a bunch of these:
2022.03.07 22:03:31.317 2012.01.30 09:00:15 Failed to copy data from the indicator with index 1, error code 4806
and then of course the margin calculation fails because the price level is "inf"
I can also see during debugging that the following function
sqGetIndicatorValue(ATR_1, 0, 3);
returns "inf" so that's how I know it is the ATR indicator.
Another weird thing is that strategies from other "batches" with ATR-adjusted price levels are working fine on this data. It is only these strategies from this "batch" on the year 2011 of Dukas data SPX500 that the ATR is not working.
Also during compilation, I get this warning:
declaration of 'ATRPeriod' hides global variable test.mq5 6660 58
I'll attach any others that I find below....
EDIT:
Changing this line to this solves the issue:
int minBars = 150;
It should probably be the "mathmax" of all the periods.... (Actually, the largest period is 148 but 148 and 149 didn't work so should be MathMax plus 2 I guess for whatever reason.)
-------------------------------------------------------------------------------
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 ---VERBOSE--- 2015.10.21 17:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 ---VERBOSE--- 2015.10.21 17:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
Commenting out the margin check I simply get an invalid price because of the infinity order levels, so probably the infinity order levels were causing a false negative for the margin calculation.
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 failed buy stop 0.1 SPX500_duk at inf sl: inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 Alert: Error description: Trade request sending failed
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Max money to risk: 1000.00000000, SL:-inf, Max 1 lot trade drawdown: inf, Point value: 10.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 failed sell stop 0.1 SPX500_duk at -inf sl: -inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 Alert: Error description: Trade request sending failed
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Max money to risk: 1000.00000000, SL:-inf, Max 1 lot trade drawdown: inf, Point value: 10.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 failed sell stop 0.1 SPX500_duk at -inf sl: -inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 Alert: Error description: Trade request sending failed
Oddly this strategy seems to work on EURUSD but not SPX500 but all other strategies seem working on SPX500...
Description changed:
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 ---VERBOSE--- 2015.10.21 17:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 ---VERBOSE--- 2015.10.21 17:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 17:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 ---VERBOSE--- 2015.10.21 18:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 18:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 ---VERBOSE--- 2015.10.21 19:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 19:00:02 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 ---VERBOSE--- 2015.10.21 20:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 20:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Max money to risk: 1000.00000000, SL:inf, Max 1 lot trade drawdown: nan, Point value: 10.00000000
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 ---VERBOSE--- 2015.10.21 21:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 11:48:36.095 Core 01 2015.10.21 21:00:00 Alert: Not enough money to send order with 0.10000000 lot or Margin Calculation Error
Commenting out the margin check I simply get an invalid price because of the infinity order levels, so probably the infinity order levels were causing a false negative for the margin calculation.
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 failed buy stop 0.1 SPX500_duk at inf sl: inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 19:00:01 Alert: Error description: Trade request sending failed
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Max money to risk: 1000.00000000, SL:-inf, Max 1 lot trade drawdown: inf, Point value: 10.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 ---VERBOSE--- 2015.09.17 20:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 failed sell stop 0.1 SPX500_duk at -inf sl: -inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 20:00:00 Alert: Error description: Trade request sending failed
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Computing Money Management for order - Risk fixed % of account
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Computing Money Management - Smallest_Lot: 0.10000000, Largest_Lot: 100.00000000, Computed LotSize: 0.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Max money to risk: 1000.00000000, SL:-inf, Max 1 lot trade drawdown: inf, Point value: 10.00000000
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 ---VERBOSE--- 2015.09.17 21:00 Calculated LotSize is <= 0. Using LotsIfNoMM value: 0.10000000)
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 failed sell stop 0.1 SPX500_duk at -inf sl: -inf [Invalid price]
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 Alert: The order request could not be completed. Error no.: 4756
2022.03.03 12:02:04.426 Core 01 2015.09.17 21:00:00 Alert: Error description: Trade request sending failed
Oddly this strategy seems to work on EURUSD but not SPX500 but all other strategies seem working on SPX500...
Status changed from New to Fixed
The sqATR indicator is the culprit. I have solved the indicator.
For the minBars, I cannot generate based on the period. This is because the user can modify the period. We cannot control what period the user going to set. I have updated the minBars to become an input. So the user can modify the minBars from the input list.
Thank you.