Compare Ask price with a given previous price value - Unexpected result.

 

Hi,

I wanted to create an ea to enter trade whenever the price gone either x pips above or below a given price value.

For example, 

Chart - AUDUDS symbol, Timeframe :1Hr, 15pips to trigger trade.

Start  ea at 0.79084 price value, so A = 0.79084 + 15pips = 0.79234 (Open buy trade)

Then B = 0.79084 - 15pips = 0.78934 (Open sell trade).

A and B was calculate once the ea initialize.

The compare price code is as below:

if(Ask > A){

//Open Buy Trade

}


if(Bid < B){

//Open sell Trade

}


But when applied to chart, it triggers Buy trade eventho the High value for that bar is only 0.79220.


I cannot figure out what is causing the trigger. Please help, thanks.

 
sniper_ea:


But when applied to chart, it triggers Buy trade eventho the High value for that bar is only 0.79220.

if high value for the bid is 0.79920

the high value for ask is 0.79920+spread.

Buys are opened at ask.

 
Keith Watford:

if high value for the bid is 0.79920

the high value for ask is 0.79920+spread.

Buys are opened at ask.


Does it means that the price low, opened, closed, high for each bar is based on the Bid?


Thanks.

 
sniper_ea:

Does it means that the price low, opened, closed, high for each bar is based on the Bid?


Thanks.


Yes, the charts are based on Bid prices.

You can turn on a line to show the current Ask price, but that is all.

Reason: