Posted By: GHRouge
Optimize Error 040 while limiting concurrent trades - 07/18/16 00:10
Hi,
I've been coming across a lot of Error 040s due to the way I've tried to implement a method to limit the total amount of trades that a strategy can execute.
Here is an example of what's happening. There is only 1 optimize call:
I have narrowed down the issue to the trade limiting lines. Commenting them out will result in an optimization without Error 040.
Does anyone have a suggestion for a better way to limit the number of trades an algo places without causing these errors?
Thanks!
I've been coming across a lot of Error 040s due to the way I've tried to implement a method to limit the total amount of trades that a strategy can execute.
Here is an example of what's happening. There is only 1 optimize call:
Code:
function ABC();{ // Trading strategy 1 algo("ABC:L") // Maximum Trade Limiter var total; for(current_trades) total++; if (total >= 4) return; Stop = 3 * ATR(10); Trail = optimize(1,1,6) * ATR(10); ... <strategy code> ... } function run(){ set(PARAMETERS); while(algo(loop("ABC",...))){ if(algo == "ABC") ABC(); if(algo == "...") ... ... } }
I have narrowed down the issue to the trade limiting lines. Commenting them out will result in an optimization without Error 040.
Does anyone have a suggestion for a better way to limit the number of trades an algo places without causing these errors?
Thanks!