Hello,
I want the quantity of contract to increase/decrease as the strategyprofit increases. So i tried the following code together with the BUY order command:
ContractSize=round(1+strategyProfit/10000) ///minimun size is 1, increase when profit is more than 10K
// Then use the BUY command
BUY ContractSize Contract at market // this does not works, BUY is never executed
If I change the ContractSize variable and set any integer number (1, 2, etc), it works. So I’m not sure if the result of the round function is giving me trouble.
anyone has had the same problem?
Try with:
ContractSize=max(1,round(1+strategyProfit/10000))
If it doesnt work, try to [scode]GRAPH ContractSize[/scode] in your backtest.
Thanks!
I was looking for a way to check the variables values, I’ll try that and get back to you.
The problem was i was using pipvalue to calculate the contract size with the SP500 index. I started using the SP500 Futures instead (ESXXXX) and the formula started working.
thanks a lot!
LeoParticipant
Veteran
Try this:
n = 1 + (strategyprofit / (134*pipvalue))
n = round(n * 100)
n = n / 100
n = max(1,n)