Cumulate orders and stops & targets

Forums ProRealTime English forum ProOrder support Cumulate orders and stops & targets

Viewing 15 posts - 1 through 15 (of 33 total)
  • #61719
    Seb

    Hi all, I have a question related to the placement of stops and targets when a strategy cumulates positions.

    Here is a simple code:

    With 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?

    #61731

    With 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.
    #61747

    Hi!

    so if i use

    set stop $loss 100

    then max loss for all contracts is 100?

    regards

    Henrik

    #61756

    Your problem is also that your code constantly recalculates SL and TGT. This is why the stop level is changed in every bar for all open positions, and the target level each time when c1 is true.

    #61775

    I don’t think so, because condition at line 8 is only true during 1 period.

    #61777

    I 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.

    #61779

    Also, there is a fundamental difference between the commands

    and

    which is not well explained in the manual.

     

    sets 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

    will 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.
    #61783

    Sorry 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) :

    This 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 :

    Bild1

    The backtest report tells us the same different exit prices for these 19 positions, 20 points away from their entry price :

    Bild2

    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 !!

    Bild3

    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.
    #61789

    Addendum : 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.

    #61794

    To make things a little clearer, I redisplay figure 1 once again, with the entry prices of all 19 positions highlighted:

    Bild4

    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 ?

    #61801

    The 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 :

    Bild6

    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 € :

    Bild7a

    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 ?

    #61810

    In my post #61783 above, the duration of the wrongly reported positions in the backtest is wrong, too; they are all displayed as 0 bars, but in fact, they are much longer.

    See the last figure at the bottom of this post #61783.

    #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.

    2 users thanked author for this post.
    #61825

    It’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.

    #61828

    It’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.

     

Viewing 15 posts - 1 through 15 (of 33 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login