Подскажите что нужно добавить для объединения двух индикаторов

 

Попытался объединить два одинаковых индикатора с разными параметрами в один. До конца не получилось. В программировании 0. Индикатор сторонний. Подскажите пожалуйста что и где нужно добавить еще?

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

//|                                                         #MTF.mq4 |

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

#property indicator_chart_window

#property indicator_buffers 8

#property indicator_color1 Lime

#property indicator_color2 Blue

#property indicator_color3 Red

#property indicator_color4 Yellow

//---- input parameters

/***********************************

PERIOD_M1   1

PERIOD_M5   5

PERIOD_M15  15

PERIOD_M30  30 

PERIOD_H1   60

PERIOD_H4   240

PERIOD_D1   1440

PERIOD_W1   10080

PERIOD_MN1  43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE    0 Close price. 

PRICE_OPEN     1 Open price. 

PRICE_HIGH     2 High price. 

PRICE_LOW      3 Low price. 

PRICE_MEDIAN   4 Median price, (high+low)/2. 

PRICE_TYPICAL  5 Typical price, (high+low+close)/3. 

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

********************************************************/

extern int TimeFrame=0;

extern int TimeFrame1=60;

double TrendUp[];

double TrendDown[];

double TrendUp1[];

double TrendDown1[];

int st = 0;

//extern int SlowerEMA = 6;


double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];


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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators


   SetIndexStyle(0, DRAW_LINE, 0,1);

   SetIndexBuffer(0, ExtMapBuffer1);

   SetIndexStyle(1, DRAW_LINE, 0,1);

   SetIndexBuffer(1, ExtMapBuffer2);

   SetIndexStyle(2, DRAW_LINE, 0,1);

   SetIndexBuffer(2, ExtMapBuffer3);

   SetIndexStyle(3, DRAW_LINE, 0,1);

   SetIndexBuffer(3, ExtMapBuffer4);

   /*SetIndexStyle(0, DRAW_ARROW, EMPTY);

   SetIndexArrow(0, 159);

   SetIndexBuffer(0, TrendUp);

   SetIndexStyle(1, DRAW_ARROW, EMPTY);

   SetIndexArrow(1, 159);

   SetIndexBuffer(1, TrendDown);*/

   /*for(int i = 0; i < Bars; i++) {

      TrendUp[i] = NULL;

      TrendDown[i] = NULL;

   }*/

   //---- name for DataWindow and indicator subwindow label   

   switch(TimeFrame)

   {

      case 1 : string TimeFrameStr="Period_M1"; break;

      case 5 : TimeFrameStr="Period_M5"; break;

      case 15 : TimeFrameStr="Period_M15"; break;

      case 30 : TimeFrameStr="Period_M30"; break;

      case 60 : TimeFrameStr="Period_H1"; break;

      case 240 : TimeFrameStr="Period_H4"; break;

      case 1440 : TimeFrameStr="Period_D1"; break;

      case 10080 : TimeFrameStr="Period_W1"; break;

      case 43200 : TimeFrameStr="Period_MN1"; break;

      default : TimeFrameStr="Current Timeframe";

        

   }

   IndicatorShortName("Supertrend("+st+") ("+TimeFrameStr+")");

   

   IndicatorShortName("Supertrend1("+st+") ("+TimeFrameStr+")");


return(0);


  }

   

  

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//---- 

   /*for(int i = 0; i < Bars; i++) {

      TrendUp[i] = NULL;

      TrendDown[i] = NULL;

   }*/

//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

   datetime TimeArray[];

   int    i,shift,limit,y=0,counted_bars=IndicatorCounted();

    

    datetime TimeArray1[];

   int    i1,shift1,limit1,y1=0,counted_bars1=IndicatorCounted();

   

// Plot defined timeframe on to current timeframe   

   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

   

   ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame1);

   

   limit=Bars-counted_bars;

   for(i=0,y=0;i<limit;i++)

   

   limit1=Bars-counted_bars1;

   for(i1=0,y1=0;i1<limit1;i1++)

   

   {

   if (Time[i]<TimeArray[y]) y++; 

   

   if (Time[i1]<TimeArray1[y1]) y1++;

   

 /***********************************************************   

   Add your main indicator loop below.  You can reference an existing

      indicator with its iName  or iCustom.

   Rule 1:  Add extern inputs above for all neccesary values   

   Rule 2:  Use 'TimeFrame' for the indicator timeframe

   Rule 3:  Use 'y' for the indicator's shift value

 **********************************************************/  

 

 ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"Supertrend",0,y);

 ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"Supertrend",1,y);

 

 ExtMapBuffer3[i1]=iCustom(NULL,TimeFrame1,"Supertrend",2,y1);

 ExtMapBuffer4[i1]=iCustom(NULL,TimeFrame1,"Supertrend",3,y1);

  } 

//----

   return(0);

  }

 

================================================================

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

//|                                                         #MTF.mq4 |

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

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 Lime

#property indicator_color2 Blue

#property indicator_color3 Red

#property indicator_color4 Yellow

//---- input parameters

/*************************************************************************

PERIOD_M1   1

PERIOD_M5   5

PERIOD_M15  15

PERIOD_M30  30 

PERIOD_H1   60

PERIOD_H4   240

PERIOD_D1   1440

PERIOD_W1   10080

PERIOD_MN1  43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE    0 Close price. 

PRICE_OPEN     1 Open price. 

PRICE_HIGH     2 High price. 

PRICE_LOW      3 Low price. 

PRICE_MEDIAN   4 Median price, (high+low)/2. 

PRICE_TYPICAL  5 Typical price, (high+low+close)/3. 

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 


PERIOD1_M1   1

PERIOD1_M5   5

PERIOD1_M15  15

PERIOD1_M30  30 

PERIOD1_H1   60

PERIOD1_H4   240

PERIOD1_D1   1440

PERIOD1_W1   10080

PERIOD1_MN1  43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE1    0 Close price1. 

PRICE_OPEN1     1 Open price1. 

PRICE_HIGH1     2 High price1. 

PRICE_LOW1      3 Low price1. 

PRICE_MEDIAN1   4 Median price1, (high1+low1)/2. 

PRICE_TYPICAL1  5 Typical price1, (high1+low1+close1)/3. 

PRICE_WEIGHTED1 6 Weighted close price1, (high1+low1+close1+close1)/4. 

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/


extern int TimeFrame=0;

extern int TimeFrame1=60;

double TrendUp[];

double TrendDown[];

double TrendUp1[];

double TrendDown1[];

int st = 0;

//extern int SlowerEMA = 6;


double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];


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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators


   SetIndexStyle(0, DRAW_LINE, 0,1);

   SetIndexBuffer(0, ExtMapBuffer1);

   SetIndexStyle(1, DRAW_LINE, 0,1);

   SetIndexBuffer(1, ExtMapBuffer2);

   SetIndexStyle(2, DRAW_LINE, 0,1);

   SetIndexBuffer(2, ExtMapBuffer3);

   SetIndexStyle(3, DRAW_LINE, 0,1);

   SetIndexBuffer(3, ExtMapBuffer4);

   /*SetIndexStyle(0, DRAW_ARROW, EMPTY);

   SetIndexArrow(0, 159);

   SetIndexBuffer(0, TrendUp);

   SetIndexStyle(1, DRAW_ARROW, EMPTY);

   SetIndexArrow(1, 159);

   SetIndexBuffer(1, TrendDown);*/

   /*for(int i = 0; i < Bars; i++) {

      TrendUp[i] = NULL;

      TrendDown[i] = NULL;

      

   SetIndexStyle1(0, DRAW_ARROW1, EMPTY1);

   SetIndexArrow1(0, 159);

   SetIndexBuffer1(0, TrendUp1);

   SetIndexStyle1(1, DRAW_ARROW1, EMPTY1);

   SetIndexArrow(1, 159);

   SetIndexBuffer1(1, TrendDown1);*/

   /*for(int i1 = 0; i1 < Bars; i1++) {

      TrendUp1[i1] = NULL;

      TrendDown1[i1] = NULL;

   }*/

   //---- name for DataWindow and indicator subwindow label   

   switch(TimeFrame)

   {

      case 1 : string TimeFrameStr="Period_M1"; break;

      case 5 : TimeFrameStr="Period_M5"; break;

      case 15 : TimeFrameStr="Period_M15"; break;

      case 30 : TimeFrameStr="Period_M30"; break;

      case 60 : TimeFrameStr="Period_H1"; break;

      case 240 : TimeFrameStr="Period_H4"; break;

      case 1440 : TimeFrameStr="Period_D1"; break;

      case 10080 : TimeFrameStr="Period_W1"; break;

      case 43200 : TimeFrameStr="Period_MN1"; break;

      default : TimeFrameStr="Current Timeframe";

      }

      switch(TimeFrame1)

      {

      case 1 : string TimeFrameStr1="Period_M1"; break;

      case 5 : TimeFrameStr1="Period_M5"; break;

      case 15 : TimeFrameStr1="Period_M15"; break;

      case 30 : TimeFrameStr1="Period_M30"; break;

      case 60 : TimeFrameStr1="Period_H1"; break;

      case 240 : TimeFrameStr1="Period_H4"; break;

      case 1440 : TimeFrameStr1="Period_D1"; break;

      case 10080 : TimeFrameStr1="Period_W1"; break;

      case 43200 : TimeFrameStr1="Period_MN1"; break;

      default : TimeFrameStr1="Current Timeframe";

    }

   IndicatorShortName("MTF("+st+") ("+TimeFrameStr+")");

   IndicatorShortName("MTF("+st+") ("+TimeFrameStr1+")");

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

   /*for(int i = 0; i < Bars; i++) {

      TrendUp[i] = NULL;

      TrendDown[i] = NULL;

      for(int i1 = 0; i1 < Bars; i1++) {

      TrendUp1[i1] = NULL;

      TrendDown1[i1] = NULL;

   }*/

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

   datetime TimeArray[];

   int    i,limit,y=0,counted_bars=IndicatorCounted();

   datetime TimeArray1[];

   int    i1,limit1,y1=0,counted_bars1=IndicatorCounted();

// Plot defined timeframe on to current timeframe   

 

   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

   ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame1);

   limit=Bars-counted_bars;

   for(i=0,y=0;i<limit;i++)

   limit1=Bars-counted_bars1;

   for(i1=0,y1=0;i1<limit1;i1++)

   {

   if (Time[i]<TimeArray[y]) y++; 

   if (Time[i1]<TimeArray1[y1]) y1++;

   

 /-------------------------------------------------------

   Add your main indicator loop below.  You can reference an existing

      indicator with its iName  or iCustom.

   Rule 1:  Add extern inputs above for all neccesary values   

   Rule 2:  Use 'TimeFrame' for the indicator timeframe

   Rule 3:  Use 'y' for the indicator's shift value

/--------------------------------------------- 

 ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"MTF",0,y);

 ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"MTF",1,y);

 ExtMapBuffer3[i1]=iCustom(NULL,TimeFrame1,"MTF",2,y1);

 ExtMapBuffer4[i1]=iCustom(NULL,TimeFrame1,"MTF",3,y1);

  } 

   return(0);

  }

======================================================================

 
Для вставки кода необходимо пользоваться кнопкой SRC, расположенной перед видео!
Причина обращения: