Error en convertir un indicador MT4 a MT5

 

Necesito ayuda estoy tratando de convertir un indicador MT4 a MT5 pero no funcion este es el código para ver si alguien sabe cual es el error

Indicador

Cuando lo paso por el probador de estrategias me sale asi

Indicadormalo

//+------------------------------------------------------------------+

//|                                            ROC-EURUSDJPYGNBP.mq4 |

//|                               Copyright © 2008, PHIL trader24    |

//|                                                                                   |

//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 5

#property indicator_plots   5


#property indicator_type1   DRAW_LINE

#property indicator_color1  DeepSkyBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1


#property indicator_type2   DRAW_LINE

#property indicator_color2  DarkOrange

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1


#property indicator_type3   DRAW_LINE

#property indicator_color3  Red

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1


#property indicator_type4   DRAW_LINE

#property indicator_color4  White

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1


#property indicator_type5   DRAW_LINE

#property indicator_color5  Green

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1


#property indicator_label1  "BufferEUR"

#property indicator_label2  "BufferUSD"

#property indicator_label3  "BufferJPY"

#property indicator_label4  "BufferGBP"

#property indicator_label5  "BufferCHF"


#define EMPTY -1

#define OBJPROP_TIME1  300

#define OBJPROP_PRICE1 301

#define OBJPROP_TIME2  302

#define OBJPROP_PRICE2 303

#define OBJPROP_TIME3  304

#define OBJPROP_PRICE3 305

//---- Paramètres

extern int Periode=14;


int TotalDevise=5;


//---- buffers

double BufferEUR[];

double BufferUSD[];

double BufferJPY[];

double BufferGBP[];

double BufferCHF[];


//+------------------------------------------------------------------+

//| Initialisation                                                   |

//+------------------------------------------------------------------+

int OnInit()

  {


   string short_name;

   short_name="ROC-";

 

//--- indicator buffers  

   SetIndexBuffer(0,BufferEUR,0);

   SetIndexBuffer(1,BufferUSD,0);

   SetIndexBuffer(2,BufferJPY,0);

   SetIndexBuffer(3,BufferGBP,0);

   SetIndexBuffer(4,BufferCHF,0);

//--- indicator digits

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//--- set draw begin

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,0);


//--- set short_name   

   short_name="ROC-";

   IndicatorSetString(INDICATOR_SHORTNAME,short_name);

   

   ArraySetAsSeries(BufferEUR,true);

   ArraySetAsSeries(BufferUSD,true);

   ArraySetAsSeries(BufferJPY,true);

   ArraySetAsSeries(BufferGBP,true);

   ArraySetAsSeries(BufferCHF,true);

        

    return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+  

int deinit()

  {

  if (ObjectFindMQL4("EUR")>=0)

     ObjectDeleteMQL4("EUR");

  return(0);

  }

//+------------------------------------------------------------------+

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

  {

   int i,counted_bars=IndicatorCountedMQL4(prev_calculated);


   int Bars=Bars(_Symbol,_Period);

   double mEURUSD;

   double mEURJPY;

   double mUSDJPY;

   double mGBPUSD;

   double mEURGBP;

   double mGBPJPY;

   double mGBPCHF;

   double mCHFJPY;

   double mEURCHF;

   double mUSDCHF;

   

  int TotalWindow=ChartGetInteger(0,CHART_WINDOWS_TOTAL);


  if (ObjectFindMQL4("EUR")<0)

     {

     ObjectCreateMQL4("EUR",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("EUR",OBJPROP_XDISTANCE,150);

     ObjectSetMQL4("EUR",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("EUR","EUR",12,"Arial",indicator_color1);

     }

  if (ObjectFindMQL4("USD")<0)

     {

     ObjectCreateMQL4("USD",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("USD",OBJPROP_XDISTANCE,200);

     ObjectSetMQL4("USD",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("USD","USD",12,"Arial",indicator_color2);

     }

  if (ObjectFindMQL4("JPY")<0)

     {

     ObjectCreateMQL4("JPY",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("JPY",OBJPROP_XDISTANCE,250);

     ObjectSetMQL4("JPY",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("JPY","JPY",12,"Arial",indicator_color3);

     }

  if (ObjectFindMQL4("GBP")<0)

     {

     ObjectCreateMQL4("GBP",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("GBP",OBJPROP_XDISTANCE,300);

     ObjectSetMQL4("GBP",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("GBP","GBP",12,"Arial",indicator_color4);

     }

  if (ObjectFindMQL4("CHF")<0)

     {

     ObjectCreateMQL4("CHF",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("CHF",OBJPROP_XDISTANCE,350);

     ObjectSetMQL4("CHF",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("CHF","CHF",12,"Arial",indicator_color5);

     }


 //--- detect start position

   int start;

   if(prev_calculated>1)

      start=prev_calculated-1;

   else

     {

      start=1;

      BufferEUR[0]=0.0;

      BufferUSD[0]=0.0;

      BufferJPY[0]=0.0;

      BufferGBP[0]=0.0;

      BufferCHF[0]=0.0; 

     }


//--- main cycle

   for(i=start; i<rates_total && !IsStopped(); i++)

     {   

     mEURUSD= NormalizeDouble((iClose("EURUSD",0,i)-iClose("EURUSD",0,i+Periode))/0.0001,0);  

     mEURJPY= NormalizeDouble((iClose("EURJPY",0,i)-iClose("EURJPY",0,i+Periode))/0.01,0);  

     mUSDJPY= NormalizeDouble((iClose("USDJPY",0,i)-iClose("USDJPY",0,i+Periode))/0.01,0);  

     mCHFJPY= NormalizeDouble((iClose("USDJPY",0,i)-iClose("USDJPY",0,i+Periode))/0.01,0);

     mUSDCHF= NormalizeDouble((iClose("USDCHF",0,i)-iClose("USDCHF",0,i+Periode))/0.0001,0); 

     

     mGBPJPY= NormalizeDouble((iClose("GBPJPY",0,i)-iClose("GBPJPY",0,i+Periode))/0.01,0);  

     mEURGBP= NormalizeDouble((iClose("EURGBP",0,i)-iClose("EURGBP",0,i+Periode))/0.0001,0);  

     mGBPUSD= NormalizeDouble((iClose("GBPUSD",0,i)-iClose("GBPUSD",0,i+Periode))/0.0001,0);

     mGBPCHF= NormalizeDouble((iClose("GBPCHF",0,i)-iClose("GBPCHF",0,i+Periode))/0.0001,0); 

     mEURCHF= NormalizeDouble((iClose("EURCHF",0,i)-iClose("EURCHF",0,i+Periode))/0.0001,0); 

     

     BufferEUR[i]=(BufferEUR[i+1]+BufferEUR[i+2]+((mEURUSD+mEURJPY+mEURGBP+mEURCHF)/(TotalDevise-1)))/4;

     BufferUSD[i]=(BufferUSD[i+1]+BufferUSD[i+2]+((mUSDJPY-mEURUSD-mGBPUSD+mUSDCHF)/(TotalDevise-1)))/4;

     BufferJPY[i]=(BufferJPY[i+1]+BufferJPY[i+2]+((mEURJPY-mUSDJPY-mGBPJPY-mUSDJPY)/(TotalDevise-1)))/4;  

     BufferGBP[i]=(BufferGBP[i+1]+BufferGBP[i+2]+((mEURGBP+mGBPJPY+mGBPUSD+mGBPCHF)/(TotalDevise-1)))/4;

     BufferCHF[i]=(BufferCHF[i+1]+BufferCHF[i+2]+((mCHFJPY-mGBPCHF-mUSDCHF-mEURCHF)/(TotalDevise-1)))/4;

     }

     

   return(rates_total);

  }

//+-----------------------  CONVERSION  -------------------------------------------+  

 int ObjectFindMQL4(string name)

  {

   return(ObjectFind(0,name));

  } 

//+------------------------------------------------------------------+  

 int IndicatorCountedMQL4(int prev_calculated)

  {

   if(prev_calculated>0) return(prev_calculated-1);

   if(prev_calculated==0) return(0);

   return(0);

  }

//+------------------------------------------------------------------+  

  bool ObjectCreateMQL4(string name,

                      ENUM_OBJECT type,

                      int window,

                      datetime time1,

                      double price1,

                      datetime time2=0,

                      double price2=0,

                      datetime time3=0,

                      double price3=0)

  {

   return(ObjectCreate(0,name,type,window,

          time1,price1,time2,price2,time3,price3));

  }

//+------------------------------------------------------------------+  

  bool ObjectSetMQL4(string name,

                   int index,

                   double value)

  {

   switch(index)

     {

      case OBJPROP_TIME1:

         ObjectSetInteger(0,name,OBJPROP_TIME,(int)value);return(true);

      case OBJPROP_PRICE1:

         ObjectSetDouble(0,name,OBJPROP_PRICE,value);return(true);

      case OBJPROP_TIME2:

         ObjectSetInteger(0,name,OBJPROP_TIME,1,(int)value);return(true);

      case OBJPROP_PRICE2:

         ObjectSetDouble(0,name,OBJPROP_PRICE,1,value);return(true);

      case OBJPROP_TIME3:

         ObjectSetInteger(0,name,OBJPROP_TIME,2,(int)value);return(true);

      case OBJPROP_PRICE3:

         ObjectSetDouble(0,name,OBJPROP_PRICE,2,value);return(true);

      case OBJPROP_COLOR:

         ObjectSetInteger(0,name,OBJPROP_COLOR,(int)value);return(true);

      case OBJPROP_STYLE:

         ObjectSetInteger(0,name,OBJPROP_STYLE,(int)value);return(true);

      case OBJPROP_WIDTH:

         ObjectSetInteger(0,name,OBJPROP_WIDTH,(int)value);return(true);

      case OBJPROP_BACK:

         ObjectSetInteger(0,name,OBJPROP_BACK,(int)value);return(true);

      case OBJPROP_RAY:

         ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,(int)value);return(true);

      case OBJPROP_ELLIPSE:

         ObjectSetInteger(0,name,OBJPROP_ELLIPSE,(int)value);return(true);

      case OBJPROP_SCALE:

         ObjectSetDouble(0,name,OBJPROP_SCALE,value);return(true);

      case OBJPROP_ANGLE:

         ObjectSetDouble(0,name,OBJPROP_ANGLE,value);return(true);

      case OBJPROP_ARROWCODE:

         ObjectSetInteger(0,name,OBJPROP_ARROWCODE,(int)value);return(true);

      case OBJPROP_TIMEFRAMES:

         ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,(int)value);return(true);

      case OBJPROP_DEVIATION:

         ObjectSetDouble(0,name,OBJPROP_DEVIATION,value);return(true);

      case OBJPROP_FONTSIZE:

         ObjectSetInteger(0,name,OBJPROP_FONTSIZE,(int)value);return(true);

      case OBJPROP_CORNER:

         ObjectSetInteger(0,name,OBJPROP_CORNER,(int)value);return(true);

      case OBJPROP_XDISTANCE:

         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,(int)value);return(true);

      case OBJPROP_YDISTANCE:

         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,(int)value);return(true);

      case OBJPROP_LEVELS:

         ObjectSetInteger(0,name,OBJPROP_LEVELS,(int)value);return(true);

      case OBJPROP_LEVELCOLOR:

         ObjectSetInteger(0,name,OBJPROP_LEVELCOLOR,(int)value);return(true);

      case OBJPROP_LEVELSTYLE:

         ObjectSetInteger(0,name,OBJPROP_LEVELSTYLE,(int)value);return(true);

      case OBJPROP_LEVELWIDTH:

         ObjectSetInteger(0,name,OBJPROP_LEVELWIDTH,(int)value);return(true);


      default: return(false);

     }

   return(false);

  }

//+------------------------------------------------------------------+  

 

  bool ObjectSetTextMQL4(string name,

                       string text,

                       int font_size,

                       string font="",

                       color text_color=CLR_NONE)

  {

   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);

   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);

   if(StringLen(text)>0 && font_size>0)

     {

      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true

         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)

        {

         if((StringLen(font)>0)

            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)

            return(false);

         if(ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)

            return(false);

         return(true);

        }

      return(false);

     }

   return(false);

  }

//+------------------------------------------------------------------+  

  void SetIndexStyleMQL4(int index,

                       int type,

                       int style=EMPTY,

                       int width=EMPTY,

                       color clr=CLR_NONE)

  {

   if(width>-1)

      PlotIndexSetInteger(index,PLOT_LINE_WIDTH,width);

   if(clr!=CLR_NONE)

      PlotIndexSetInteger(index,PLOT_LINE_COLOR,clr);

   switch(type)

     {

      case 0:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);

      case 1:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_SECTION);

      case 2:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);

      case 3:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ARROW);

      case 4:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ZIGZAG);

      case 12:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_NONE);


      default:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);

     }

   switch(style)

     {

      case 0:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_SOLID);

      case 1:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASH);

      case 2:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DOT);

      case 3:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOT);

      case 4:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOTDOT);


      default: return;

     }

  }     

//+------------------------------------------------------------------+  

  

 void SetLevelStyleMQL4(int draw_style,

                       int line_width,

                       color clr=CLR_NONE)

  {

   IndicatorSetInteger(INDICATOR_LEVELWIDTH,line_width);

   if(clr!=CLR_NONE)

      IndicatorSetInteger(INDICATOR_LEVELCOLOR,clr);

   switch(draw_style)

     {

      case 0:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_SOLID);

      case 1:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASH);

      case 2:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DOT);

      case 3:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOT);

      case 4:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOTDOT);


      default: return;

     }

  } 

 //+------------------------------------------------------------------+  

 

  bool ObjectDeleteMQL4(string name)

  {

   return(ObjectDelete(0,name));

  }

  

//+------------------------------------------------------------------+  

 

double iCloseMQL4(string symbol,int tf,int index)

{

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

   double Arr[];

   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);

   if(CopyClose(symbol,timeframe, index, 1, Arr)>0) 

        return(Arr[0]);

   else 

        return(-1);

}  


//+------------------------------------------------------------------+  

ENUM_TIMEFRAMES TFMigrate(int tf)

  {

   switch(tf)

     {

      case 0: return(PERIOD_CURRENT);

      case 1: return(PERIOD_M1);

      case 5: return(PERIOD_M5);

      case 15: return(PERIOD_M15);

      case 30: return(PERIOD_M30);

      case 60: return(PERIOD_H1);

      case 240: return(PERIOD_H4);

      case 1440: return(PERIOD_D1);

      case 10080: return(PERIOD_W1);

      case 43200: return(PERIOD_MN1);

      

      case 2: return(PERIOD_M2);

      case 3: return(PERIOD_M3);

      case 4: return(PERIOD_M4);      

      case 6: return(PERIOD_M6);

      case 10: return(PERIOD_M10);

      case 12: return(PERIOD_M12);

      case 16385: return(PERIOD_H1);

      case 16386: return(PERIOD_H2);

      case 16387: return(PERIOD_H3);

      case 16388: return(PERIOD_H4);

      case 16390: return(PERIOD_H6);

      case 16392: return(PERIOD_H8);

      case 16396: return(PERIOD_H12);

      case 16408: return(PERIOD_D1);

      case 32769: return(PERIOD_W1);

      case 49153: return(PERIOD_MN1);      

      default: return(PERIOD_CURRENT);

     }

  }

//+-----------------------  CONVERSION  -------------------------------------------+  


 
Jesus Mosquera:

Necesito ayuda estoy tratando de convertir un indicador MT4 a MT5 pero no funcion este es el código para ver si alguien sabe cual es el error

Cuando lo paso por el probador de estrategias me sale asi


//+------------------------------------------------------------------+

//|                                            ROC-EURUSDJPYGNBP.mq4 |

//|                               Copyright © 2008, PHIL trader24    |

//|                                                                                   |

//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 5

#property indicator_plots   5


#property indicator_type1   DRAW_LINE

#property indicator_color1  DeepSkyBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1


#property indicator_type2   DRAW_LINE

#property indicator_color2  DarkOrange

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1


#property indicator_type3   DRAW_LINE

#property indicator_color3  Red

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1


#property indicator_type4   DRAW_LINE

#property indicator_color4  White

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1


#property indicator_type5   DRAW_LINE

#property indicator_color5  Green

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1


#property indicator_label1  "BufferEUR"

#property indicator_label2  "BufferUSD"

#property indicator_label3  "BufferJPY"

#property indicator_label4  "BufferGBP"

#property indicator_label5  "BufferCHF"


#define EMPTY -1

#define OBJPROP_TIME1  300

#define OBJPROP_PRICE1 301

#define OBJPROP_TIME2  302

#define OBJPROP_PRICE2 303

#define OBJPROP_TIME3  304

#define OBJPROP_PRICE3 305

//---- Paramètres

extern int Periode=14;


int TotalDevise=5;


//---- buffers

double BufferEUR[];

double BufferUSD[];

double BufferJPY[];

double BufferGBP[];

double BufferCHF[];


//+------------------------------------------------------------------+

//| Initialisation                                                   |

//+------------------------------------------------------------------+

int OnInit()

  {


   string short_name;

   short_name="ROC-";

 

//--- indicator buffers  

   SetIndexBuffer(0,BufferEUR,0);

   SetIndexBuffer(1,BufferUSD,0);

   SetIndexBuffer(2,BufferJPY,0);

   SetIndexBuffer(3,BufferGBP,0);

   SetIndexBuffer(4,BufferCHF,0);

//--- indicator digits

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//--- set draw begin

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,0);

   PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,0);


//--- set short_name   

   short_name="ROC-";

   IndicatorSetString(INDICATOR_SHORTNAME,short_name);

   

   ArraySetAsSeries(BufferEUR,true);

   ArraySetAsSeries(BufferUSD,true);

   ArraySetAsSeries(BufferJPY,true);

   ArraySetAsSeries(BufferGBP,true);

   ArraySetAsSeries(BufferCHF,true);

        

    return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+  

int deinit()

  {

  if (ObjectFindMQL4("EUR")>=0)

     ObjectDeleteMQL4("EUR");

  return(0);

  }

//+------------------------------------------------------------------+

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

  {

   int i,counted_bars=IndicatorCountedMQL4(prev_calculated);


   int Bars=Bars(_Symbol,_Period);

   double mEURUSD;

   double mEURJPY;

   double mUSDJPY;

   double mGBPUSD;

   double mEURGBP;

   double mGBPJPY;

   double mGBPCHF;

   double mCHFJPY;

   double mEURCHF;

   double mUSDCHF;

   

  int TotalWindow=ChartGetInteger(0,CHART_WINDOWS_TOTAL);


  if (ObjectFindMQL4("EUR")<0)

     {

     ObjectCreateMQL4("EUR",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("EUR",OBJPROP_XDISTANCE,150);

     ObjectSetMQL4("EUR",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("EUR","EUR",12,"Arial",indicator_color1);

     }

  if (ObjectFindMQL4("USD")<0)

     {

     ObjectCreateMQL4("USD",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("USD",OBJPROP_XDISTANCE,200);

     ObjectSetMQL4("USD",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("USD","USD",12,"Arial",indicator_color2);

     }

  if (ObjectFindMQL4("JPY")<0)

     {

     ObjectCreateMQL4("JPY",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("JPY",OBJPROP_XDISTANCE,250);

     ObjectSetMQL4("JPY",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("JPY","JPY",12,"Arial",indicator_color3);

     }

  if (ObjectFindMQL4("GBP")<0)

     {

     ObjectCreateMQL4("GBP",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("GBP",OBJPROP_XDISTANCE,300);

     ObjectSetMQL4("GBP",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("GBP","GBP",12,"Arial",indicator_color4);

     }

  if (ObjectFindMQL4("CHF")<0)

     {

     ObjectCreateMQL4("CHF",OBJ_LABEL,TotalWindow-1,0,0);

     ObjectSetMQL4("CHF",OBJPROP_XDISTANCE,350);

     ObjectSetMQL4("CHF",OBJPROP_YDISTANCE,1);

     ObjectSetTextMQL4("CHF","CHF",12,"Arial",indicator_color5);

     }


 //--- detect start position

   int start;

   if(prev_calculated>1)

      start=prev_calculated-1;

   else

     {

      start=1;

      BufferEUR[0]=0.0;

      BufferUSD[0]=0.0;

      BufferJPY[0]=0.0;

      BufferGBP[0]=0.0;

      BufferCHF[0]=0.0; 

     }


//--- main cycle

   for(i=start; i<rates_total && !IsStopped(); i++)

     {   

     mEURUSD= NormalizeDouble((iClose("EURUSD",0,i)-iClose("EURUSD",0,i+Periode))/0.0001,0);  

     mEURJPY= NormalizeDouble((iClose("EURJPY",0,i)-iClose("EURJPY",0,i+Periode))/0.01,0);  

     mUSDJPY= NormalizeDouble((iClose("USDJPY",0,i)-iClose("USDJPY",0,i+Periode))/0.01,0);  

     mCHFJPY= NormalizeDouble((iClose("USDJPY",0,i)-iClose("USDJPY",0,i+Periode))/0.01,0);

     mUSDCHF= NormalizeDouble((iClose("USDCHF",0,i)-iClose("USDCHF",0,i+Periode))/0.0001,0); 

     

     mGBPJPY= NormalizeDouble((iClose("GBPJPY",0,i)-iClose("GBPJPY",0,i+Periode))/0.01,0);  

     mEURGBP= NormalizeDouble((iClose("EURGBP",0,i)-iClose("EURGBP",0,i+Periode))/0.0001,0);  

     mGBPUSD= NormalizeDouble((iClose("GBPUSD",0,i)-iClose("GBPUSD",0,i+Periode))/0.0001,0);

     mGBPCHF= NormalizeDouble((iClose("GBPCHF",0,i)-iClose("GBPCHF",0,i+Periode))/0.0001,0); 

     mEURCHF= NormalizeDouble((iClose("EURCHF",0,i)-iClose("EURCHF",0,i+Periode))/0.0001,0); 

     

     BufferEUR[i]=(BufferEUR[i+1]+BufferEUR[i+2]+((mEURUSD+mEURJPY+mEURGBP+mEURCHF)/(TotalDevise-1)))/4;

     BufferUSD[i]=(BufferUSD[i+1]+BufferUSD[i+2]+((mUSDJPY-mEURUSD-mGBPUSD+mUSDCHF)/(TotalDevise-1)))/4;

     BufferJPY[i]=(BufferJPY[i+1]+BufferJPY[i+2]+((mEURJPY-mUSDJPY-mGBPJPY-mUSDJPY)/(TotalDevise-1)))/4;  

     BufferGBP[i]=(BufferGBP[i+1]+BufferGBP[i+2]+((mEURGBP+mGBPJPY+mGBPUSD+mGBPCHF)/(TotalDevise-1)))/4;

     BufferCHF[i]=(BufferCHF[i+1]+BufferCHF[i+2]+((mCHFJPY-mGBPCHF-mUSDCHF-mEURCHF)/(TotalDevise-1)))/4;

     }

     

   return(rates_total);

  }

//+-----------------------  CONVERSION  -------------------------------------------+  

 int ObjectFindMQL4(string name)

  {

   return(ObjectFind(0,name));

  } 

//+------------------------------------------------------------------+  

 int IndicatorCountedMQL4(int prev_calculated)

  {

   if(prev_calculated>0) return(prev_calculated-1);

   if(prev_calculated==0) return(0);

   return(0);

  }

//+------------------------------------------------------------------+  

  bool ObjectCreateMQL4(string name,

                      ENUM_OBJECT type,

                      int window,

                      datetime time1,

                      double price1,

                      datetime time2=0,

                      double price2=0,

                      datetime time3=0,

                      double price3=0)

  {

   return(ObjectCreate(0,name,type,window,

          time1,price1,time2,price2,time3,price3));

  }

//+------------------------------------------------------------------+  

  bool ObjectSetMQL4(string name,

                   int index,

                   double value)

  {

   switch(index)

     {

      case OBJPROP_TIME1:

         ObjectSetInteger(0,name,OBJPROP_TIME,(int)value);return(true);

      case OBJPROP_PRICE1:

         ObjectSetDouble(0,name,OBJPROP_PRICE,value);return(true);

      case OBJPROP_TIME2:

         ObjectSetInteger(0,name,OBJPROP_TIME,1,(int)value);return(true);

      case OBJPROP_PRICE2:

         ObjectSetDouble(0,name,OBJPROP_PRICE,1,value);return(true);

      case OBJPROP_TIME3:

         ObjectSetInteger(0,name,OBJPROP_TIME,2,(int)value);return(true);

      case OBJPROP_PRICE3:

         ObjectSetDouble(0,name,OBJPROP_PRICE,2,value);return(true);

      case OBJPROP_COLOR:

         ObjectSetInteger(0,name,OBJPROP_COLOR,(int)value);return(true);

      case OBJPROP_STYLE:

         ObjectSetInteger(0,name,OBJPROP_STYLE,(int)value);return(true);

      case OBJPROP_WIDTH:

         ObjectSetInteger(0,name,OBJPROP_WIDTH,(int)value);return(true);

      case OBJPROP_BACK:

         ObjectSetInteger(0,name,OBJPROP_BACK,(int)value);return(true);

      case OBJPROP_RAY:

         ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,(int)value);return(true);

      case OBJPROP_ELLIPSE:

         ObjectSetInteger(0,name,OBJPROP_ELLIPSE,(int)value);return(true);

      case OBJPROP_SCALE:

         ObjectSetDouble(0,name,OBJPROP_SCALE,value);return(true);

      case OBJPROP_ANGLE:

         ObjectSetDouble(0,name,OBJPROP_ANGLE,value);return(true);

      case OBJPROP_ARROWCODE:

         ObjectSetInteger(0,name,OBJPROP_ARROWCODE,(int)value);return(true);

      case OBJPROP_TIMEFRAMES:

         ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,(int)value);return(true);

      case OBJPROP_DEVIATION:

         ObjectSetDouble(0,name,OBJPROP_DEVIATION,value);return(true);

      case OBJPROP_FONTSIZE:

         ObjectSetInteger(0,name,OBJPROP_FONTSIZE,(int)value);return(true);

      case OBJPROP_CORNER:

         ObjectSetInteger(0,name,OBJPROP_CORNER,(int)value);return(true);

      case OBJPROP_XDISTANCE:

         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,(int)value);return(true);

      case OBJPROP_YDISTANCE:

         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,(int)value);return(true);

      case OBJPROP_LEVELS:

         ObjectSetInteger(0,name,OBJPROP_LEVELS,(int)value);return(true);

      case OBJPROP_LEVELCOLOR:

         ObjectSetInteger(0,name,OBJPROP_LEVELCOLOR,(int)value);return(true);

      case OBJPROP_LEVELSTYLE:

         ObjectSetInteger(0,name,OBJPROP_LEVELSTYLE,(int)value);return(true);

      case OBJPROP_LEVELWIDTH:

         ObjectSetInteger(0,name,OBJPROP_LEVELWIDTH,(int)value);return(true);


      default: return(false);

     }

   return(false);

  }

//+------------------------------------------------------------------+  

 

  bool ObjectSetTextMQL4(string name,

                       string text,

                       int font_size,

                       string font="",

                       color text_color=CLR_NONE)

  {

   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);

   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);

   if(StringLen(text)>0 && font_size>0)

     {

      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true

         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)

        {

         if((StringLen(font)>0)

            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)

            return(false);

         if(ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)

            return(false);

         return(true);

        }

      return(false);

     }

   return(false);

  }

//+------------------------------------------------------------------+  

  void SetIndexStyleMQL4(int index,

                       int type,

                       int style=EMPTY,

                       int width=EMPTY,

                       color clr=CLR_NONE)

  {

   if(width>-1)

      PlotIndexSetInteger(index,PLOT_LINE_WIDTH,width);

   if(clr!=CLR_NONE)

      PlotIndexSetInteger(index,PLOT_LINE_COLOR,clr);

   switch(type)

     {

      case 0:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);

      case 1:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_SECTION);

      case 2:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);

      case 3:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ARROW);

      case 4:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ZIGZAG);

      case 12:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_NONE);


      default:

         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);

     }

   switch(style)

     {

      case 0:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_SOLID);

      case 1:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASH);

      case 2:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DOT);

      case 3:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOT);

      case 4:

         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOTDOT);


      default: return;

     }

  }     

//+------------------------------------------------------------------+  

  

 void SetLevelStyleMQL4(int draw_style,

                       int line_width,

                       color clr=CLR_NONE)

  {

   IndicatorSetInteger(INDICATOR_LEVELWIDTH,line_width);

   if(clr!=CLR_NONE)

      IndicatorSetInteger(INDICATOR_LEVELCOLOR,clr);

   switch(draw_style)

     {

      case 0:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_SOLID);

      case 1:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASH);

      case 2:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DOT);

      case 3:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOT);

      case 4:

         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOTDOT);


      default: return;

     }

  } 

 //+------------------------------------------------------------------+  

 

  bool ObjectDeleteMQL4(string name)

  {

   return(ObjectDelete(0,name));

  }

  

//+------------------------------------------------------------------+  

 

double iCloseMQL4(string symbol,int tf,int index)

{

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

   double Arr[];

   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);

   if(CopyClose(symbol,timeframe, index, 1, Arr)>0) 

        return(Arr[0]);

   else 

        return(-1);

}  


//+------------------------------------------------------------------+  

ENUM_TIMEFRAMES TFMigrate(int tf)

  {

   switch(tf)

     {

      case 0: return(PERIOD_CURRENT);

      case 1: return(PERIOD_M1);

      case 5: return(PERIOD_M5);

      case 15: return(PERIOD_M15);

      case 30: return(PERIOD_M30);

      case 60: return(PERIOD_H1);

      case 240: return(PERIOD_H4);

      case 1440: return(PERIOD_D1);

      case 10080: return(PERIOD_W1);

      case 43200: return(PERIOD_MN1);

      

      case 2: return(PERIOD_M2);

      case 3: return(PERIOD_M3);

      case 4: return(PERIOD_M4);      

      case 6: return(PERIOD_M6);

      case 10: return(PERIOD_M10);

      case 12: return(PERIOD_M12);

      case 16385: return(PERIOD_H1);

      case 16386: return(PERIOD_H2);

      case 16387: return(PERIOD_H3);

      case 16388: return(PERIOD_H4);

      case 16390: return(PERIOD_H6);

      case 16392: return(PERIOD_H8);

      case 16396: return(PERIOD_H12);

      case 16408: return(PERIOD_D1);

      case 32769: return(PERIOD_W1);

      case 49153: return(PERIOD_MN1);      

      default: return(PERIOD_CURRENT);

     }

  }

//+-----------------------  CONVERSION  -------------------------------------------+  


Pudiste añadir el código con la opción: "añadir código". Viéndolo así, ni idea. De todas formas, ya casi lo tienes! Un saludo
 
Enrique Enguix Vino:
Pudiste añadir el código con la opción: "añadir código". Viéndolo así, ni idea. De todas formas, ya casi lo tienes! Un saludo

Hola!

                 Deberias antes de nada ir al tutorial de MQL4 to MQL5 y en diferencias del MQL5 vs MQL4, no se de MQL5 pero el encabezimiento de MQL5 es completamente diferente y hay muchas funciones y ordenes que de MQL5 no existen en MQL4 con lo que dificilmente se puede traducir o pasar de uno a otro, si no es imprescindible no te lo aconsejo, muchos Brockers sobre todo los sociales (Darwinex, etc.) para sus servicios sociales no aceptan de momento otra plataformea que no sea MT4, si es por capricho o por que tu cuenta real la has abierto en MT5 te aconsejaria que pasases a MT4 púes a fecha de hoy es mas estable que MT5, solo Metaquotes es quien por intereses propios y desconocidos quiere que nos pasemos a MT5 pero ha fecha de hoy no le he encontrado ventaja alguna.


Por otro lado, ese codigo no esta bien si lo Compilas te da 23 errores co lo que es imposible traducir nada a MT5, cuelga el mq4 sin errores y podremos intentar traducir o pasar lo posible o modificar lo posible a mq5.

Un saludo

Razón de la queja: