Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Hilfe beim Indikator bauen (http://www.expert-advisor.com/forum/showthread.php?t=6618)

Sirocool 29.03.20 17:49

Hilfe beim Indikator bauen
 
Hey Leute ich bräuchte mal Hilfe bei was bin neu Hier und probiere gerade mal was aus.

der Indikator berechnet drei Indikatoren (RSI;STOCH;CCI) und soll mir das unten dann anzeigen wie beim RSI in einer Linie die auch zickzack macht und nicht gerade durchgeht. Wäre euch dankbar dabei mir mal zuhelfen :)

[IMG]blob:https://mega.nz/12aa580d-0748-43e5-9e10-34e66155dc77[/IMG]

und hier der Mql4 Code

Code:

//+------------------------------------------------------------------+
//|                                                            2.mq4 |
//|                                          M.Streit Copyright 2020 |
//|                                            https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "M.Streit Copyright 2020"
#property link      "https://www.mql5.com"
#property version  "1.00"
#property strict
#property indicator_separate_window
//#property indicator_chart_window
#property indicator_buffers 1
#property indicator_width1  1
#property indicator_width2  1
#property indicator_minimum -200
#property indicator_maximum 200



double tops[];
double bottoms[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                        |
//+------------------------------------------------------------------+
int OnInit()
  {
IndicatorShortName("Beta2020"); 
 
SetIndexBuffer(0,tops);
SetIndexStyle(0,DRAW_LINE,EMPTY,1,clrBlue);
SetIndexLabel(0,"tops");

SetIndexBuffer(1,bottoms);
SetIndexStyle(1,DRAW_LINE);
SetIndexLabel(0,"bottoms");
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
/* Berechnung des Indikatorwertes den er ausgeben soll */ 
double RSIWert = DoubleToStr(iRSI(Symbol(),0,14,PRICE_CLOSE,1),2);
double CCIWERT = DoubleToStr(iCCI(Symbol(),0,14,PRICE_CLOSE,0),2);
double SToWERT = DoubleToStr(iStochastic(Symbol(),0,14,3,3,MODE_SMA,0,MODE_MAIN,0),2);
/* Ausgabewert den er ausgeben soll */
double DWert = DoubleToStr((SToWERT+RSIWert+CCIWERT)/3,2);
 
 for(int i=Bars-1;i>=0;i--)
 {
 tops[i]=DWert;
 //bottoms[i]=Low[i];
 }
 
//--- return value of prev_calculated for next call
  return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
 
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
 
  }
//+------------------------------------------------------------------+

Mit freundlichen Grüßen

Sirocool

AVT 30.03.20 04:31

Zitat:

Zitat von Sirocool (Beitrag 43443)
der Indikator berechnet drei Indikatoren (RSI;STOCH;CCI) und soll mir das unten dann anzeigen wie beim RSI in einer Linie die auch zickzack macht und nicht gerade durchgeht. Wäre euch dankbar dabei mir mal zuhelfen :)l

Ich kann mir etwa denken, was Du vorhast. Problem dabei:
  1. RSI und Stochastic haben feste Grenzen - nämlich 100 und -100.
  2. CCI geht über diese Werte hinaus - und wenn das passiert, bedeutet das bei >100 Longtrend und bei <-100 Shorttrend.
    Übrigens: ein Max/Miin bei 200/-200 geht nicht, der CCI kann durchaus höhere Werte haben (sieh Dir mal CCI(14) im DAX Daily/Weekly an).
Man könnte den ersten Punkt umrechnen, dazu müßte man aber definieren, ab welchem Level bei RSI und Stochastic der Trend beginnt - das entspricht z.B. einer Interpretation, die sagt "Long wenn RSI über 80 und Short wenn RSI unter 20".

Ich hab schon mal ne "Arbeitsversion" nach dem gemacht, was ich in Deinem Code gefunden habe, aber bisher sieht die Linie nur etwas unruhiger als ein CCI(14) aus.

Zitat:

[IMG]blob:https://mega.nz/12aa580d-0748-43e5-9e10-34e66155dc77[/IMG]
Da gibt es nur Reklame für meag.nz zu sehen, sonst nix. :confused:
AVT

Sirocool 30.03.20 11:13

Brauche Hilfe beim Indikator erstellen
 
https://s19.directupload.net/images/200330/phmcy7yt.jpg


Bild wurde Bearbeitet nicht mehr bei Mega.nz in meiner Cloud müsste jetzt gehen.

Mit freundlichen Grüßen

Sirocool[/QUOTE]

AVT 30.03.20 21:31

Liste der Anhänge anzeigen (Anzahl: 1)
Ich habe den Indi mal gebaut (einzige Abweichung: iRSI(Symbol(),0,14,PRICE_CLOSE,1) => iRSI(Symbol(),0,14,PRICE_CLOSE,0) weil die anderen beiden auch den aktuellen Wert nehmen).
Probier's mal aus, ob Du Dir das so gedacht hast.
AVT

Sirocool 31.03.20 12:14

Ich glaube ich ahbe die lösung raus
 
hie mal der Mql4code




https://www.file-upload.net/download...206/3.jpg.html

3.jpg


Code:


//
#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_minimum -200
#property indicator_maximum  200
#property indicator_color1 Black
extern int barsToProcess=100;
double ExtMapBuffer1[];

int init()
{
  SetIndexStyle(0,DRAW_LINE);
  SetIndexBuffer(0,ExtMapBuffer1);
  MathSrand(TimeLocal());
  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                      |
//+------------------------------------------------------------------+
int deinit()
{
  ObjectsDeleteAll();
  // Löschen wir alle Objekte
 
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{


MathSrand(GetTickCount());
double RSIWert = iRSI(Symbol(),0,14,PRICE_CLOSE,1);
double CCIWERT = iCCI(Symbol(),0,14,PRICE_CLOSE,0); //DoubleToStr("",2);
double SToWERT = iStochastic(Symbol(),0,14,3,3,MODE_SMA,0,MODE_MAIN,0);
double DWert = (SToWERT+RSIWert+CCIWERT)/3;

  int counted_bars=IndicatorCounted(),
      limit;
 
  if(counted_bars>0)
      counted_bars--;
 
  limit=Bars-counted_bars;
 
  if(limit>barsToProcess)
      limit=barsToProcess;
 
  for(int i=0;i<limit;i++)
  {
      ExtMapBuffer1[i]=DWert*MathRand()/32767;//MathRand()%2; //MathSrand(GetTickCount());  //MathRand()%1001;
  }
 
  return(0);
}


Sirocool 06.04.20 15:14

So ist Fertig
 
https://s19.directupload.net/images/200406/wxbg9aor.jpg



Code:

//
#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 3


#property indicator_minimum -20
#property indicator_maximum  20

extern int barsToProcess=100;
double TrendUp[], TrendDn[],SignalUp[];

string indicatorFileName;


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
{

  SetIndexBuffer(0,SignalUp);SetIndexStyle(0,DRAW_LINE,EMPTY,0,clrBlack);
  SetIndexBuffer(1,TrendUp);SetIndexStyle(1,DRAW_LINE,EMPTY,0,clrRed);
  SetIndexBuffer(2,TrendDn);SetIndexStyle(2,DRAW_LINE,EMPTY,0,clrGreen);
 
 
  indicatorFileName = WindowExpertName();
     
   
       
  IndicatorShortName("Score 2020 " + "Signalwert:");
 
 
 
 
 
  MathSrand(TimeLocal());
  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                      |
//+------------------------------------------------------------------+
int deinit()
{
  ObjectsDeleteAll();
  // Löschen wir alle Objekte
 
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{



  int counted_bars=IndicatorCounted(),
      limit;
 
  if(counted_bars>0)
      counted_bars--;
 
  limit=Bars-counted_bars;
 
  if(limit>barsToProcess)
      limit=barsToProcess;
   
   

  for(int i=0;i<limit;i++)
  {
  double Scoreindex = 0;
 
 
  double cci = iCCI(NULL,0,14,PRICE_TYPICAL,i);
              if (cci < -100) Scoreindex -=5;
              if (cci >  100) Scoreindex +=5;

        double rsi = iRSI(NULL,0,14,PRICE_CLOSE,i);
              if (rsi < 30) Scoreindex -=5;
              if (rsi > 70) Scoreindex +=5;
             
        double stoFastK = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_MAIN  ,i);
        double stoFastD = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_SIGNAL,i);
              if (stoFastK < 20) Scoreindex -=5;
              if (stoFastK > 80) Scoreindex +=5;
              if (stoFastD < 20) Scoreindex -=5;
              if (stoFastD > 80) Scoreindex +=5;
 
 
  /*
 
  if( insyncScore>=20)
  {
  TrendUp[i]=DoubleToStr(insyncScore,2);//iCCI(Symbol(),0,14,PRICE_CLOSE,i);
  }
  if( insyncScore>=-20)SetIndexStyle(3,DRAW_LINE,EMPTY,EMPTY,clrGreen);
  {
  SignalUp[i]=DoubleToStr(insyncScore,2);//iCCI(Symbol(),0,14,PRICE_CLOSE,i);
  }
  */
  if(Scoreindex>+0)TrendUp[i]=DoubleToStr(Scoreindex,2);
  if(Scoreindex<-0)TrendDn[i]=DoubleToStr(Scoreindex,2);
  //if(Scoreindex=0)SignalUp[i]=DoubleToStr(Scoreindex,2);
  SignalUp[i]=DoubleToStr(Scoreindex,2);
 
  }
 
  return(0);
}




/*




*/


AVT 06.04.20 20:35

Gefällt mir sehr gut, Deine Stufenlösung :D
AVT

Sirocool 15.04.20 20:29

Update Indikator berechnet jetzt auch Alte kerzen verläufe
 
https://www.bilder-upload.eu/thumb/0...1586975338.jpg




Code:


//
#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_style1  STYLE_DOT
#property indicator_style2  STYLE_DOT
#property indicator_style3  STYLE_DOT
#property indicator_minimum -30
#property indicator_maximum  30
#property indicator_level1    -20
#property indicator_level2    0
#property indicator_level3    20

#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT


extern int barsToProcess=100;
double TrendUp[], TrendDn[],SignalUp[];

string indicatorFileName;

string Lizenzcode = "12104499";

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
{
//if (AccountNumber() != Lizenzcode) return(INIT_FAILED);

  SetIndexBuffer(0,SignalUp);SetIndexStyle(0,DRAW_LINE,0,1,clrBlack);
  SetIndexBuffer(1,TrendUp);SetIndexStyle(1,DRAW_LINE,0,2,clrRed);
  SetIndexBuffer(2,TrendDn);SetIndexStyle(2,DRAW_LINE,0,2,clrGreen);
 
 
  indicatorFileName = WindowExpertName();
     
   
       
  IndicatorShortName("Score 2020 " + "Signalwert:");
 
 
 
 
 
  MathSrand(TimeLocal());
  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                      |
//+------------------------------------------------------------------+
int deinit()
{
  ObjectsDeleteAll();
  // Löschen wir alle Objekte
 
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{

int i, limit, counted_bars=IndicatorCounted();

  limit=Bars-counted_bars;
  /*limit= MathMin(Bars-counted_bars,Bars-1);//Bars;//MathMin(Bars-counted_bars,Bars-1);//Bars-counted_bars;
        limit=barsToProcess;
    if(counted_bars>0)
      counted_bars--;
     
 // if(limit>barsToProcess);
   
 */
 
 
 

   
   
//for (i=limit, r=Bars-i-1; i>=0; i--,r++)  for(i=limit;i<limit;i++)
  for(i=limit;i>=0;i--)
  {
  double Scoreindex = 0;
 
 
  double cciclose = iCCI(NULL,0,14,PRICE_CLOSE,i);
              if (cciclose < -100) Scoreindex -=5;
              if (cciclose >  100) Scoreindex +=5;
  double cciopen = iCCI(NULL,0,14,PRICE_OPEN,i);
              if (cciopen < -100) Scoreindex -=5;
              if (cciopen >  100) Scoreindex +=5;           

        double rsi = iRSI(NULL,0,14,PRICE_CLOSE,i);
              if (rsi < 20) Scoreindex -=5;
              if (rsi > 70) Scoreindex +=5;
             
        double stoFastK = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_MAIN  ,i);
        double stoFastD = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_SIGNAL,i);
              if (stoFastK < 20) Scoreindex -=5;
              if (stoFastK > 80) Scoreindex +=5;
              if (stoFastD < 20) Scoreindex -=5;
              if (stoFastD > 80) Scoreindex +=5;
 
 

 
  if(Scoreindex>0)TrendUp[i]=DoubleToStr(Scoreindex,2);
  if(Scoreindex<0)TrendDn[i]=DoubleToStr(Scoreindex,2);
  //if(Scoreindex=0)SignalUp[i]=DoubleToStr(Scoreindex,2);
 
  //ExtCCIBuffer[i]=(ExtPriceBuffer[i]-ExtMovBuffer[i])/dSum;
  SignalUp[i]=DoubleToStr(Scoreindex,2);

  }
 
  return(0);
}


Sirocool 08.05.20 19:31

Updates
 
Heute mal ein kleines Update für euch werde diesmal keinen Quellcod mit liefern so lange das Hauptproject nicht fertig ist. Wer die ex4 Dateien haben möchte meldet sich einfach bei mir.

https://www.minpic.de/t/adii/wh2m6

Mit freundlichen Grüßen

Sirocool


Alle Zeitangaben in WEZ +2. Es ist jetzt 14:38 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum