How to write in MQL code referring to the open/close value of the 2nd and 3rd candle before current candle?

 

[For example]

Last three candles has the following values:

_________________________________________

[3 candle]

Open 1.1234

Close 1.1249


[2 candle]

Open 1.1249

Close 1.1280


[3 candle - current candle]

Ask: 1.1285

Bid: 1.1284

____________________________________________________________________________________

My question is: How to write the code in MQL referring to the opening / closing the last two candles?

How do I get these values into the variables in MQL?

____________________________________________________________________________________

 

I just asked this question and I believe it is Open[PERIOD], for example Open[1] would be the open price of the candle that just closed. Open[2] would be the candle before that.


Can someone confirm?

 

P&G

Yes, its this method for the last closed bar

Open[1]

High[1]

Low[1]

Close[1]


and these for the bar before, etc

Open[2]

High[2]

Low[2]

Close[2]


Good luck

-BB-

 

Thank you.


Cheers,

Good people you are!

 
Is there a way to get the median price for the last bar? Something like Median[1]? I can't find any documentation for that. Does it exist?
 
golden188:
Is there a way to get the median price for the last bar? Something like Median[1]? I can't find any documentation for that. Does it exist?

Median[1]=High[1]-Low[1], if that is not what you are looking for, then you would have to figure out a formule and use close,open,high, and low values to get your median value.

Reason: