I wanted to code something that, at the start of the current timeframe candle, the EA will check say, the trend. Then later on, at every tick it will check something else.
I tried to use the below format
but i realise that it only runs what is at the start of every candle but not running what is at every tick. why is that so?
Because of the return(0); it exits from the start() function.
Try this . . .
int start() { if (Time0 != Time[0]) { //check the trend and other things that happen at the start of the bar Time0 = Time[0]; } // every tick// //ordersend etc other commands }
Your code | int start() { // every tick if (Time0 == Time[0]) return(0); Time0 = Time[0]; // new bar only |
try | int start() { if (Time0 != Time[0]){ Time0 = Time[0]; // new bar only } // every tick } |
if (Time0 < Time[0])
Hi WHRoeder, raptor
thanks for the suggestion but I think there is something wrong. Instead of doing what is within the bracket once every candle, it is executing it v tick..
Could you advise?
thanks.
Previously a post said the broker had the wrong datetime (wrong date, correct time) when they corrected it, the EA stops functioning. Use != not <
That was not the whole code i deleted
I will write my code again so you see how it was
because i don't understand why it is wrong using < this way
int start() { if (Time0 < Time[0]) { //check the trend and other things that happen at the start of new bar Time0 = Time[0]; // or Time[0] = TimeCurrent(); } // check something else. }I did not make it TimeLocal( );
//or Time0 = TimeCurrent(); <<<=== That is not TimeLocal() !!!!
With using TimeLocal( ) you can get it it will have a wrong datetime (wrong date, correct time)
not with using brokertime TimeCurrent ( )
I deleted my post because i thought there was written 3 times almost same solution for one question
The problem you are describing is because difference timezone between brokertime and localtime can make this error
a different day but right time
So how can brokertime be different from TimeCurrent( ) ??
Are you sure the OP of that Previously posting mentioned that issue did not change Periodicity of the timeframe
that can have lead to such an error i think and might have ended working EA
Hi WHRoeder, raptor
thanks for the suggestion but I think there is something wrong. Instead of doing what is within the bracket once every candle, it is executing it v tick..
Is Time0 declared Globally ? do you understand how the code works or are you just copy & pasting it and hoping for the best ?
I used the below.
understand that what happened within the candle should be within the {}. So. I'm just puzzled why it is doing every tick instead of every candle
static datetime Time0;
I used the below.
understand that what happened within the candle should be within the {}. So. I'm just puzzled why it is doing every tick instead of every candle
Put this indicator on a M1 chart and watch the experts tab for a coulple of minutes . . . then figure out what you did wrong and let us know please.
ur indicator works perfectly well...
is it because it's if (Time0 != Time[0]) not if (Time0 == Time[0])
ur indicator works perfectly well...
is it because it's if (Time0 != Time[0]) not if (Time0 == Time[0])
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I wanted to code something that, at the start of the current timeframe candle, the EA will check say, the trend. Then later on, at every tick it will check something else.
I tried to use the below format
but i realise that it only runs what is at the start of every candle but not running what is at every tick. why is that so?
Thanks.