static bool logic = 0; if(logic == 0) { //do logic 1 logic = 1; } if(logic == 1) { // do logic 2 }Use static variables if you want their values to last more than one tick.
// if(logic=FALSE) Don't assign false to logic and then test for it to be true. if(logic == FALSE) test if it is false.
- Why test it for if(logic == false), you know it is false because you set it just above in the if(logic == true{}.
- Remember statics (and globally declared) variables are not reset on chart changes
- You would never write if( (2+2) == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Especially use readable names for self documenting code
static bool isFirstTick = true; if(isFirstTick){ isFirstTick = false; : // first tick only } else{ : // not first tick } // every tick
WHRoeder:
- Why test it for if(logic == false), you know it is false because you set it just above in the if(logic == true{}.
- Remember statics (and globally declared) variables are not reset on chart changes
- You would never write if( (2+2) == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Especially use readable names for self documenting code
Thanks Sir.
Understood why I shouldn't use (Bool==True).
It has worked now.
Now I'd check it for the Full program.
I just Hope it wouldn't be a Mess!
Regards
In my example, you would need to return after the first logic to prevent it doing both on the first tick:
static bool logic2 = 0; if(!logic2) { //do logic 1 logic2 = true; return; } if(logic2) { // do logic 2 }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have been trying a Logic to work.
After starting, at the first Tick, the EA will execute 'One Set of Logic'. Then from the 'Second' Tick, it'll keep executing another 'Set of Logic'.
To do so I tried something like this:
But on the Second Tick, 'Choose_Logic' remains 'TRUE' as it's getting it defined like that at the starting.
Tried some other things but didn't work.
A 'for' loop or 'Case-Break' can be used?
Please suggest me how can I implement this?
Thanks