ATR trailing stop exit problem

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #57580 quote
    rdcarvajalrdcarvajal
    Participant
    New

    Hi,

    I have been learning the PRT-language for coding a proven system that i currently trade manually on daily bars. I have done a Montecarlo and it should work on other timeframes hence the need for automated trading . I use an ATR-trailing stop and when price during the day touches the ATR-trail it gets out of the position. The problem i have is that ProOrder always exits on the next candle, which is a big problem since it can lead to bigger losses. I know there is no way around this when using the EXIT command, but i think there might be a solution with some sort of adaptive stop (or trailing stop) that changes as the trade progresses, I just haven’t been able to work around it. Please have a look at the attached graph for better understanding.

    Any help will be greatly appreciated. Thank you.

    This is a simplified sample code for reference.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = ExponentialAverage[8](close)
    indicator2 = ExponentialAverage[50](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 5 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = CALL "2ATR trailing stop"
    c2 = (low < indicator3)
    StopLoss=Close[1]-indicator3[1]
    
    IF c2 THEN
    SET STOP TRAILING StopLoss
    ENDIF
    ATR-trailing.png ATR-trailing.png
    #57609 quote
    VonasiVonasi
    Moderator
    Master

    Use a SELL STOP at the chosen price.

    SELL at <your chosen price> STOP
    #57670 quote
    rdcarvajalrdcarvajal
    Participant
    New

    Hi Vonasi:

    It worked! and so simple… Thanks a lot.

    Cheers,

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

ATR trailing stop exit problem


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rdcarvajal @rdcarvajal Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by rdcarvajalrdcarvajal
8 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/07/2018
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...