Partial close of trades
Forums › ProRealTime English forum › ProOrder support › Partial close of trades
- This topic has 3 replies, 2 voices, and was last updated 8 years ago by Nicolas.
-
-
05/30/2016 at 3:47 PM #8391
Hi there,
Say we’ve opened 2 long positions and when the trade is x pips in profit, we want to close one position and move our stop loss to BE for the remaining position , also the stop should trail the remaining position. According to me you can’t implement this scheme by just using the build-in commands “set stop loss”, “set target profit” and “set stop trailing”.
But i’ve managed to implement this scheme and it works except for the following: if a stop- or target level is reached during a certain bar then the order is not executed by PRT until the nextbar open, so hereby in general the pricelevel at which the position is actually closed by PRT is different from the preprogrammed desired exitlevel by the trader. This difference is more pronounced when trading on the higher timeframes. If the desirable exitlevel is near the close of a certain bar then the discrepancy between realtime trading and the backtesting is small. But if the exitlevel is reached somewhere at the open of a certain bar and this bar closes way off its openingprice then the discrepancy is significant. This problem is less pronounced when trading the lower timeframes, since the time elapsed between consecutive bars is much smaller and therefore the pricelevels are relatively close to each other. But what’s the reason that with the build-in command “set stop loss” PRT is able to close a position during a bar when an exit pricelevel is reached during that bar.So my conclusion is that the proposed schema can’t be programmed properly, am i correct ?
Regards,
05/30/2016 at 4:12 PM #8394Hi xozhang,
Did you test your own partial close function in real time already?
In real time, SET STOP LOSS and SET TARGET PROFIT will set your defined price levels in the broker order book, so they will be executed at the desired prices, no matter if you are at open or at close of the current bar.
05/30/2016 at 6:58 PM #8409Hi Nicolas, thnx for the swift reply, yes I know that SET STOP LOSS will close the trade at the desired price in real time, but I wanted to backtest the possibility of closing multiple positions partially. According to me this can’t be done by using the SET STOP LOSS, SET TARGET PROFIT etc …. commands in the backtest code. So I programmed my own code which closes multiple positions partially. In het screenshot below you’ll see the backtest result of 2 specific long positions X and Y where in each position 2 shares are bought. The initial stop loss is at 40 pips and when the trade has move into a profit of 90 pips, one share is sold at market and the stop loss for the remaining share becomes a trailing stop with an initial stop of 40 pips again. So lets do the numbers for both long positions X and Y :
Long position X – this trade goes into profit and at 747.2 + 90 = 837.2 one share should be closed, this condition is met somewhere at the High of Bar (A) (see screenshot), but PRT doesn’t close there but at the open of NextBar Open which is at 832.5, so here’s a difference between backtest and realtime. The profit is 832.5 – 747.2 = 85.3 pip instead of 90 pip. The Stop Loss is now moved to 832.7 – 40 = 892.7 as indicated by the stop loss GRAPH, 832.7 is the High of Bar (A) at which the first target is met. As you’ll see during the trade the Stop Loss level is continually updated up to 894.2 where the trade is stopped out and the 2nd share is sold at market. This condition is met somewhere along Bar (B) but PRT doesn’t close the trade here but at the NextBar Open at 877.3 instead of 894.2 so here’s also a difference between backtest and realtime. The profit in the backtest is (894.2 – 877.3) = 16.9 pip more than in realtime.
Long postion Y – initial stop loss is at: 891.2 – 40 = 851.2, this trade doesn’t get to the 90 pip profit target and the trade is stopped out, at 851.2 both shares are sold. This condition is met somewhere along Bar (C) but PRT closes the trade at NextBar Open at 855.8, once again a difference between backtest and realtime. The loss is 891.2 -855.8 = 35.4 pip per share in the backtest in realtime this should be 40 pip.
05/30/2016 at 7:35 PM #8414 -
AuthorPosts
Find exclusive trading pro-tools on