MA_kanal





//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 8
#property  indicator_color1  Blue
#property  indicator_color2  Black
#property  indicator_color3  DarkGray
#property  indicator_color4  DarkGray
#property  indicator_color5  DarkGray
#property  indicator_color6  DarkGray
#property  indicator_color7  Black
#property  indicator_color8  Red
//---- indicator parameters
extern int Per=55;
extern int NumBar=1000;
//---- indicator buffers
double     Buf1[], Buf2[],Buf3[], Buf4[],Buf5[], Buf6[],Buf7[],Buf8[],ma1,ma2;
int  j=0, n=0;
string  txt[11];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,2);
//   SetIndexDrawBegin(0,draw_begin);
//   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicator buffers mapping
IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buf1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Buf2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Buf3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Buf4);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,Buf5);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,Buf6);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,Buf7);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,Buf8);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MA");
   SetIndexLabel(0,"MA");
//---- initialization done
   txt[1]  = "U4";
   txt[2]  = "U3";
   txt[3]  = "U2";
   txt[4]  = "U1";
   txt[5]  = "D1";
   txt[6]  = "D2";
   txt[7]  = "D3";
   txt[8]  = "D4";
   txt[9]  = "LB";

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() 
{
   ObjectDelete("g1");
   ObjectDelete("g2");
   ObjectDelete("g3");
   ObjectDelete("g4");
   ObjectDelete("g5");
   ObjectDelete("g6");
   ObjectDelete("g7");
   ObjectDelete("g8");
   ObjectDelete("g9");
   
   ObjectDelete("t1");
   ObjectDelete("t2");
   ObjectDelete("t3");
   ObjectDelete("t4");
   ObjectDelete("t5");
   ObjectDelete("t6");
   ObjectDelete("t7");
   ObjectDelete("t8");
   ObjectDelete("t9");

   return(0);
}
//+------------------------------------------------------------------+
int start()
{
  int i;
   if (Minute()<=1)
  {
     ObjectDelete("g1");
   ObjectDelete("g2");
   ObjectDelete("g3");
   ObjectDelete("g4");
   ObjectDelete("g5");
   ObjectDelete("g6");
   ObjectDelete("g7");
   ObjectDelete("g8");
   ObjectDelete("g9");
   
   ObjectDelete("t1");
   ObjectDelete("t2");
   ObjectDelete("t3");
   ObjectDelete("t4");
   ObjectDelete("t5");
   ObjectDelete("t6");
   ObjectDelete("t7");
   ObjectDelete("t8");
   ObjectDelete("t9");
  }
  for (i=0;i<NumBar;i++)
  {
    Buf1[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,1.38,MODE_UPPER,i);
    Buf2[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,1,MODE_UPPER,i);
    Buf3[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,0.62,MODE_UPPER,i);
    Buf4[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,0.38,MODE_UPPER,i);
    Buf5[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,0.38,MODE_LOWER,i);
    Buf6[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,0.62,MODE_LOWER,i);
    Buf7[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,1,MODE_LOWER,i);
    Buf8[i]=iEnvelopes(NULL, 0, Per,MODE_SMA,0,PRICE_CLOSE,1.38,MODE_LOWER,i);
  }
   if(ObjectFind("g1") == -1) 
   {
           ObjectCreate("g1", OBJ_TREND, 0, Time[0], Buf1[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf1[0]+(Buf1[0]-Buf1[2])*(20-TimeHour(Time[0])));
           ObjectSet("g1", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g1", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g1", OBJPROP_COLOR, DarkGray);
           ObjectMove("g1", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf1[0]+(Buf1[0]-Buf1[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g2") == -1) 
   {
           ObjectCreate("g2", OBJ_TREND, 0, Time[0], Buf2[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf2[0]+(Buf2[0]-Buf2[2])*(20-TimeHour(Time[0])));
           ObjectSet("g2", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g2", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g2", OBJPROP_WIDTH, 2);
           ObjectSet("g2", OBJPROP_COLOR, Black);
           ObjectMove("g2", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf2[0]+(Buf2[0]-Buf2[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g3") == -1) 
   {
           ObjectCreate("g3", OBJ_TREND, 0, Time[0], Buf3[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf3[0]+(Buf3[0]-Buf3[2])*(20-TimeHour(Time[0])));
           ObjectSet("g3", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g3", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g3", OBJPROP_COLOR, DarkGray);
           ObjectMove("g3", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf3[0]+(Buf3[0]-Buf3[2])*(20-TimeHour(Time[0])));
   }
   
   if(ObjectFind("g4") == -1) 
   {
           ObjectCreate("g4", OBJ_TREND, 0, Time[0], Buf4[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf4[0]+(Buf4[0]-Buf4[2])*(20-TimeHour(Time[0])));
           ObjectSet("g4", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g4", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g4", OBJPROP_COLOR, DarkGray);
           ObjectMove("g4", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf4[0]+(Buf4[0]-Buf4[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g5") == -1) 
   {
           ObjectCreate("g5", OBJ_TREND, 0, Time[0], Buf5[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf5[0]+(Buf5[0]-Buf5[2])*(20-TimeHour(Time[0])));
           ObjectSet("g5", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g5", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g5", OBJPROP_COLOR, DarkGray);
           ObjectMove("g5", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf5[0]+(Buf5[0]-Buf5[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g6") == -1) 
   {
           ObjectCreate("g6", OBJ_TREND, 0, Time[0], Buf6[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf6[0]+(Buf6[0]-Buf6[2])*(20-TimeHour(Time[0])));
           ObjectSet("g6", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g6", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g6", OBJPROP_COLOR, DarkGray);
           ObjectMove("g6", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf6[0]+(Buf6[0]-Buf6[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g7") == -1) 
   {
           ObjectCreate("g7", OBJ_TREND, 0, Time[0], Buf7[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf7[0]+(Buf7[0]-Buf7[2])*(20-TimeHour(Time[0])));
           ObjectSet("g7", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g7", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g7", OBJPROP_WIDTH, 2);
           ObjectSet("g7", OBJPROP_COLOR, Black);
           ObjectMove("g7", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf7[0]+(Buf7[0]-Buf7[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g8") == -1) 
   {
           ObjectCreate("g8", OBJ_TREND, 0, Time[0], Buf8[0],Time[0]+(24-TimeHour(Time[0]))*3600, Buf8[0]+(Buf8[0]-Buf8[2])*(20-TimeHour(Time[0])));
           ObjectSet("g8", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g8", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g8", OBJPROP_COLOR, DarkGray);
           ObjectMove("g8", 1, Time[0]+(24-TimeHour(Time[0]))*3600,Buf8[0]+(Buf8[0]-Buf8[2])*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("g9") == -1) 
   {
      ma1=iMA(NULL,0,55,0,MODE_SMA,PRICE_CLOSE,0);
      ma2=iMA(NULL,0,55,0,MODE_SMA,PRICE_CLOSE,2);
           ObjectCreate("g9", OBJ_TREND, 0, Time[0], ma1,Time[0]+(24-TimeHour(Time[0]))*3600, ma1+(ma1-ma2)*(20-TimeHour(Time[0])));
           ObjectSet("g9", OBJPROP_RAY, DRAW_LINE);
           ObjectSet("g9", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("g9", OBJPROP_WIDTH, 2);
           ObjectSet("g9", OBJPROP_COLOR, Teal);
           ObjectMove("g9", 1, Time[0]+(24-TimeHour(Time[0]))*3600,ma1+(ma1-ma2)*(20-TimeHour(Time[0])));
   }
   if(ObjectFind("t1") == -1) 
   {
           ObjectCreate("t1", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf1[0]+(Buf1[0]-Buf1[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t1", txt[1], 8, "Arial", Black);
           ObjectMove("t1", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf1[0]+(Buf1[0]-Buf1[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t2") == -1) 
   {
           ObjectCreate("t2", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf2[0]+(Buf2[0]-Buf2[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t2", txt[2], 8, "Arial", Black);
           ObjectMove("t2", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf2[0]+(Buf2[0]-Buf2[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t3") == -1) 
   {
           ObjectCreate("t3", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf3[0]+(Buf3[0]-Buf3[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t3", txt[3], 8, "Arial", Black);
           ObjectMove("t3", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf3[0]+(Buf3[0]-Buf3[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t4") == -1) 
   {
           ObjectCreate("t4", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf4[0]+(Buf4[0]-Buf4[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t4", txt[4], 8, "Arial", Black);
           ObjectMove("t4", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf4[0]+(Buf4[0]-Buf4[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t5") == -1) 
   {
           ObjectCreate("t5", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf5[0]+(Buf5[0]-Buf5[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t5", txt[5], 8, "Arial", Black);
           ObjectMove("t5", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf5[0]+(Buf5[0]-Buf5[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t6") == -1) 
   {
           ObjectCreate("t6", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf6[0]+(Buf6[0]-Buf6[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t6", txt[6], 8, "Arial", Black);
           ObjectMove("t6", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf6[0]+(Buf6[0]-Buf6[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t7") == -1) 
   {
           ObjectCreate("t7", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf7[0]+(Buf7[0]-Buf7[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t7", txt[7], 8, "Arial", Black);
           ObjectMove("t7", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf7[0]+(Buf7[0]-Buf7[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t8") == -1) 
   {
           ObjectCreate("t8", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, Buf8[0]+(Buf8[0]-Buf8[2])*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t8", txt[8], 8, "Arial", Black);
           ObjectMove("t8", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  Buf8[0]+(Buf8[0]-Buf8[2])*(20-TimeHour(Time[0]))+7*Point);
   }
   if(ObjectFind("t9") == -1) 
   {
            ma1=iMA(NULL,0,55,0,MODE_SMA,PRICE_CLOSE,0);
            ma2=iMA(NULL,0,55,0,MODE_SMA,PRICE_CLOSE,2);
           ObjectCreate("t9", OBJ_TEXT, 0, Time[0]+(27-TimeHour(Time[0]))*3600, ma1+(ma1-ma2)*(20-TimeHour(Time[0]))+7*Point);
           ObjectSetText("t9", txt[9], 8, "Arial", Black);
           ObjectMove("t9", 0, Time[0]+(27-TimeHour(Time[0]))*3600,  ma1+(ma1-ma2)*(20-TimeHour(Time[0]))+7*Point);
   }

}






Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Envelopes indicator
Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: