For check if new bar start.
double prevtime = 0; bool is_new_bar(){ if(prevtime != Time[0]){ prevtime = Time[0]; return true; } return false; }
you need to call is_new_bar() on every tick...
If you want bar close value.
double current_close = Close[0]; double prev_close = Close[1]; double prev_prev_close = Close[2]; ...
selnomeria: I use script to force the EA to run once on every bar start.
..... if( Now == Time( 0 )) { return(); } .... what is the solution? how can i get the CLOSE of that bar? b |
|
|
SOrry, you are right...
abut my goal: I JUST WANT TO CHECK IF CURRENT 5 MINUTE BAR's close price is above open, then send buy-order.
I dont want to check this on next bar...
asad998
your solution of current close[0] - If it is checked on first (new_bar_open) tick, then how it can get CLOSE value of the whole 5 min bar (because it is only first tick)? so, that's why I want that only to run on the CLOSE (LAST TICK) of bar in EA.
selnomeria: your solution of current close[0] - If it is checked on first (new_bar_open) tick, then how it can get CLOSE value of the whole 5 min bar (because it is only first tick)?
|
|
|
WOW :((((
At 11:59:58 are there going to be more ticks before 12:00:00?
At 11:59:59 are there going to be more ticks before 12:00:00?
At 12:00:00 no more ticks can be added to the 11:59:00 bar. But the 12:00:00 bar doesn't open until the first tick arrives. That might be 12:00:01 or 12:00:03...
You don't know the final close price of a bar until a new bar starts. Which is why many EAs are coded to trade on the first tick received of a new bar, using the prices of the previous bar.
At 11:59:58 are there going to be more ticks before 12:00:00?
At 11:59:59 are there going to be more ticks before 12:00:00?
At 12:00:00 no more ticks can be added to the 11:59:00 bar. But the 12:00:00 bar doesn't open until the first tick arrives. That might be 12:00:01 or 12:00:03...
You don't know the final close price of a bar until a new bar starts. Which is why many EAs are coded to trade on the first tick received of a new bar, using the prices of the previous bar.
yes, its good explanation.
- 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 use script to force the EA to run once on every bar start.
..... if( Now == Time[0]) { return; } ....
However, in my EA, let's say, Trade happens if CLOSE>OPEN of the bar (i dont matter ticks)...
however, the EA is executed only on OPENs of bars...
what is the solution? how can i get the CLOSE of that bar? b