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:
1
2
3
4
ContractSize=round(1+strategyProfit/10000)///minimun size is 1, increase when profit is more than 10K
// Then use the BUY command
BUYContractSizeContractatmarket// 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.
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.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.