EL Bullish Breakout

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #254121 quote
    frilyas
    Participant
    New

    Hello everyone,

    I am about to take the plunge and switch mainly to ProRealTime after a long absence from trading. I do not have much experience in coding and automation, and I would like to transfer the tools I used on NanoTrader previously.

    For this reason, I need help recoding a strategy that I used on Nanotrader, the express code for which is attached:

    EL_Bullish_Breakout2.txt
    #254129 quote
    robertogozzi
    Moderator
    Master
    I slightly modified the title to make it more meaningful for readers.
    #254139 quote
    Iván González
    Moderator
    Master
    Hi. Here you have.
    //------------------------------------------
    // PRC_EL Bullish Breakout
    // version = 0
    // 02.12.2025
    // Iván González @ www.prorealcode.com
    // Sharing ProRealTime knowledge
    //------------------------------------------
    // --- Parameters ---
    //------------------------------------------
    Smooth = 3
    Mini = 4
    Maxi = 19
    Prolong = 10
    MaxHighInclination = 500
    EntryStrategy = 1
    //------------------------------------------
    // --- State Variables ---
    //------------------------------------------
    ONCE currentSlope = 0
    ONCE lineActive = 0
    ONCE extensionCount = 0
    // Initialize with Close to avoid visual jumps if used prematurely
    ONCE lastValidLineVal = Close
    // ---------------------------------------------------------------------
    // 1. PIVOT DETECTION
    // ---------------------------------------------------------------------
    isPivot = 0
    pivotBar = 0
    pivotPrice = 0
    
    // Detection logic based on 'Smooth' parameter
    IF Smooth = 1 THEN
    IF High[1] >= High[2] AND High[1] > High THEN
    isPivot = 1
    pivotBar = BarIndex[1]
    pivotPrice = High[1]
    ENDIF
    ELSIF Smooth = 2 THEN
    IF High[2] >= High[3] AND High[2] >= High[4] AND High[2] > High[1] AND High[2] > High THEN
    isPivot = 1
    pivotBar = BarIndex[2]
    pivotPrice = High[2]
    ENDIF
    ELSIF Smooth = 3 THEN
    IF High[3] >= High[4] AND High[3] >= High[5] AND High[3] >= High[6] AND High[3] > High[2] AND High[3] > High[1] AND High[3] > High THEN
    isPivot = 1
    pivotBar = BarIndex[3]
    pivotPrice = High[3]
    ENDIF
    ENDIF
    
    // Manage the simulated pivot array (FIFO)
    IF isPivot = 1 THEN
    H5 = H4
    BarH5 = BarH4
    H4 = H3
    BarH4 = BarH3
    H3 = H2
    BarH3 = BarH2
    H2 = H1
    BarH2 = BarH1
    H1 = pivotPrice
    BarH1 = pivotBar
        
    // When a new pivot is found, reset active search to re-evaluate
    lineActive = 0
    ENDIF
    
    // ---------------------------------------------------------------------
    // 2. LINE CALCULATION AND VALIDATION
    // ---------------------------------------------------------------------
    isValidLine = 0
    chosenH = 0
    chosenBarH = 0
    finalSlope = 0
    
    // Only process if there is a new pivot H1 and an existing historical H2
    IF isPivot = 1 AND H2 > 0 THEN
        
    // --- Attempt 1: Connect H1 with H2 ---
    distH2 = BarH1 - BarH2
        
    IF distH2 >= Mini AND distH2 <= Maxi AND H2 >= H1 THEN
            
    tempSlope = (H1 - H2) / distH2
    isClean = 1
            
    // Cleanliness validation (no intermediate candle crosses the line)
    FOR i = 1 TO (distH2 - 1) DO
    // Calculate theoretical line price in the past
    theoreticalPrice = H2 + (tempSlope * i)
    // Index of the candle to check (from H2 moving forward)
    checkIndexOffset = (BarIndex - BarH2) - i
                
    IF High[checkIndexOffset] > theoreticalPrice THEN
    isClean = 0
    BREAK
    ENDIF
    NEXT
            
    // Slope validation (x100000 to normalize FX/Indices scale)
    slopeFactor = (tempSlope * 100000) / Close
    validSlope = 0
    IF slopeFactor <= MaxHighInclination THEN
    validSlope = 1
    ENDIF
            
    IF isClean = 1 AND validSlope = 1 THEN
    isValidLine = 1
    chosenH = H2
    chosenBarH = BarH2
    finalSlope = tempSlope
    ENDIF
    ENDIF
        
    // --- Attempt 2: Connect H1 with H3 (if H2 failed) ---
    IF isValidLine = 0 AND H3 > 0 THEN
    distH3 = BarH1 - BarH3
    IF distH3 >= Mini AND distH3 <= Maxi AND H3 >= H1 THEN
    tempSlope = (H1 - H3) / distH3
    isClean = 1
                
    FOR i = 1 TO (distH3 - 1) DO
    theoreticalPrice = H3 + (tempSlope * i)
    checkIndexOffset = (BarIndex - BarH3) - i
                    
    IF High[checkIndexOffset] > theoreticalPrice THEN
    isClean = 0
    BREAK
    ENDIF
    NEXT
                
    slopeFactor = (tempSlope * 100000) / Close
    validSlope = 0
    IF slopeFactor <= MaxHighInclination THEN
    validSlope = 1
    ENDIF
                
    IF isClean = 1 AND validSlope = 1 THEN
    isValidLine = 1
    chosenH = H3
    chosenBarH = BarH3
    finalSlope = tempSlope
    ENDIF
    ENDIF
    ENDIF
    
    // --------------------------------------------------------
    // START PROJECTION
    // --------------------------------------------------------
    IF isValidLine = 1 THEN
    currentSlope = finalSlope
    lineActive = 1
    extensionCount = Prolong
            
    // 1. Draw Solid Line (History)
    DRAWSEGMENT(chosenBarH, chosenH, BarH1, H1) COLOURED(0,0,0) STYLE(line, 2)
            
    // 2. Fill the "Lag" gap from Smooth parameter
    currentDist = BarIndex - BarH1
    currentResVal = H1 + (currentSlope * currentDist)
            
    // Draw the first dotted segment from Pivot H1 to RIGHT NOW
    DRAWSEGMENT(BarH1, H1, BarIndex, currentResVal) COLOURED(0, 200, 0) STYLE(dottedline, 2)
            
    // 3. Initialize the value for the NEXT candle
    lastValidLineVal = currentResVal
    ENDIF
    
    ENDIF
    
    // ---------------------------------------------------------------------
    // 3. CONTINUOUS PROJECTION DRAWING AND SIGNALS
    // ---------------------------------------------------------------------
    buySignal = 0
    resValue = 0
    
    // Only enter here if line is active AND it is NOT the candle where we just detected the pivot
    IF lineActive = 1 AND extensionCount > 0 AND isPivot = 0 THEN
        
    // Step-by-step projection (Previous candle -> Current candle)
    resValue = lastValidLineVal + currentSlope
        
    // Draw continuous projection
    DRAWSEGMENT(BarIndex[1], lastValidLineVal, BarIndex, resValue) COLOURED(0, 200, 0) STYLE(dottedline, 2)
        
    // Update for the future
    lastValidLineVal = resValue
        
    // Breakout Entry Logic
    isBreakout = 0
    IF EntryStrategy = 1 THEN
    // Close crosses over
    IF Close CROSSES OVER resValue THEN
    isBreakout = 1
    ENDIF
    ELSIF EntryStrategy = 2 THEN
    // High crosses over and Close is higher
    IF High CROSSES OVER resValue AND Close > resValue THEN
    isBreakout = 1
    ENDIF
    ENDIF
        
    IF isBreakout = 1 THEN
    buySignal = 1
    // Disable line after breakout
    lineActive = 0
            
    // Draw visual signal
    DRAWARROWUP(BarIndex, Low - AverageTrueRange[14](Close)) COLOURED(0, 155, 0)
    ENDIF
        
    // Decrease candle counter
    extensionCount = extensionCount - 1
        
    IF extensionCount = 0 THEN
    lineActive = 0
    ENDIF
        
    ENDIF
    
    RETURN
    robertogozzi thanked this post
    #254210 quote
    frilyas
    Participant
    New
    Hello, Ivan, I really want to thank you, you are really nice. Please accept the gratitude of an old man who has just arrived from the world of Nanotrader and is embarking on the ProRealTime journey, but who is not very good at coding and programming, especially with ProBuilder. I used a lot of tools available on NanoTrader that I would like to find on ProRealTime. Thank you again. Kind regards,
    Iván González thanked this post
    #254212 quote
    frilyas
    Participant
    New
    The same goes for robertogozzi; thank you too.
    robertogozzi thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

TradingView to ProRealTime Translation Center

New Reply
Author
author-avatar
frilyas @frilyas Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by frilyas
2 months, 3 weeks ago.

Topic Details
Forum: TradingView to ProRealTime Translation Center Forum
Started: 12/01/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...