Cumulate orders and stops & targets
Forums › ProRealTime English forum › ProOrder support › Cumulate orders and stops & targets
- This topic has 34 replies, 2 voices, and was last updated 7 months ago by GraHal.
-
-
02/06/2018 at 3:29 PM #61719
Hi all, I have a question related to the placement of stops and targets when a strategy cumulates positions.
Here is a simple code:
1234567891011121314151617181920// Definition of code parametersDEFPARAM CumulateOrders = True // Cumulating positions activated// Conditions to enter long positionsindicator1 = RSI[2](close)c1 = (indicator1 CROSSES UNDER 5)if barindex - tradeindex = 0 thenSL = lowest[5](low)TGT = 6*(tradeprice-SL)endifIF c1 THENBUY 1 CONTRACT AT high+1 stopset target profit TGTENDIFIF longonmarket THENsell at SL stopENDIFWith this code, every time a position is added to an existing position, it changes the previously set target and stop of the previous position.
Anybody an idea how you can add a stop and target to an “add” position, without messing with the previous position its stop and target?
02/06/2018 at 4:10 PM #61731With an IG or PRT-CFD account, you can use %PROFIT and %LOSS, it should add individual takeprofit and stoploss for each order.
2 users thanked author for this post.
02/06/2018 at 5:49 PM #6174702/06/2018 at 6:39 PM #6175602/06/2018 at 7:26 PM #6177502/06/2018 at 7:44 PM #61777I don’t think so, because condition at line 8 is only true during 1 period.
You are right, lines 9 and 10 do not recalculate TGT and SL after every bar, but only in those bars, when a new position has just been opened (barindex – tradeindex = 0).
But still, these new values for TGT and SL are then applied later to all open positions, in line 15 only when c1 is true, and in line 19 all the time, as far as I see it.
02/06/2018 at 8:06 PM #61779Also, there is a fundamental difference between the commands
1set target profit TGTand
1sell at SL stopwhich is not well explained in the manual.
1set target profit TGTsets the target price by TGT units away from the opening price of each open individual position. So, each position will have the same difference between its opening and target price, which will be TGT. But all positions will have different values of their target prices, whenever their opening prices are different.
On the other hand, the command
1sell at SL stopwill set the same exit price SL for all positions, irrespective of their individual opening prices. All open positions will have the same absolute stop price SL, which can be altered several times in line 19 during the course of the system.
3 users thanked author for this post.
02/06/2018 at 9:28 PM #61783Sorry to say this, @nicolas, but I think I just found another quite serious PRT bug, dealing with the “set target pprofit” commands, when multiple positions are open.
The English manual says on page 12 :
SET TARGET PROFIT x: Set a profit target to close the position x units from the average position price.
So, when multiple positions are open, and we say : “set target pprofit 20”, this should mean that a single average limit 20 points away from the average position price of all positions will be set, not different limits for every position 20 points away from the different position prices.
But : now here comes reality.
Take this little test system (I really do like them, meanwhile) :
test system for1234567891011121314151617// test system for "set target pprofit" bug// DAX 1 minute chartdefparam cumulateorders = trueONCE TI = 0If barindex = TI + 20 thenbuy 1 contract at marketTI = barindexendifset target pprofit 20set stop ploss 20If positionprice <> 0 thengraph positionpriceendifThis system buys a new position every 20 bars, irrespective of what happens. It sets a stop loss of 20 points and a target profit of 20 points, too. Backtest has been done with a spread of 1 point.
According to the manual, this should set at least the target 20 points away from the average position price, when multiple positions are open.
It remains unclear in the manual whether the stop loss will be set 20 points away from each individual position price, or 20 points away from the average position price.
But here, we deal only with the target price, now :
Take the chart and look at the date 01.02.2018, TIME = 8:00. At this time, 19 open positions are closed and their target profit is taken.
According to the manual, this should happen 20 points away from the average position price, which was 13229,7 at this time (for all 19 positions). So, all 19 positions should be closed at the same price of 13249,7
But now look at the chart : It reports that all positions have been closed at 8:00 at different exit prices, all 20 points away from their individual opening price, not 20 points away from the average position price :
The backtest report tells us the same different exit prices for these 19 positions, 20 points away from their entry price :
Because all of these positions are reported to have been closed 20 points away from their entry price, their results should be + 20,00 € for all of them.
However, in the list of all closed positions in the same backtest report, all of these 19 positions are shown to have different results, as if they would indeed have been closed at the same price, 20 points away from an average position price !!
Now, what is true in reality ? The command “set target pprofit x” : does it close multiple positions all at the same target price, x points away from the average position price, or does it close them all at different individual prices, x points away from their individual opening price ?
The backtest report and the chart say all different things together at the same time, unfortunately.
1 user thanked author for this post.
02/06/2018 at 9:32 PM #61789Addendum : What about the “set stop ploss x” command for multiple positions ?
Does it set the stop x points away from the individual opening price of each single position, or does it set a combined stop loss 20 points away from the average position price ?
Unfortunately, this is not clear to me at this time anymore.
02/06/2018 at 10:01 PM #61794To make things a little clearer, I redisplay figure 1 once again, with the entry prices of all 19 positions highlighted:
Now you can clearly see that all positions are reported to have been closed exactly 20 points away from their entry price.
But the backtest reports different results for all of them, from 10,96 € to 27,46 €. What is true, now ?
02/06/2018 at 10:47 PM #61801The same mess for the command “set stop ploss 20” also, tested with the same code as above.
DAX 1 minute chart.
On 29.01.2018, 21:40:00, three positions are closed by running into the stop :
In the chart, all three positions are reported to have been closed exactly 20 points away from their entry price. So they all should have a result of -20,00 €.
However, the backtest reports three different results for them, between -15,87 € and -17,37 € :
Do we have the same problem here ??
Also, the duration of these positions seems to be wrong; it cannot be 9, 0 and 0 bars as the backtest report says, but it is longer. What is wrong here ?
02/06/2018 at 11:03 PM #6181002/06/2018 at 11:34 PM #61818@ilaria : Please read my posts above and forward them to your team, so they can correct (or explain) the bugs I described. And please, give us further information as to what the commands
set target pprofit xx
and
set stop ploss xx
really do, when multiple positions are open. The manual and the backtest results are entirely inconsistent, in this regard.
02/07/2018 at 8:49 AM #61825It’s not a bug. Your assumption is true but for IG or PRT CFD, not with prorealtime software and its paper trading where profits and losses are set with the average position price. The documentation is talking about how prorealtime handle it,not how broker are dealing with these price levels. However I think that to be perfectly clear, an addendum should be added to the documentation, you are right.
02/07/2018 at 9:28 AM #61828It’s not a bug. Your assumption is true but for IG or PRT CFD, not with prorealtime software and its paper trading where profits and losses are set with the average position price. The documentation is talking about how prorealtime handle it,not how broker are dealing with these price levels. However I think that to be perfectly clear, an addendum should be added to the documentation, you are right.
And so how about all the inconsistencies in the backtest reports ? Positions that should have -20 € result are shown to have -15,67 € ?? And when in fact they have a duration of 23 bars, they are shown with 0 bars ? No bug ? Please…
The backtest does not know any broker, Nicolas.
It is a clear bug, as the backtests above show. They are full of errors.
Clear question : Where does
set target pprofit 20
set the limits of multiple positions ?
20 points away from an individual position price, or 20 points away from the average position price ?
Everyone using PRT software needs to know this.
And the backtest errors and inconsistencies need to be removed.
-
AuthorPosts
Find exclusive trading pro-tools on