Need Help in calling index buffer values of Arrows Drawn on Main Chart in EA

 

Hi


I need to call the up arrow and down arrow, in this indicator, can someone help me please

Thanks in advance

//+------------------------------------------------------------------+
//|                                            !!!_2019_C_Blocks.mq4 |
//|                                             Copyright 2019, M.G" |
//|                                      Prophetfxpro@protonmail.com |
//+------------------------------------------------------------------+

#property copyright "Copyright 2019, M.G."

#property link      "Prophetfxpro@protonmail.com"


#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 clrMaroon
#property indicator_color2 clrDarkGreen

#property indicator_color3 clrLime 
#property indicator_color4 clrRed 
#property indicator_color5 clrYellow


#property indicator_width1 2
#property indicator_width2 2


#property indicator_width3 2
#property indicator_width4 2

#property indicator_width5 2
#property indicator_style1 2
#property indicator_style2 2


#property indicator_level1 0
#property indicator_level2 200
#property indicator_level3 -200
#property indicator_level2 100
#property indicator_level3 -100
#property indicator_level2 92
#property indicator_level3 -92

#property indicator_levelstyle 0
#property indicator_levelwidth 1
#property indicator_levelcolor clrOrange
//---- input parameters

extern string Note_1="Setup Periods";
extern int Slow_Period=6;

extern string Note_2="Block Height. Larger for Big TFs";
extern int Block_Height_Value=75;



extern string Note_4="Alert Options";
extern bool Alerts_On=false;
extern double Alert_Level=0;
extern color ArrowColor=Magenta;

extern bool see_chart_signal=true;
extern int sig_shift=0;
extern string Note_5 = "Trends, use Neg short Pos long";
extern string Note_5a = "Range, use Pos short Neg long";
extern double chart_short_level = 0.92; 
extern double chart_long_level = -0.92; 
extern int short_arrow= 234;
extern int long_arrow = 233;
extern color shortclr = clrRed;
extern color longclr=clrDodgerBlue;
extern bool see_sig_verts=true;
extern int vert_style=2;

int Bar_Limiter=0;

//---- indicator buffers
double LongBuff[];
double ShortBuff[];
double FillLongBuff[];
double FillShortBuff[];
double ChartFillColor[];


bool higher=false;
bool lower=false;
double Points;
int i,idx;
double TheHigh,TheLow,BBlock,BBlock_In_Points,BBlockUp,BBlockDn;
string display_name;
int Bars2Use;
string alerttxt="";
string alertname="Cal";
int win_idx;
double fillUp[];
double fillDN[];
string Salerttxt="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator draw

   IndicatorBuffers(7);
   SetIndexBuffer(0,fillUp);SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,fillDN);SetIndexStyle(1,DRAW_HISTOGRAM);

   SetIndexBuffer(2,FillLongBuff);SetIndexStyle(2,DRAW_HISTOGRAM);SetIndexEmptyValue(2,0);SetIndexDrawBegin(2,Bar_Limiter);
   SetIndexBuffer(3,FillShortBuff);SetIndexStyle(3,DRAW_HISTOGRAM);SetIndexEmptyValue(3,0);SetIndexDrawBegin(3,Bar_Limiter);
   SetIndexBuffer(4,ChartFillColor);SetIndexStyle(4,DRAW_HISTOGRAM);SetIndexEmptyValue(4,0);SetIndexDrawBegin(4,Bar_Limiter);

   SetIndexBuffer(5,LongBuff);
   SetIndexBuffer(6,ShortBuff);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));


   display_name="C_Blocks: "+DoubleToStr(Block_Height_Value,0)+" Size Block";

   IndicatorShortName(display_name);

   SetIndexLabel(0,"C_Blocks: "+DoubleToStr(Block_Height_Value,0)+" Size Block");
   SetIndexLabel(1,"C_Blocks: "+DoubleToStr(Block_Height_Value,0)+" Size Block");
//----
   SetIndexDrawBegin(0,Block_Height_Value);
   SetIndexDrawBegin(1,Block_Height_Value);
//----

   return(0);
  }
//--------de-initialize
int deinit()
  {

   ObjectDelete(alertname);
   for(int ai=ObjectsTotal()-1; ai>=0; ai--)
     {
      string label=ObjectName(ai);
      if(StringSubstr(label, 0, 4) == "ctop" )ObjectDelete(label);
      if(StringSubstr(label, 0, 4) == "cbot" )ObjectDelete(label);

     }

   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+   

int start()
  {



   Points=1;

   if(Bars>Bar_Limiter && Bar_Limiter>0)Bars2Use=Bar_Limiter; else
   Bars2Use=Bars;

   if(NewBar2())
     {
      for(idx=Bars2Use-1-Block_Height_Value;idx>=0;idx--)
        {

         BBlock_In_Points=Block_Height_Value*Points;

         //if (idx==Bars-1-Block_Height_Value)
         if(idx==Bars2Use-1-Block_Height_Value)
           {
            TheHigh=iCCI(NULL,0,Slow_Period,PRICE_HIGH,idx);
            TheLow=iCCI(NULL,0,Slow_Period,PRICE_LOW,idx);
            BBlock=(iCCI(NULL,0,Slow_Period,PRICE_HIGH,idx)-iCCI(NULL,0,Slow_Period,PRICE_LOW,idx));
           }

         //if (idx<Bars-1-Block_Height_Value)  
         if(idx<Bars2Use-1-Block_Height_Value)
           {
            if(iCCI(NULL,0,Slow_Period,PRICE_CLOSE,idx)>=TheHigh+BBlock)
              {
               if(BBlock==0)
                  BBlockUp=0;
               else BBlockUp=MathRound((iCCI(NULL,0,Slow_Period,PRICE_CLOSE,idx)-TheHigh)/BBlock)*BBlock;

               TheHigh= TheHigh+BBlockUp;
               BBlock = BBlock_In_Points;
               TheLow = TheHigh - BBlock;
               BBlockDn=0;
              }

            if(iCCI(NULL,0,Slow_Period,PRICE_CLOSE,idx)<=TheLow-BBlock)
              {
               if(BBlock==0)
                  BBlockDn=0;
               else BBlockDn=MathRound((TheLow-iCCI(NULL,0,Slow_Period,PRICE_CLOSE,idx))/BBlock)*BBlock;

               TheLow = TheLow - BBlockDn;
               BBlock = BBlock_In_Points;
               TheHigh= TheLow+BBlock;
               BBlockUp=0;
              }
           }

         fillUp[idx]=100;
         fillDN[idx]=-100;


         LongBuff[idx]=TheHigh/Points;
         ShortBuff[idx]=TheLow/Points;

         if(LongBuff[idx]>LongBuff[idx+1]&& LongBuff[idx]>0){higher=true;lower=false;}
         if(LongBuff[idx]>LongBuff[idx+1]&& LongBuff[idx]<0){higher=false;lower=true;}

         if(ShortBuff[idx]<ShortBuff[idx+1]&&  ShortBuff[idx]>0){higher=false;lower=true;}
         if(ShortBuff[idx]<ShortBuff[idx+1]&&  ShortBuff[idx]<0){higher=true;lower=false;}
         //--------------------------------     
         FillLongBuff[idx]=0;
         FillShortBuff[idx]=0;

         ChartFillColor[idx]=0;

         if(higher==true){FillLongBuff[idx]=LongBuff[idx];FillShortBuff[idx]=ShortBuff[idx+1];}
         if(lower==true){FillShortBuff[idx]=LongBuff[idx+1];FillLongBuff[idx]=ShortBuff[idx];}

         if(MathMin(FillLongBuff[idx],FillShortBuff[idx])>0)ChartFillColor[idx]=MathMin(FillLongBuff[idx],FillShortBuff[idx]);
         if(MathMin(FillLongBuff[idx],FillShortBuff[idx])<0)ChartFillColor[idx]=MathMax(FillLongBuff[idx],FillShortBuff[idx]);


         alerttxt="C_Blocks "+Symbol()+" Tf "+Period()+" Level Hit @ "+DoubleToStr(Alert_Level,1)+" "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
         win_idx=WindowFind(display_name); //
         if(!Alerts_On && ObjectFind(alertname)==win_idx)
           {
            ObjectDelete(alertname);
           }

        }
      //---------------------------
      for(idx=0;idx<Bars2Use-1-Block_Height_Value;idx++)
        {

         if(see_chart_signal)
           {
            //--short

            if(ChartFillColor[idx+1]<chart_short_level && ChartFillColor[idx+2]>=chart_short_level)
              {

               Salerttxt="C_Blocks "+Symbol()+" Tf "+Period()+" Level Hit @ "+DoubleToStr(chart_short_level,1)+" "+TimeToStr(iTime(NULL,0,idx+1),TIME_DATE|TIME_SECONDS);
               if(Alerts_On)if(NewBarShort()) { Alert(Salerttxt+" Short Direction");}
               string objPeak="ctop"+TimeToStr(iTime(NULL,0,idx+1+sig_shift),TIME_DATE|TIME_MINUTES);
               ObjectCreate(objPeak,OBJ_ARROW,0,iTime(NULL,0,idx+1+sig_shift),iHigh(NULL,0,idx+1));
               ObjectSet(objPeak,OBJPROP_COLOR,shortclr);
               ObjectSet(objPeak,OBJPROP_ARROWCODE,short_arrow);
               ObjectSet(objPeak,OBJPROP_WIDTH,1);
               ObjectSet(objPeak,OBJPROP_BACK,true);
               ObjectSet(objPeak,OBJPROP_ANCHOR,ANCHOR_BOTTOM);

               if(see_sig_verts)
                 {
                  string objPeakv="ctopv"+TimeToStr(iTime(NULL,0,idx+1+sig_shift),TIME_DATE|TIME_MINUTES);
                  ObjectCreate(objPeakv,OBJ_VLINE,0,iTime(NULL,0,idx+1+sig_shift),iHigh(NULL,0,idx+1));
                  ObjectSet(objPeakv,OBJPROP_COLOR,shortclr);
                  ObjectSet(objPeakv,OBJPROP_STYLE,vert_style);
                  ObjectSet(objPeakv,OBJPROP_WIDTH,1);

                 }

              }

            //--long
            if(ChartFillColor[idx+1]>chart_long_level && ChartFillColor[idx+2]<=chart_long_level)
              {

               Salerttxt="C_Blocks "+Symbol()+" Tf "+Period()+" Level Hit @ "+DoubleToStr(chart_long_level,1)+" "+TimeToStr(iTime(NULL,0,idx+1),TIME_DATE|TIME_SECONDS);
               if(Alerts_On)if(NewBarShort()) { Alert(Salerttxt+" Long Direction");}
               string objValley="cbot"+TimeToStr(iTime(NULL,0,idx+1+sig_shift),TIME_DATE|TIME_MINUTES);
               ObjectCreate(objValley,OBJ_ARROW,0,iTime(NULL,0,idx+1+sig_shift),iLow(NULL,0,idx+1));
               ObjectSet(objValley,OBJPROP_COLOR,longclr);
               ObjectSet(objValley,OBJPROP_ARROWCODE,long_arrow);
               ObjectSet(objValley,OBJPROP_WIDTH,1);
               ObjectSet(objValley,OBJPROP_BACK,true);
               ObjectSet(objValley,OBJPROP_ANCHOR,ANCHOR_TOP);

               if(see_sig_verts)
                 {
                  string objValleyv="cbotv"+TimeToStr(iTime(NULL,0,idx+1+sig_shift),TIME_DATE|TIME_MINUTES);
                  ObjectCreate(objValleyv,OBJ_VLINE,0,iTime(NULL,0,idx+1+sig_shift),iLow(NULL,0,idx+1));
                  ObjectSet(objValleyv,OBJPROP_COLOR,longclr);
                  ObjectSet(objValleyv,OBJPROP_STYLE,vert_style);
                  ObjectSet(objValleyv,OBJPROP_WIDTH,1);



                 }

              }




           }



        }
      //------------------------





      if(Alerts_On)
        {

         if(ObjectFind(alertname)!=win_idx)
           {
            ObjectCreate(alertname,OBJ_ARROW,win_idx,Time[0],Alert_Level); //draw an up arrow
            ObjectSet(alertname,OBJPROP_STYLE,STYLE_SOLID);
            ObjectSet(alertname,OBJPROP_ARROWCODE,3);
            ObjectSet(alertname,OBJPROP_COLOR,ArrowColor);

           }
         if(ObjectFind(alertname)==win_idx)
           {
            ObjectSet(alertname,OBJPROP_TIME1,Time[0]);

           }

         if(ChartFillColor[1]>Alert_Level && ChartFillColor[2]<=Alert_Level   && NewBar())Alert(alerttxt+" Long Direction");
         if(ChartFillColor[1]<Alert_Level && ChartFillColor[2]>=Alert_Level  && NewBara() )Alert(alerttxt+" Short Direction");



         NewBar();
         NewBara();
        }
      //----------------------- 

     }
   return(0);
  }
//---------------------------------

//---------------------------------
bool NewBar()
  {

   static datetime lastbar=0;
   datetime curbar=Time[1];
   if(lastbar!=curbar)
     {
      lastbar=curbar;
      return(true);
     }
   else
     {
      return(false);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool NewBara()
  {

   static datetime lastbara=0;
   datetime curbara=Time[1];
   if(lastbara!=curbara)
     {
      lastbara=curbara;
      return(true);
     }
   else
     {
      return(false);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool NewBar2()
  {

   static datetime lastbar2=0;
   datetime curbar2=Time[0];
   if(lastbar2!=curbar2)
     {
      lastbar2=curbar2;
      return(true);
     }
   else
     {
      return(false);
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------+
bool NewBarShort()
  {

   static datetime lastbara=0;
   datetime curbara=Time[1];
   if(lastbara!=curbara)
     {
      lastbara=curbara;
      return(true);
     }
   else
     {
      return(false);
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------+
bool NewBarLong()
  {

   static datetime lastbara=0;
   datetime curbara=Time[1];
   if(lastbara!=curbara)
     {
      lastbara=curbara;
      return(true);
     }
   else
     {
      return(false);
     }
  }

//-----------------------------------------------------------------------------------------------------------------------------+ 
 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
Can u please send me link for mt4 section
 
Vijay Akash T P:
Can u please send me link for mt4 section

Link

 
Vijay Akash T P:

Need Help in calling index buffer values of Arrows Drawn on Main Chart in EA

I need to call the up arrow and down arrow, in this indicator, can someone help me please
ObjectCreate(objValley,OBJ_ARROW,
  1. There are two types of arrows.

    1. Buffers of type arrow. View (Alt+V) → Data Window (Control+D) If you see your "main indicator" and a value where there is an arrow, then read the buffer, (using iCustom) and do what you want with it.
      You should encapsulate your iCustom calls to make your code self-documenting.
                Detailed explanation of iCustom - MQL4 programming forum
    2. Otherwise, it is drawing arrow objects. Charts (Alt+C) → Objects → Objects List (Control+B).
      Find the corresponding object and find the naming pattern. Then you can get all appropriate objects and their values.
                Object Functions

  2. Your code is drawing objects.
Reason: