Stop order works in backtest but not for real – PLEASE IGNORE

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #138877 quote
    teapot2002
    Participant
    Average

    SORRY, PLEASE IGNORE THIS! I can’t see how to delete it. I think that I stopped it from running automatically, so no wonder it didn’t move the stop order.

    In my PRT code I have some profit management which is meant to set a stop at breakeven, copied from a post on this forum. This works in backtesting, but today it failed when running on the real platform, so my trade lost when it would have broken even had the stop order worked. Does anyone have any ideas, please?

    I’ve pasted in the profit management code below. I know that this doesn’t quite make sense with PointsToKeep being zero, but I wanted to post exactly what’s running.

    You can see that PRT exits at the Breakeven level, but the trade running on the platform didn’t do this.

    InProfit = 18  
    InProfitShort = 38
    PointsToKeep = 0 //how many points to keep in profit above or below our entry price when the breakeven is activated (beware of spread) - optimised
    PointsToKeepShort = 4
    
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
     
    // --- BUY SIDE ---
    //test if the price has moved favourably "startBreakeven" points already
    IF LONGONMARKET AND close - tradeprice >= InProfit THEN   // price has moved up a good distance
    breakevenLevel = tradeprice + PointsToKeep  // move up the stop
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF LONGONMARKET AND breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    
    graph breakevenlevel
    graph tradeprice
    // --- end of BUY SIDE ---

    The screenshot shows it working as designed in ProReal.

    I tried to add another screenshot showing the results of the trade, but that didn’t seem to work, so I’ve pasted them in below – sorry if the formatting doesn’t come out well.  The code is running in my Swiss account, which is one hour ahead of the ProReal time in the UK.

    Date           Summary         MarketName                   ProfitAndLoss  Open level    Close level     Size    Currency      PL Amount      DateUtc                               OpenDateUtc
    09/07/20 Closing trades Germany 30 Cash (€1)       -£53.35          12669.7        12560              0.54      £             -53.35                    2020-07-09T14:44:05    2020-07-09T08:10:00

    Thanks in advance.

    Screenshot-2020-07-09-at-17.58.16.png Screenshot-2020-07-09-at-17.58.16.png
    #138879 quote
    robertogozzi
    Moderator
    Master

    Did you make sure you have updated the version running in AutoTrading after you may have made some modifications in ProBackTest?

    Maybe you modified the Trailing Stop code but did not update the runnung version.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Stop order works in backtest but not for real – PLEASE IGNORE


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
teapot2002 @teapot2002 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/09/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...