What's wrong with this code? (Trade once per bar)
You don't instruct the EA to do anything if the condition is false and when the condition is true, it justs assigns a value to the variable ThisBarTrade
line 2 is conditional on line 1, then it will continue with the rest of the code
| Your code | if (Bars != ThisBarTrade ) ThisBarTrade = Bars; : // every tick |
| Equivalent | if (Bars != ThisBarTrade ) ThisBarTrade = Bars; : // every tick |
| Try | : // every tick static datetime timeNow; datetime timePrev = timeNow; timeNow = Time[0]; if (timeNow != timePrev) { : // Once per bar } : // every tickDon't use bars, if new history is downloaded, Bars changes. Don't use tick volume, you can miss ticks. Always use time. See also resetting statics |
No errors but continues to open multiple trades when stopped out during signal bar. Any help would be much appreciated.
Cheers.