I made a surprising discovery. As we all know it is not possible to close a position partially with proorder. This is at least what I thought.
But now I noticed that under special circumstances proorder DOES close positions partially – at least in backtest. I don’t know what will happen in live trading though.
In backtest PRT closes a position partially IF it is a cumulated position and you have a set profit target like SET TARGET PPROFIT 20. This will close just always the part of your position that reaches 20 pips profit and leaves the rest unaffected.
Have a look at the attached picture. You see the strategy accumulating orders and coming up to 11 contracts maximum. And now look at the closes! I thought the whole 11 contracts would be closed at once BUT very wrong. In the backtest 4 contracts close on 14th may (all 4 at different price levels!!), on 15th close another 3, on 16th 2 more and the remaining 2 are closed on 27th because price drops under the trailing SL.
This was EXTREMELY unexpected for me and I’m still unsure what to expect in live trading.
Each order (with IG/PRT-CFD) has its own takeprofit and stoploss level, right. But you cannot set different takeprofit value for individual order.
So, this is not a partial closure of 11 contracts, bought at the same level.
So I guess you could BUY or SELLSHORT several positions using STOP or LIMIT orders at the same price? You can then close out one position at a time which is almost like partially closing out some of one larger position. Obviously your minimum stake would be higher than the minimum for that market.
I also don’t see yet how one can make use of this fact but i thought it is interesting und it was definitely unexpected for me.
So basically we can summarize one can set individual targets and stops for every accumulated part of an order but using standard buy/sell orders will always close the whole position.
Is it not possible to set different StopLoss and TakeProfit levels for each entry to the market within the IF condition THEN?
I think it should work if you set target and stop always directly after opening a position. When cumulating is activated PRT obviously takes the set target and stop only for the last addition to the cumulated position.
Then I see no possibility to influence this stops or targets for the different parts of a cumulated order. You always can only manipulate the stop and target for the last part that you opened at tradeindex(1). So one can set this stops and targets and leave them in the market and can have an additional SL for the whole position (or what is left).
I remember writing strategies in probacktest with the defparam cumulate orders = true and going for partial closure before being able to use the “graph” function, imagine the nightmare trying to debug rebuilt acpu’s corrected of partial gains without graphing it, to go around the prt position centric entry price… Partial close was working then with “at market” and pending “at stop” and “at limit” orders, it even worked with a stored variable rather than a number for contract numbers (as long as it was an integer, haven’t tried again since decimal orders are possible), but we never could choose which one was closed, we could only manage a total number of opened positions varying with all the adding and substracting and re-adding of contracts. Imagine the disappointment when first going live without knowing yet partial close doesn’t work live, and going back to semi-manual trading from indicators at the time…
Tell me about it. I thought yesterday that I found the holy grail after great looking WFA and even monte carlo simulation looked great. But well, if it is too good to be true, it probably isn’t…
When cumulating is activated PRT obviously takes the set target and stop only for the last addition to the cumulated position.
No. If you SET TARGET, it will affect all opened positions, sorry 😐
OK, but how does this partial closures than happen Nicolas? If the set command would sell the whole position it should look like it does on the picture I attached above.
I now eliminated all SET instructions (both SET TARGET and SET STOP) from the code and the result changes significantly.
Please have a look at the attached picture. The lower code (blue and orange symbols) utilizes the set command while the upper (turkos and pink symbols) does not. Beginning with march 8th both strategies accumulate long contracts BUT the set version closes at four different days parts of the position (with set target).The pink/turkos strategy without set command can’t do so and closes the whole position (5 contracts) on april 10th. The orange/blue strategy has the same stop loss and also closes the position on 10th april but has at this time only 2 contracts left because of closing 4 contracts in-between (and actually also buying a new contract because falling under max positionsize).
Anyway Nicolas, I think this is only explainable with the set command only selling the last addition to a position. If you have another explaination I’m keen to hear it.
Yes, these are positions with the same take profit in points from their opened prices which is fully compliant with what I have in mind 🙂 But Set target will give the same take profit for each order (from their opening prices).
Then I think this was a misunderstanding. We both see and think the same but put it in other words. SET gives the same take profit for all (parts) of a cumulated order.
Now you two are getting me confused! Am I right in thinking that you can have several positions open all with different levels of SL and TP if you have used a different SET instruction after each BUY or SELL instruction?