
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
What value does IsTrade have when you declare it ? Either make this static or give it a global scope . . .
Tried making it global, then the EA placed only one trade throughout the entire backtest.
It's declared as false.
If I declare it before the initial for loop that has OrderSelect(), then assign a true value to it if it finds an order with the magic number, I end up with over 800 trades -
two extremes :)
Tried making it global, then the EA placed only one trade throughout the entire backtest.
Yep, you need additional code to set it false . . when should it be false ? I presume when there are no orders placed ? so code a check that looks to see if there are any running trades . . if not set IsTrade = false;
Okay, so figured out the problem - apparently, as soon a trade gets closed because of a stop loss getting kicked in, the EA immediately opens another trade - so instead of trades being opened at even times such as 1200, 1600, 2000(four hour candles, since that is the TF I am running the backtest on) trades are being opened in between as well, at odd times -
1 2010.09.15 04:00 buy 1 0.10 1.29648 1.28530 0.00000 0.00 10000.00 - this one is fine, opening at the start of a 4 hour candle
2 2010.09.16 01:35 modify 1 0.10 1.29648 1.30010 0.00000 0.00 10000.00 - this is also fine, the stop is moved up to the next low
3 2010.09.16 01:36 s/l 1 0.10 1.30010 1.30010 0.00000 36.75 10036.75 - this is fine too, the stop is kicked in and im out for a profit
4 2010.09.16 01:36 buy 2 0.10 1.30028 1.29540 0.00000 0.00 10036.75 - this is confusiing - its 1:36 am, and it takes a trade
5 2010.09.16 01:40 modify 2 0.10 1.30028 1.30010 0.00000 0.00 10036.75 - 4 minutes after the trade, the stop is moved up
6 2010.09.16 01:43 s/l 2 0.10 1.30010 1.30010 0.00000 -1.80 10034.95 - 3 minutes later, the stop-loss is kicked in
7 2010.09.16 01:43 buy 3 0.10 1.30038 1.29540 0.00000 0.00 10034.95 - new trade immediately(since conditions haven't changed on the H4)
8 2010.09.16 01:43 modify 3 0.10 1.30038 1.30010 0.00000 0.00 10034.95 - stop moved immediately
9 2010.09.16 01:43 s/l 3 0.10 1.30010 1.30010 0.00000 -2.80 10032.15 - stop loss
This is why there are over a thousand trades in 8 months, lol - any suggestions?