replace
if(IsNewBar()){ if(Bid > priceB) { Alert("UP", Bid); } if(Bid < priceS) { Alert("DOWN", Bid); } priceB = Open[0] + (20*Point); priceS = Open[0] - (20*Point); }
with
if (IsNewBar()) { priceB = Open[0] + (20*Point); priceS = Open[0] - (20*Point); } if (Bid > priceB) { Alert("UP", Bid); } if (Bid < priceS) { Alert("DOWN", Bid); }
because otherwise the prices are updated after the checks and not in realtime (1 bar late)
replace
with
because otherwise the prices are updated after the checks and not in realtime (1 bar late)
thanks for answer,
This is true, But this is َAlert in each tick, I want to َAlert it once in a candle, and wait for the next candle to check Bid and Candle Open[0],
Whenever a candle is created, check it, once the condition ( if's ) is right, get out of the checking and wait for the next candle.
Example for more details:
new candle created and Open[0] is: 2002.1
check and compare with the Bid, until bid is: 2004.1(or more) Or 2000.1(or more)
then Alert me and stop checking and alerting,
Until the next new candle is created
This is true, But this is َAlert in each tick, I want to َAlert it once in a candle, and wait for the next candle to check Bid and Candle Open[0],
Not tested
static bool waitNewBarUp=false; static bool waitNewBarDown=false; if(IsNewBar()) { waitNewBarUp=false; waitNewBarDown=false; } if(!waitNewBarUp && Bid-Open[0]>=20*Point) { Alert("UP", Bid); waitNewBarUp=true; } if(!waitNewBarDown && Open-Bid[0]>=20*Point) { Alert("DOWN", Bid); waitNewBarDown=true; }
Not tested
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I want to compare the Bid and the Candle open price at the beginning of each candle, in EA.
If Bid goes 20 Point(or more) higher than the Candle open price, Take a position.
If Bid goes 20 Point(or more) lower than the Candle open price, Take a position.
and And then wait for the next candle.
for example:
The candle opened and open price is: 20222.4
if bid is 20224.4 or more : open position.
if bid is 20220.4 or more: open position.
and then wait for the next candle to open...
I searched a lot but couldn't find anything to help.
I use this code to detect the beginning of the candle:
I was able to write this code, but this code compares the Bid to the previous candle opening price, at the beginning of each candle:
thanks for your help.