Hi guys, I’m new here just tinkering around my setup until I have this problem.
I want to close out all short/long position when a condition is fulfilled and proceed with adding new long/short position at the same time. The problem is I have three different result when the code seemingly have the same logic. *or is it me?*
Below code give me below error when I want to prepare it for automated trading.
“Trading systems with orders that partially close a position cannot be sent to ProOrder”
This version 1 below gives me 400% return but code does not work as mentioned earlier.
V2
1
2
3
4
5
6
7
8
9
IFc1ANDc2ANDc3ANDc4ANDc5ANDc6ANDc7ANDc8THEN
BUYCOUNTOFSHORTSHARESCONTRACTATMARKET
BUY5CONTRACTATMARKET
ENDIF
IFs1ANDs2ANDs3ANDs4ANDs5ANDs6ANDs7ANDs8THEN
SELLCOUNTOFLONGSHARESCONTRACTATMARKET
SELLSHORT5CONTRACTATMARKET
ENDIF
So I moved on to the version 2, the code works however it only give me 100% return.
V2
1
2
3
4
5
6
7
8
9
IFc1ANDc2ANDc3ANDc4ANDc5ANDc6ANDc7ANDc8THEN
BUYATMARKET//to close out whatever short position i have
BUY5CONTRACTATMARKET
ENDIF
IFs1ANDs2ANDs3ANDs4ANDs5ANDs6ANDs7ANDs8THEN
SELLATMARKET//to close out whatever long position i have
SELLSHORT5CONTRACTATMARKET
ENDIF
So I went on with version 3, this code works as well but this time give me 300% return
version 3
1
2
3
4
5
6
7
8
9
10
11
12
13
IFc1ANDc2ANDc3ANDc4ANDc5ANDc6ANDc7ANDc8THEN
IF(COUNTOFSHORTSHARES>0)THEN
BUYATMARKET//to close out whatever short position i have
ENDIF
BUY5CONTRACTATMARKET
ENDIF
IFs1ANDs2ANDs3ANDs4ANDs5ANDs6ANDs7ANDs8THEN
IF(COUNTOFLONGSHARES>0)THEN
SELLATMARKET//to close out whatever long position i have
ENDIF
SELLSHORT5CONTRACTATMARKET
ENDIF
I like to be able to get back where i can have 400% return, but I do not understand why there are differences in the results from the three versions.
If you are long on the market then a SELLSHORT instruction will close all long positions.
If you are short on the market then a BUY instruction will close all short positions.
Partial closure of positions, for example: BUY 5 contracts then SELL 1 contract is possible only in backtesting. You cannot run a strategy live with partial closure at the moment in PRT.
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.