Please help to describe close price 5 minute ago in mt4

 
Hello everybody.
I am trying to code a EA:
x = close current - close at 5 minute ago.
x>30pips ->buy
x stoploss=30pips, takeprofit=80pips, trailing stop = 30pips.
Time frame 4 hour.

The problem: how to describe close price at 5 minutes ago in mt4 ?

The close price at 5 minutes ago will change value with time.

Anyone help me ? Thank you so much.
 
Huylucdao:
Hello everybody.
I am trying to code a EA:
x = close current - close at 5 minute ago.
x>30pips ->buy
x stoploss=30pips, takeprofit=80pips, trailing stop = 30pips.
Time frame 4 hour.

The problem: how to describe close price at 5 minutes ago in mt4 ?

The close price at 5 minutes ago will change value with time.

Anyone help me ? Thank you so much.

There is no "close price" 5 minutes ago . . . close price applies to a bar and discrete packets of time, not x minutes ago. You can get the close of a M1 bar 5 bars ago . . .

iClose(NULL, PERIOD_M1, 5)
 
Thank RaptorUK so much :)
RaptorUK:

There is no "close price" 5 minutes ago . . . close price applies to a bar and discrete packets of time, not x minutes ago. You can get the close of a M1 bar 5 bars ago . . .


Reason: