Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 05.08.22
droyo33 droyo33 ist offline
Neues Mitglied
 
Registriert seit: Jun 2021
Beiträge: 29
droyo33 befindet sich auf einem aufstrebenden Ast
Standard Swing Highs & Low identifizieren mit EA

Hallo zusammen,

ich möchte mit meinem EA Highs und Lows identifizieren so wie es der Fractals Indikator tut, nur dass ich den Indikator quasi in meinen EA überführe und mir die Highs & Lows in zb. ein Array speichere.

Die Indikatoren nutzen ja die int Start() Funktion, die ich in einem EA nicht habe.
Ich habe probiert den Code von Fractals in mein EA zu überführen nur leider hat es nicht geklappt.

Welche Möglichkeiten gibt es da bspw.?
Könnte ich den Fractals Indikator theoretisch mit anpassungen in mein EA überführen?

Code des Indikators sieht folgendermaßen aus:

Code:
//
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int Equals=5;
extern int nLeftUp=2;
extern int nRightUp=2;
extern int nLeftDown=2;
extern int nRightDown=2;
//---- buffers
double FractalsUp[];
double FractalsDown[];
//----
int pos=0,cntup=0,cntdown=0,cnt=0;
int r=0,l=0,e=0;
int fup=0,fdown=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,FractalsUp);
   SetIndexBuffer(1,FractalsDown);
//----
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexArrow(0,217);
//----
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(1,218);
//----
   cntup=nLeftUp+nRightUp+Equals+1;
   cntdown=nLeftDown+Equals+1;
   if(cntup>=cntdown)
      cnt=cntup;
   if(cntup<cntdown)
      cnt=cntdown;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i=0,j=0;
   int cbars=IndicatorCounted();
//----
   if(cbars<0)
      return(-1);
//----
   if(cbars>0)
      cbars--;
   pos=0;
//----
   if(cbars>(Bars-cnt-1))
      pos=(Bars-cnt-1);
   else
      pos=Bars -(cbars+nRightUp);
  if(cbars==0) pos-=Equals;       
//----
   while(pos>=nRightUp)
     {
      FractalsUp[pos]=NULL;
      FractalsDown[pos]=NULL;
      //ôÐÀÊÒÀË ÂÂÅÐÕ
      r=nRightUp; //ïðîâåðÿåì ïðàâóþ ñòîðîíó ôðàêòàëà
      //----
      for(i=1; i<=r; i++)
        {
         if(High[pos]<=High[pos-i])
            break;
        }
      //åñëè ñïðàâà âñå ÎÊ òî i äîëæíî áûòü ðàâíî r+1
      if(i==r+1) //FractalsUp[pos]=High[pos];
        {
         l=nLeftUp;  //ïðîâåðÿåì ëåâóþ ñòîðîíó ôðàêòàëà
         e= Equals;
         //----
         for(j=1; j<=l+Equals; j++)
           {
            if(High[pos]<High[pos+j])
               break;
            //----
            if(High[pos]>High[pos+j])
               l--;
            //----
            if(High[pos]==High[pos+j])
               e--;
            //----
            if(l==0)
              {
               FractalsUp[pos]=High[pos];
               break;
              }
            //----
            if(e<0)
               break;
           }
        }
      //ÔÐÀÊÒÀË ÂÍÈÇ
      r=nRightDown; //ïðîâåðÿåì ïðàâóþ ñòîðîíó ôðàêòàëà
      //----
      for(i=1; i<=r; i++)
        {
         if(Low[pos]>=Low[pos-i])
            break;
        }
      //----
      if(i==r+1) //FractalsUp[pos]=High[pos];
        {
         l=nLeftDown;  //ïðîâåðÿåì ëåâóþ ñòîðîíó ôðàêòàëà
         e= Equals;
         //----
         for(j=1; j<=l+Equals; j++)
           {
            if(Low[pos]>Low[pos+j])
               break;
            //----
            if(Low[pos]<Low[pos+j])
               l--;
            //----
            if(Low[pos]==Low[pos+j])
               e--;
            //----
            if(l==0)
              {
               FractalsDown[pos]=Low[pos];
               break;
              }
            if(e<0)
               break;
           }
        }
      pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Das würde ich gerne in meinen EA implementieren, geht das überhaupt?

Beste Grüße