Breakout Algo not closing trades

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #160851 quote
    Mitchy14Mitchy14
    Participant
    Average

    Evening all,

    Slightly embarrassed by the ‘amateurish’ nature of this code but…

    I wondered if I could ask for some help regarding my algo not closing trades relating (specifically) to my breakout criteria (a and b). It seems to close them based on the RSI I use, but not my a or b formula.  Even when I ask it to lookback 1 period (close[1] < b) removing the majority of the Exit criteria it still doesn’t close any trades relating to a or b formulas – however, it does close when I only include this period (for instance, close > b).

    Is it due to the ‘lookback’ nature of the a/b formulas?

    Appreciate your help with this and apologise for the rookie format.

    Best,

    Tom

    // Prevents the system from placing new orders on specified days of the week
    
    DEFPARAM cumulateOrders = FALSE // Cumulating positions
    
    AA = period
    
    // Breakout criteria
    
    a = highest[AA](high[1])//Max
    b = lowest[AA](low[1])//Min
    
    
    ATR = AverageTrueRange[2](close)
    
    // Conditions to enter long positions
    indicator1 = Average[100](close)
    c1 = (close > indicator1)
    indicator2 = RSI[2](close)
    c2 = (indicator2 > 70)
    c3 = (close > a)
    c4 = (close[1] > a)
    c5 = (open > open[2])
    
    IF not SHORTONMARKET AND (c1 AND c2 AND c3 AND c4 AND c5) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter long positions  #2
    indicator5 = Average[100](close)
    c6 = (close < indicator5)
    indicator6 = RSI[2](close)
    c7 = (indicator6 > 50)
    c8 = (close > b)
    c9 = (close[1] > b)
    
    
    IF not SHORTONMARKET AND c6 AND c7 AND c8 AND c9 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    c10 = (close < a)
    c11 = (close[1] > a)
    c12 = (close[2] > a)
    c13 = (high < a)
    c14 = (high[1] > a)
    
    IF c10 AND c11 AND c12 AND c13 AND c14 THEN
    SELL AT MARKET
    ENDIF
    
    
    // Conditions to enter short positions
    indicator10 = Average[100](close)
    c15 = (close > indicator10)
    indicator11 = RSI[2](close)
    c16 = (indicator11 < 50)
    c17 = (close < a)
    c18 = (close[1] < a)
    
    IF not LONGONMARKET AND (c15 AND c16 AND c17 AND c18) THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    //Conditions to enter short positions #2
    indicator14 = Average[100](close)
    c19 = (close < indicator14)
    indicator15 = RSI[2](close)
    c20 = (indicator15 < 40)
    c21 = (close < b)
    c22 = (close[1] < b)
    c23 = (open < open[2])
    
    IF not SHORTONMARKET AND c19 AND c20 AND c21 AND c22 AND c23 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    c24 = (close > b)
    c25 = (close[1] < b)
    c26 = (low > b)
    c27 = (low[1] < b)
    c28 = (low[2] < b)
    
    
    IF c24 AND c25 AND c26 AND c27 AND c28 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    If (indicator2 > 95) Then
    Sell at market
    ElsIf ((close > close[1] + ATR) or SHORTONMARKET) and indicator2 < 5 Then
    Exitshort at market
    EndIf
    #160856 quote
    GraHalGraHal
    Participant
    Legend

    You should use GRAPH and check that your several coincidents exit conditions are being triggered at same time?

    GRAPH

    Mitchy14 thanked this post
    #160901 quote
    Mitchy14Mitchy14
    Participant
    Average

    Hi GraHal,

    Appreciate the insight – wasn’t even aware of this feature.

    I’ll check it out.

    Best

    Tom

    GraHal thanked this post
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

Breakout Algo not closing trades


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mitchy14 @mitchy14 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/09/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...