Indicator from MQL4 to MQL5

MQL5 Konvertierung

Auftrag beendet

Ausführungszeit 10 Minuten
Bewertung des Kunden
very fast and friendly.

Spezifikation

I have an indicator in MQL4 but I need it in MQL5. It's a Chandelier Exit indicator. The MQL5 indicator must show the exact same signals as the MQL4 indicator.

#property indicator_chart_window

#property indicator_buffers 6

#property indicator_color1 clrLimeGreen

#property indicator_color2 clrOrange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_color3 clrLimeGreen

#property indicator_color4 clrOrange

#property indicator_width3 2

#property indicator_width4 2


#property strict


extern int bars = 10000;

           

extern int             length      = 1;             

extern double          multiplier  = 2.0;            

extern bool            useClose = true;           


extern bool arrows = true;//Main Chart Arrows

extern int arrowBuyCode = 233;

extern int arrowSellCode = 234;

extern int arrowBuySize = 2;

extern int arrowSellSize = 2;

extern color arrowColorBuy = clrGreen;

extern color arrowColorSell = clrRed;

extern double ArrowDistanceBuy = 2;

extern double ArrowDistanceSell = 2;

extern int ArrowRef = 1234;

string indicatorFileName;


//

double longStop_[],longStop[];

double shortStop_[],shortStop[];

int OnInit()

{


  

      

      

      SetIndexBuffer(2, longStop);

      SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2); 

      SetIndexBuffer(3, shortStop);

      SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2); 

       

      SetIndexBuffer(4, longStop_);

      SetIndexStyle(4,DRAW_NONE); 

      SetIndexBuffer(5, shortStop_);

      SetIndexStyle(5,DRAW_NONE); 

      

      

      SetIndexBuffer(0,up_arr);

      SetIndexStyle(0,DRAW_ARROW,EMPTY,arrowBuySize,arrowColorBuy);

      SetIndexArrow(0,arrowBuyCode);

      SetIndexLabel(0,"UP arrow");

      

      SetIndexBuffer(1,dn_arr);

      SetIndexStyle(1,DRAW_ARROW,EMPTY,arrowSellSize,arrowColorSell);

      SetIndexArrow(1,arrowSellCode);

      SetIndexLabel(1,"DOWN arrow");

     

      indicatorFileName = WindowExpertName();

   return(0);

}

 double up_arr[];

 double dn_arr[];



void OnDeinit(const int reason) { }



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[])

{

   int limit;

   int CountedBars=IndicatorCounted();

   if(CountedBars>Bars-1) CountedBars=Bars-1;

   if(CountedBars<0) return(-1);

   if(CountedBars>0) CountedBars--;

   if(CountedBars<10) CountedBars = 10;

   limit=Bars-1-CountedBars;

   

   if (limit > bars)

   {

      limit = bars;

   }

   for(int i=limit; i>=0; i--) 

   {



         double atr = multiplier * iATR(NULL,0,length,i);

        

         

            int hh;

            if (useClose)

               hh = iHighest(NULL,0,MODE_CLOSE,length,i);

            else hh = iHighest(NULL,0,MODE_HIGH,length,i);

            

            if (useClose)

            {

               longStop_[i] = iClose(NULL,0,hh) - atr;

            }

            else longStop_[i] = iHigh(NULL,0,hh) - atr;

            

            longStop_[i] = iClose(NULL,0,i+1) > longStop_[i+1] ? MathMax(longStop_[i], longStop_[i+1]) : longStop_[i];

            

            int ll;

            if (useClose)

               ll = iLowest(NULL,0,MODE_CLOSE,length,i);

            else ll = iLowest(NULL,0,MODE_LOW,length,i);

            

            if (useClose)

            {

               shortStop_[i] = iClose(NULL,0,ll) + atr;

            }

            else shortStop_[i] = iLow(NULL,0,ll) + atr;

         

            shortStop_[i] = iClose(NULL,0,i+1) < shortStop_[i+1] ? MathMin(shortStop_[i], shortStop_[i+1]) : shortStop_[i];

        

         

         

         static int prevdir ;

         


         static int dir = 1;

         dir = (iClose(NULL,0,i) > shortStop_[i+1]) ? 1 : (iClose(NULL,0,i) < longStop_[i+1] ? -1 : dir);

                     

            

         if (dir == 1)

         {

            longStop[i] = longStop_[i];

            shortStop[i] = EMPTY_VALUE;

            if (prevdir == -1)

            {

               longStop[i+1] = shortStop[i+1];

               up_arr[i] = iLow(NULL,0,i) - iATR(NULL,0,20,i)*ArrowDistanceBuy;         

            }

               

         }

         else if (dir == -1)

         {

            shortStop[i] = shortStop_[i];

            longStop[i] = EMPTY_VALUE;

            if (prevdir == 1)

            {

               shortStop[i+1] = longStop[i+1];

               dn_arr[i] = iHigh(NULL,0,i) + iATR(NULL,0,20,i)*(ArrowDistanceSell+1);       

            } 

         }   

            

         prevdir = dir;


            }

   return(rates_total);

   

Dateien:

Bewerbungen

1
Entwickler 1
Bewertung
(713)
Projekte
1032
39%
Schlichtung
47
49% / 23%
Frist nicht eingehalten
84
8%
Frei

Projektdetails

Budget
30 - 40 USD
MwSt (19%): 5.7 - 7.6 USD
Insgesamt: 35.7 - 47.6 USD
Für die Entwickler
27 - 36 USD