Pivot Point Indicator with Arrows for signal

 
Hi there , I am currently working on a pivot point indicator which should display some signals to a user via the use of arrow symbols. I am trying to find out if it is possible to enable the bars on the charts to interact with the pivot lines so for example: If a bar touches Support Line 1, a arrow should be displayed below that same bar pointing upwards suggesting to the user/trader that they can consider going LONG on that pair now, and vice-versa if the Resistance Line 1 is touched an arrow should be displayed above that bar pointing downwards suggesting to the user that they can now go SHORT. Is this doable? I have already began programming this and the pivot point lines are drawn out using data buffers and I have attached an image displaying how I would like the signals to look. Any help would be appreciated as this is for my final year of university project. Thanks.
 
  1. Of course it's possible. A line has a price, a bar has H/L price. If they overlap do what you want. If you really had begun programming this you wouldn't have asked the question.
  2. No image attached.
  3. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
 

Thanks for the response, here is the code I have constructed so far:

 

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

//|                                                     Attempt1.mq4 |

//|                                                 Aramide Shobande |

//|                                          aramide_s@hotmail.co.uk |

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

#property copyright "Aramide Shobande"

#property link      "aramide_s@hotmail.co.uk"


#property indicator_chart_window

#property indicator_buffers 5

#property indicator_color1 Lime

#property indicator_color2 Red


#property indicator_color3 Blue

#property indicator_color4 Lime

#property indicator_color5 Red


extern int numOfBars=100;


//--- buffers

double ExtMapBuffer1Up[];

double ExtMapBuffer2Down[];


double PivotBuffer[];

double S1Buffer[];

double R1Buffer[];


string Pivot="Pivot Point", Sup1="S 1", Res1="R 1";


int fontsize=15;


double P,S1,R1;


double LastHigh, LastLow, x;

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

   SetIndexStyle(0,DRAW_ARROW);

   SetIndexArrow(0,241);

   SetIndexBuffer(0,ExtMapBuffer1Up);

   

   SetIndexEmptyValue(0,0.0);

   

   SetIndexStyle(1,DRAW_ARROW);

   SetIndexArrow(1,242);

   SetIndexBuffer(1,ExtMapBuffer2Down);

   

   SetIndexEmptyValue(1,0.0);

   

   string short_name;

   

   SetIndexStyle(2,DRAW_LINE,0,1,Blue);

   SetIndexStyle(3,DRAW_LINE,0,1,Lime);

   SetIndexStyle(4,DRAW_LINE,0,1,Red);

   

   SetIndexBuffer(2,PivotBuffer);

   SetIndexBuffer(3,S1Buffer);

   SetIndexBuffer(4,R1Buffer);

   

   short_name="Pivot Point";

   IndicatorShortName(short_name);

   SetIndexLabel(2,short_name);

   

   SetIndexDrawBegin(2,1);

//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//----

   ObjectDelete("Pivot");

   ObjectDelete("Sup1");

   ObjectDelete("Res1");

   

//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

   int    counted_bars=IndicatorCounted();

   int    maximum;

   int    i;

   double MakeArrow;

   

   if(counted_bars==0)

   {

      x=Period();

      if(x>240) return(-1);

      

      ObjectCreate("Pivot",OBJ_TEXT,0,0,0);

      ObjectSetText("Pivot", "Pivot Point",fontsize,"Arial",White);

      

      ObjectCreate("Sup1",OBJ_TEXT,0,0,0);

      ObjectSetText("Sup1","S 1",fontsize,"Arial",White);

      

      ObjectCreate("Res1",OBJ_TEXT,0,0,0);

      ObjectSetText("Res1","R 1",fontsize,"Arial",White);

   }

   

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

   maximum=(Bars-counted_bars)-1;

   

   for(i=maximum; i>0;i--)

   {

      if (High[i+1]>LastHigh)

         LastHigh=High[i+1];

         

      if (Low[i+1]<LastLow)

         LastLow=Low[i+1];

         

      if (TimeDay(Time[i])!=TimeDay(Time[i+1]))

         {

            P=(LastHigh+LastLow+Close[i+1])/3;

            

            R1 = (2*P)-LastLow;

            S1 = (2*P)-LastHigh;

            

            LastLow=Open[i];

            LastHigh=Open[i];

            

            ObjectMove("Pivot",0,Time[i],P);

            ObjectMove("Sup1",0,Time[i],S1);

            ObjectMove("Res1",0,Time[i],R1);

         }

         

         PivotBuffer[i]=P;

         S1Buffer[i]=S1;

         R1Buffer[i]=R1;

         

         

         //This is where the interaction between the pivot point lines

         //and the bars touching them should take place

         MakeArrow=Bars;

         

         if(MakeArrow<R1Buffer[i])

            ExtMapBuffer1Up[i]=Low[i]+5*Point;

         else

            ExtMapBuffer1Up[i]=0.0;

         

    }


//----

   

//----

   return(0);

  }

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

 

 The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?

 

I have also attached the source code. 

Files:
attempt1.mq4  5 kb
 
UniPivotDev:

Thanks for the response, here is the code I have constructed so far:

 <CODE REMOVED>

 

 The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?

 

I have also attached the source code. 

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button.
 
UniPivotDev:

Thanks for the response, here is the code I have constructed so far:


 The section I have highlighted in yellow is where I attempted to make the arrows appear when the bar exceeds or touches R1 in this case a arrow should appear pointing down. Now what is currently happening is that an arrow appears on all the bars not just the ones that have exceeded R1 so what is the approach I should take here?

 

Why are you comparing a bar count,  Bars,  against a price,  R1Buffer[i] ?

         MakeArrow = Bars;

         if(MakeArrow < R1Buffer[i])
 

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. comparing bar count against a price
  3. never updating MakeArrow
  4. Just compare the bar high vs R
 
I have made some amendments as can be seen below, the program tries to take in the Price_close and if the arrows variable (MakeArrow) 
price is less than R1Buffer price (which is resistance 1 in my pivot points) an arrow should be outputted, if not then no arrow should 
be outputted. This is just a test to see if the arrows would output as seen below:




         MakeArrow[i]=PRICE_CLOSE;
         
         if(MakeArrow[i]<R1Buffer[i])
            ExtMapBuffer2Down[i]=High[i]+5*Point;
         else
            ExtMapBuffer2Down[i]=0.0;

Am I on the right track here now? As what I need to do now is to make it so if the price of most recent bar is at the same price 
as where R1Buffer is (Resistance 1) then an arrow should appear. Any extra tips?
 
UniPivotDev:

PRICE_CLOSE is what ?  maybe it is zero ?  PRICE_CLOSE

Coding is not about guessing,  you need to read, learn and think.

 

Price close is the closed price of a bar is it not? So what I am trying to get the code to do here is to output an arrow above a bar which has closed above the price of where the R1Buffer was generated using the pivot point calculations. What keeps occurring here now is that once the closed bar closes above R1 an arrow is still not displayed and I can't seem to figure out why.

 

Anyways since then I've opted to use the following method:

 MakeArrow[i]=Open[i];
         
         if(MakeArrow[i]>=R1Buffer[i])
            ExtMapBuffer2Down[i]=High[i]+5*Point;
         else
            ExtMapBuffer2Down[i]=0.0;

 Which means the variable array MakeArrow[i] is assigned the value of Open[i], meaning that when the Open[i] opens above R1 an arrow should be outputted. This is a syntax that would be accepted in usual C++/C# but MQL4 is not performing the function as I would expect.

 

Where arrows should be outputted

As Can be seen in the attached image, several arrows should have been outputted where the bars opened above R1 but they have not appeared.

 

What should happen 

This is what should occur when the lines are touched or exceeded. Am I using the wrong approach as I am running out of time, I can only test this indicator while the market remains open. 

 
UniPivotDev:

Price close is the closed price of a bar is it not? 


Did you click the link I posted ?  PRICE_CLOSE is a constant and has a value of zero.  Click this link:  PRICE_CLOSE

 

UniPivotDev:

Anyways since then I've opted to use the following method:

Which means the variable array MakeArrow[i] is assigned the value of Open[i], meaning that when the Open[i] opens above R1 an arrow should be outputted. This is a syntax that would be accepted in usual C++/C# but MQL4 is not performing the function as I would expect.

Well done,  you are making progress.