Forums › ProRealTime English forum › ProOrder support › 100% time onmarket long and short strategy – unwanted partial close problem › Reply To: 100% time onmarket long and short strategy – unwanted partial close problem
Hi Nicolas,
thanks for your reply.
I will double check to make sure that positions are balanced because of rounding, and that this hasn’t caused a problem somehow.
I do know what you mean about closing all orders, and I will try different variations of this.
As I mentioned in the second block of code snippet in my initial post above , with my first attempt to fix this problem I did try to exit out of all positions first, before trading in the opposite direction – market exit code used as per below (for shorts):
1 2 3 |
if shortonmarket then exitshort at market endif |
and then placed a buy order for a positionsize directly after it.
The 2nd block of code in my initial post (with exitshort) works fine/gives the exact same backtest result as my initial code, but again when I try to set it up for live trading, the error message is displayed.
In theory, this should counteract any out of balance positions, because you are starting with a clean book with no positions before you take on a new order, right?
And by just saying “exitshort at market”, you are not specifying a quantity in the instructions for disposal – which seems to be the initial problem that I was dealing with. So this problem should be solved, but it still doesn’t seem to be?
Is it possible – to exitshort at market – and then – buy new positions all in the same bar/candle/same run of code? This is what I’m aiming for.
Many thanks,
Finning.