Plotting lines in an EA

To add comments, please log in or register
John Skinner
120
John Skinner  

Hi,

I am trying to write an EA that will plot the lowest low and highest high for the past ‘n’ number of days. I have worked out how to do it in a Custom Indicator but can’t figure it out in an EA.

I have attached a image of what I am trying to achieve.

Could someone point me to some example code that will help me with what I am trying to achieve?


Thanks,

John

Simon Gniadkowski
17239
Simon Gniadkowski  
Use iHighest and iLowest with PERIOD_D1 and set the count value to be n days . . . then when you have the bar numbers for each you can iHigh and iLow to the the highest and lowest price values (if your chart is on D1 then you can use High[] and Low[] instead)
John Skinner
120
John Skinner  
RaptorUK:
Use iHighest and iLowest with PERIOD_D1 and set the count value to be n days . . . then when you have the bar numbers for each you can iHigh and iLow to the the highest and lowest price values (if your chart is on D1 then you can use High[] and Low[] instead)

Any chance you would have some sample code. I just can't get my head around it
Simon Gniadkowski
17239
Simon Gniadkowski  
skinner36:

Any chance you would have some sample code. I just can't get my head around it

Show what you have tried . . . there is sample code in the Documentation

double val;
  // calculating the highest value on the 20 consequtive bars in the range
  // from the 4th to the 23rd index inclusive on the current chart
  val=High[iHighest(NULL,PERIOD_D1,MODE_HIGH,20,4)];
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,val),", ",  iOpen("USDCHF",PERIOD_H1,val),", ",
                                      iHigh("USDCHF",PERIOD_H1,val),", ",  iLow("USDCHF",PERIOD_H1,val),", ",
                                      iClose("USDCHF",PERIOD_H1,val),", ", iVolume("USDCHF",PERIOD_H1,val));
Tjipke de Vries
6659
Tjipke de Vries  

Never seen this indicator ???

https://www.mql5.com/en/code/7107

Choose for N2 the value '0'

and for the last changes you can play with the timeframe value to get the right one

not that hard to do so let us know if your succeed and what you did...

To add comments, please log in or register