Indicatore Commodity Trend Reactor per ProRealTime

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #258391 quote
    Stenozar
    Participant
    Master

    Buon pomeriggio, chiedo se si possa tradurre questo indicatore che mi pare interessante:

    // This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International  

    // https://creativecommons.org/licenses/by-nc-sa/4.0/

    // © BigBeluga


    //@version=6

    indicator(“Commodity Trend Reactor [BigBeluga]”, max_labels_count = 500)


    // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{

    len = input.int(25, “CCi Length”)

    t_len = input.int(20, “Trail Line Length”)


    upper = input.int(50, “Upper Threshold”)

    lower = input.int(-50, “Lower Threshold”)



    low_ = ta.lowest(t_len)

    high_ = ta.highest(t_len)


    cci = ta.cci(close, len)


    var trend = bool(na)

    color_bg = color(na)


    if ta.crossover(cci, upper)

      trend := true 


    if ta.crossunder(cci, lower)

      trend := false 



    if trend and trend != trend[1]

      color_bg := color.new(color.lime, 90)


    if not trend and trend != trend[1]

      color_bg := color.new(color.orange, 90)




    bgcolor(color_bg, force_overlay = true)

    bgcolor(color_bg, force_overlay = false)



    trail_line = float(na)


    if trend

      trail_line := low_

    if not trend

      trail_line := high_



    cci_col = cci < upper and cci > lower ? color.gray : cci > upper ? color.lime : cci < lower ? color.orange : na


    pt = plot(trail_line, force_overlay = true, color = trend != trend[1] ? na : (trend ? color.lime : color.orange))

    cls = plot(close, display = display.none, editable = false, force_overlay = true)


    cci_p = plot(cci, color = cci_col)

    up = plot(upper, display = display.none, editable = false)

    lw = plot(lower, display = display.none, editable = false)


    fill(cci_p, up, cci, upper, cci > upper ? color.rgb(0, 230, 119, 53) : color(na), color(na))

    fill(cci_p, lw, cci, lower, cci < lower ? color.rgb(255, 153, 0, 57) : color(na), color(na))


    fill(pt, cls, close, trail_line, color(na), trend != trend[1] ? na : (trend ? color.new(color.lime, 80) : color.new(color.orange, 80)))


    plotshape(cci > 200, “Top”, shape.square, location.top, color = color.lime)

    plotshape(cci < -200, “Bottom”, shape.square, location.bottom, color = color.orange)



    if cci > 200 

      label.new(bar_index, high, “■”, textcolor = cci_col, color = color(na), style = label.style_label_center, size = size.normal, force_overlay = true)

    if cci < -200 

      label.new(bar_index, low, “■”, textcolor = cci_col, color = color(na), style = label.style_label_center, size = size.normal, force_overlay = true)


    hline(upper, linestyle = hline.style_solid)

    hline(0)

    hline(lower, linestyle = hline.style_solid)

    #258397 quote
    Nicolas
    Keymaster
    Master

    Please post your conversion requests from TradingView to ProRealTime in this group:

    TradingView to ProRealTime Translation Center

    I’ve just transferred your topic; it will be for the next request 🙂

    #258416 quote
    Iván González
    Moderator
    Master

    Hi! Here’s the code. It needs to be separated into two parts: one goes inside the price and the other in the bottom panel.

    Price

    //-----------------------------------------------
    // PRC_Commodity Trend Reactor [BigBeluga] - CCI Oscillator
    // Display: Price chart overlay
    // version = 0
    // 23.02.2026
    // Iván González @ www.prorealcode.com
    // Sharing ProRealTime knowledge
    //-----------------------------------------------
    // --- INPUTS ---
    cciLen = 25 // CCI Length
    tLen = 20 // Trail Line Length
    upperThr = 50 // Upper Threshold
    lowerThr = -50 // Lower Threshold
    
    
    // --- CALCULATIONS ---
    lowVal = lowest[tLen](low)
    highVal = highest[tLen](high)
    cciVal = CCI[cciLen](close)
    
    
    // --- TREND DETECTION ---
    // trend: -1=undefined, 1=bullish, 0=bearish
    ONCE trend = -1
    
    
    IF cciVal crosses over upperThr THEN
    trend = 1
    ENDIF
    
    
    IF cciVal crosses under lowerThr THEN
    trend = 0
    ENDIF
    
    
    // --- TRAIL LINE + COLORS ---
    IF trend = 1 THEN
    trailLine = lowVal
    r1 = 0
    g1 = 230
    b1 = 119
    ELSIF trend = 0 THEN
    trailLine = highVal
    r1 = 255
    g1 = 153
    b1 = 0
    ELSE
    trailLine = undefined
    r1 = 128
    g1 = 128
    b1 = 128
    ENDIF
    
    
    // --- BREAK LINE ON TREND CHANGE ---
    IF trend >= 0 AND trend[1] >= 0 AND trend <> trend[1] THEN
    trailLine = undefined
    ENDIF
    
    
    // --- EXTREME CCI SIGNALS ON PRICE ---
    IF cciVal > 200 THEN
    DRAWPOINT(barindex, high, 3) COLOURED(0, 230, 119)
    ENDIF
    
    
    IF cciVal < -200 THEN
    DRAWPOINT(barindex, low, 3) COLOURED(255, 153, 0)
    ENDIF
    
    
    // --- BACKGROUND FLASH ON TREND CHANGE (optional visual) ---
    // PRT doesn't have bgcolor - using drawrectangle for 1-bar highlight
    IF trend = 1 AND trend[1] = 0 THEN
    DRAWRECTANGLE(barindex - 1, low, barindex, high) COLOURED(0, 255, 0, 220) BORDERCOLOR(0, 255, 0, 255)
    ENDIF
    
    
    IF trend = 0 AND trend[1] = 1 THEN
    DRAWRECTANGLE(barindex - 1, low, barindex, high) COLOURED(255, 153, 0, 220) BORDERCOLOR(255, 153, 0, 255)
    ENDIF
    
    
    RETURN trailLine COLOURED(r1, g1, b1) style(line, 2), close COLOURED(0, 0, 0, 0)
    

    Bottom panel

    //-----------------------------------------------
    // PRC_Commodity Trend Reactor [BigBeluga] - CCI Oscillator
    // Display: Separate oscillator panel
    // version = 0
    // 23.02.2026
    // Iván González @ www.prorealcode.com
    // Sharing ProRealTime knowledge
    //-----------------------------------------------
    // --- INPUTS ---
    cciLen = 25 // CCI Length
    upperThr = 50 // Upper Threshold
    lowerThr = -50 // Lower Threshold
    
    
    // --- CCI CALCULATION ---
    cciVal = CCI[cciLen](close)
    
    
    // --- CCI COLOR ---
    // gray when between thresholds, lime above upper, orange below lower
    IF cciVal > upperThr THEN
    rc = 0
    gc = 230
    bc = 119
    ELSIF cciVal < lowerThr THEN
    rc = 255
    gc = 153
    bc = 0
    ELSE
    rc = 128
    gc = 128
    bc = 128
    ENDIF
    
    
    // --- FILLS ---
    // Fill between CCI and upper threshold when CCI > upper
    IF cciVal > upperThr THEN
    alphaUp=100
    else
    alphaUp=0
    ENDIF
    COLORBETWEEN(cciVal, upperThr, 0, 230, 119, alphaUp)
    // Fill between CCI and lower threshold when CCI < lower
    IF cciVal < lowerThr THEN
    alphaDn=100
    else
    alphaDn=0
    ENDIF
    COLORBETWEEN(cciVal, lowerThr, 255, 153, 0, alphaDn)
    // --- EXTREME SIGNALS ---
    IF cciVal > 200 THEN
    DRAWPOINT(barindex, cciVal, 2) COLOURED(0, 230, 119)
    ENDIF
    
    
    IF cciVal < -200 THEN
    DRAWPOINT(barindex, cciVal, 2) COLOURED(255, 153, 0)
    ENDIF
    //-----------------------------------------------
    RETURN cciVal COLOURED(rc, gc, bc) style(line, 2), upperThr COLOURED(100, 100, 100) style(line, 1), lowerThr COLOURED(100, 100, 100) style(line, 1), 0 AS "Zero" COLOURED(80, 80, 80) style(dottedline, 1)
    



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

TradingView to ProRealTime Translation Center

New Reply
Author
author-avatar
Stenozar @stenozar Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Iván González
4 days, 19 hours ago.

Topic Details
Forum: TradingView to ProRealTime Translation Center Forum
Started: 02/22/2026
Status: Active
Attachments: No files
Logo Logo
Loading...