End of day breakout

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14939 quote
    prolfsprolfs
    Participant
    Junior

    Hi Everybody,

    I have a simple breakout strategy that I am trying to code in PRT, but I’m struggling a bit with the ATR-stop loss and the position sizing (also uses ATR). I haven’t even attempted the position size part yet, as the system is closing orders at strange times…

    Here is the code and attached is a photo of the rules.

    Hope you can help me!

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    //variables
    positionsize=2
    fastMA=50
    slowMA=100
    DonchOpen=50
    
    // Conditions to enter long positions
    C1 = close > Highest[DonchOpen](high[1])
    indicator1 = ExponentialAverage[fastMA](close)
    indicator2 = ExponentialAverage[slowMA](close)
    C2 = (indicator1 > indicator2)
    if C1 and C2 then
    BUY positionsize PERPOINT AT MARKET
    endif
    
    // Conditions to exit long positions
    highpoint=max(tradeprice,Highest[DonchOpen](high[1]))
    atr = averagetruerange[100]*3
    SL1 = highpoint - atr
    if longonmarket then
    sell at SL1 stop
    endif
    
    // Conditions to enter short positions
    C4 = close < lowest[DonchOpen](low[1])
    indicator1 = ExponentialAverage[fastMA](close)
    indicator2 = ExponentialAverage[slowMA](close)
    c5 = (indicator1 < indicator2)
    if c4 and c5 then
    sellshort positionsize PERPOINT AT MARKET
    endif
    
    // Conditions to exit short positions
    lowpoint=min(tradeprice,lowest[DonchOpen](low[1]))
    atr = averagetruerange[100]*3
    SL2 = lowpoint + atr
    if shortonmarket then
    sell at SL2 stop
    endif
    Clen-breakout-rules.png Clen-breakout-rules.png
    #35309 quote
    DANYDANY
    Participant
    Senior

    Just with a bit of late, sorry 😐

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    //variables
    positionsize=2
    fastMA=ExponentialAverage[50](close)
    slowMA=ExponentialAverage[100](close)
    AVGTRLong=averagetruerange[100]
    DonchOpen=50
    
    // Conditions to enter long positions
    LGC1 = close > Highest[DonchOpen](high[1])
    LGC2 = (fastMA > slowMA)
    
    if Not LongOnMarket AND (LGC1 and LGC2) then
    BUY positionsize CONTRACT AT MARKET
    LGatr = AVGTRLong*3
    endif
    
    // Conditions to exit long positions
    if longonmarket then
    LGsl = tradeprice - LGatr
    //Graph tradeprice as "tradeprace"
    //Graph LGatr as "LGatr"
    //Graph LGsl as "LGsl"
    sell at LGsl stop
    endif
    
    // Conditions to enter short positions
    SHC1 = close < lowest[DonchOpen](low[1])
    SHC2 = (fastMA < slowMA)
    if Not ShortOnMarket AND SHC1 and SHC2 then
    sellshort positionsize CONTRACT AT MARKET
    SHatr = AVGTRLong*3
    endif
    
    // Conditions to exit short positions
    if shortonmarket then
    SHsl = tradeprice + SHatr
    Graph tradeprice as "tradeprace"
    Graph SHatr as "SHatr"
    Graph SHsl as "SHsl"
    exitshort at SHsl stop
    endif
Viewing 2 posts - 1 through 2 (of 2 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

End of day breakout


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
prolfs @prolfs Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by DANYDANY
9 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/15/2016
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...