Download MetaTrader 5

arrows not visible in data window !

To add comments, please log in or register
Dimitar Pavlov
1192
Dimitar Pavlov  
Hi this indicator has arrows but they are not visible in data window can anyone help me to be added as buffers so they can be visible in data window ? Thanks :) 
Dimitar Pavlov
1192
Dimitar Pavlov  
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 6
#property  indicator_color1  Green
#property  indicator_color2  Red
#property  indicator_color3  Silver

#property  indicator_width1  3
#property  indicator_width2  3
//---- indicator parameters
extern int FastEMA=5;
extern int SlowEMA=13;
extern int SignalSMA=1;
extern int Arrow_Gap = 3;
extern bool Audible_Alerts = true;
extern bool Push_Notifications = false;
//---- indicator buffers
double     MacdBuffer[],   MacdBufferUp[],   MacdBufferDown[];
double     SignalBuffer[];
double myPoint; //initialized in OnInit
datetime time_alert; //used when sending alert

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   DeleteArrows();
//---- drawing settings
  IndicatorBuffers(4);
   
   SetIndexBuffer (0,MacdBufferUp);
   SetIndexStyle  (0,DRAW_HISTOGRAM);
   SetIndexBuffer (1,MacdBufferDown); 
   SetIndexStyle  (1,DRAW_HISTOGRAM);
   SetIndexBuffer (2,SignalBuffer);
   SetIndexStyle  (2,DRAW_LINE);
   SetIndexDrawBegin(2,SignalSMA);
   SetIndexBuffer (3,MacdBuffer);
   SetIndexStyle  (3,DRAW_NONE);   
   
   SetIndexLabel  (0,"Buffer 0");
   SetIndexLabel  (1,"Buffer 1");
   SetIndexLabel  (2,"Signal");
   IndicatorDigits(Digits+3);
   IndicatorShortName("MACD_color("+FastEMA+","+SlowEMA+","+SignalSMA+")");
      myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
         {
         MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
         }
   for(i = limit-1; i >= 0; i--)
   {
      MacdBufferDown[i]=0.0; MacdBufferUp[i]=0.0;
     
         if(i>=1) //это зарет на изображение нулевого бара //break the null bar  
            {
               if(MacdBuffer[i+1]-MacdBuffer[i]>=0)MacdBufferDown[i]=MacdBuffer[i]; //условия раскраси //condition of color
                  else MacdBufferUp[i]=MacdBuffer[i];}
                  
    //Test 3 Bar rule
    int ia=0;
    int ix;
    int iGreen=0;
    if(MacdBufferDown[i+1]!=0 && MacdBufferDown[i+2]!=0 && MacdBufferDown[i+3]!=0 && MacdBufferDown[i+4]==0)
    {
       for(ix=5;ix<50;ix++){
         if(MacdBufferDown[i+ix]!=iGreen)break;
       }
     
       if(ix>=7)
       {ia=0;
        for(ix=ix;ix<50;ix++){
         if(MacdBufferDown[i+ix]==iGreen)break;
         ia++;
         }
       
       if(ia>=3)
       {

         if(ObjectFind("ArrowSell"+i)==0)ObjectDelete("ArrowSell"+i);
         ObjectCreate(0, "ArrowSell"+i,OBJ_ARROW_DOWN, 0, iTime(NULL,0,i), High[i] + (Arrow_Gap * myPoint));//Draw Arrow Down
         ObjectSet("ArrowSell"+i, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("ArrowSell"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
         ObjectSet("ArrowSell"+i, OBJPROP_COLOR,Red);
         if(i == 0 && Time[0] != time_alert)myAlert("Sell Alert " + i);
         time_alert = Time[0]; 
      }
      }
      }
    
    
    if(MacdBufferDown[i+1]==iGreen && MacdBufferDown[i+2]==iGreen && MacdBufferDown[i+3]==iGreen && MacdBufferDown[i+4]!=iGreen)
    {
       for(ix=5;ix<50;ix++){
         if(MacdBufferDown[i+ix]==iGreen)break;
       }
     
       if(ix>=7)
       {ia=0;
        for(ix=ix;ix<50;ix++){
         
         if(MacdBufferDown[i+ix]!=iGreen)break;
         ia++;
         }
       
       if(ia>=3)
       {      
        // Print(ia + " " + TimeToStr(iTime(NULL,0,i)));
         ObjectCreate(0, "ArrowBuy"+i,OBJ_ARROW_UP, 0, iTime(NULL,0,i), Low[i] - Arrow_Gap * myPoint);//Draw Arrow Up       
         ObjectSet("ArrowBuy"+i, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("ArrowBuy"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
         ObjectSet("ArrowBuy"+i, OBJPROP_COLOR,Green);
         if(i == 0 && Time[0] != time_alert)myAlert("Buy Alert "+i);
         time_alert = Time[0]; 
      }
        }     
            
   }
   }
   for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
   return(0);
  }
//+------------------------------------------------------------------+

void DeleteArrows()
{
  for (int i = ObjectsTotal() - 1; i > -1; i--)
  if (StringFind(ObjectName(i),"Arrow" ) >= 0) ObjectDelete(ObjectName(i));
}

void OnDeinit(const int reason)
{
   DeleteArrows();
}

void myAlert( string message)
  {

      if(Audible_Alerts) Alert("MACD Color Signal @ "+Symbol()+","+Period()+" | "+message);
      if(Push_Notifications) SendNotification("MACD Color Signal @ "+Symbol()+","+Period()+" | "+message);

  }
Kaleem Haider
84594
Kaleem Haider  
Dimitar Pavlov:
Arrow are drawn as an Object not as a buffer.  you need to create buffers to store arrows, and plot those buffers.
Dimitar Pavlov
1192
Dimitar Pavlov  
yes but i dont know how :( 
Ernst Van Der Merwe
4800
Ernst Van Der Merwe  
#property  indicator_separate_window
#property  indicator_buffers 5
#property  indicator_color1  Green
#property  indicator_color2  Red
#property  indicator_color3  Silver

#property  indicator_width1  3
#property  indicator_width2  3
//---- indicator parameters
extern int FastEMA=5;
extern int SlowEMA=13;
extern int SignalSMA=1;
extern int Arrow_Gap = 3;
extern bool Audible_Alerts = true;
extern bool Push_Notifications = false;
//---- indicator buffers
double     MacdBuffer[],   MacdBufferUp[],   MacdBufferDown[];
double     SignalBuffer[];
double     BuyBuffer[],SellBuffer[];
double myPoint; //initialized in OnInit
datetime time_alert; //used when sending alert

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   DeleteArrows();
//---- drawing settings
   IndicatorBuffers(6);

   SetIndexBuffer (0,MacdBufferUp);
   SetIndexStyle  (0,DRAW_HISTOGRAM);
   SetIndexEmptyValue(0,0.0);
   SetIndexBuffer (1,MacdBufferDown); 
   SetIndexStyle  (1,DRAW_HISTOGRAM);
   SetIndexEmptyValue(1,0.0);
   SetIndexBuffer (2,SignalBuffer);
   SetIndexStyle  (2,DRAW_LINE);
   SetIndexDrawBegin(2,SignalSMA);
   SetIndexBuffer (3,BuyBuffer);
   SetIndexStyle  (3,DRAW_NONE);   
   SetIndexEmptyValue(3,0.0);
   SetIndexBuffer (4,SellBuffer);
   SetIndexStyle  (4,DRAW_NONE);   
   SetIndexEmptyValue(4,0.0);
   SetIndexBuffer (5,MacdBuffer);
   SetIndexStyle  (5,DRAW_NONE);   
   
   SetIndexLabel  (0,"Bull Buffer");
   SetIndexLabel  (1,"Bear Buffer");
   SetIndexLabel  (2,"Signal");
   SetIndexLabel  (3,"Buy");
   SetIndexLabel  (4,"Sell");
   
       if(ia>=3)
       {
         double high=High[i] + (Arrow_Gap * myPoint);
         SellBuffer[i]=high;
         if(ObjectFind("ArrowSell"+i)==0)ObjectDelete("ArrowSell"+i);
         ObjectCreate(0, "ArrowSell"+i,OBJ_ARROW_DOWN, 0, iTime(NULL,0,i), high );//Draw Arrow Down
         ObjectSet("ArrowSell"+i, OBJPROP_STYLE, STYLE_SOLID);
Dimitar Pavlov
1192
Dimitar Pavlov  
Hi Ernst , can you make the whole code ? im not so good in coding , thanks 
Ernst Van Der Merwe
4800
Ernst Van Der Merwe  
Dimitar Pavlov:
Hi Ernst , can you make the whole code ? im not so good in coding , thanks 
Files:
Dimitar Pavlov
1192
Dimitar Pavlov  
Thanks :)
To add comments, please log in or register