Three Step Future Trend Indicator

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #247352 quote
    LucasBest
    Participant
    Junior

    If someone who have some extra times and a very good knowledge in PRT and TV, can translate it, i would really appreciate.

    Three Step Future-Trend [BigBeluga]
    https://fr.tradingview.com/v/ay15DZnZ/

    // 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('Three Step Future-Trend [BigBeluga]', overlay = true)
    
    
    // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
    int period = input.int(25, 'Period')
    color color_up = input.color(color.lime, 'UP', inline = 'c')
    color color_dn = input.color(#d42583, 'DOWN', inline = 'c')
    // }
    
    
    
    // CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
    draw_boxes(period, color1, color2, color3) =>
        float H = ta.highest(50)
        float L = ta.lowest(50)
        var boxes = array.new<box>()
    
        if barstate.islast
    
            for i = 0 to 2 by 1
                int index1 = period * (i > 0 ? i + 1 : 1)
                int index2 = period * i
                color color = i == 0 ? color1 : i == 1 ? color2 : color3
                box1 = box.new(bar_index - index1 + 1, H[index2], bar_index - period * i, L[index2], bgcolor = color.new(color, 90), border_color = color, border_width = 2, text = str.tostring(index1) + ' - ' + str.tostring(index2), text_size = size.large, text_color = chart.fg_color, text_halign = text.align_right, text_valign = color == color_up ? text.align_bottom : text.align_top)
    
                boxes.push(box1)
    
                if boxes.size() > 3
                    box.delete(boxes.shift())
    
    future_trend(period, src) =>
        var color = color(na)
        var delta1 = float(na)
        var delta2 = float(na)
        var delta3 = float(na)
        var total1 = float(na)
        var total2 = float(na)
        var total3 = float(na)
    
        array<float> values = array.new<float>(period + 1)
        array<float> delta = array.new<float>(period + 1)
    
        array<chart.point> future_trend = array.new<chart.point>(period + 1)
    
        delta_vol = close > open ? volume : -volume
    
        delta1 := math.sum(delta_vol, period)
        delta2 := math.sum(delta_vol, period * 2) - delta1
        delta3 := math.sum(delta_vol, period * 3) - delta1 - delta2
    
        total1 := math.sum(volume, period)
        total2 := math.sum(volume, period * 2) - total1
        total3 := math.sum(volume, period * 3) - total1 - total2
    
        color color1 = delta1 > 0 ? color_up : color_dn
        color color2 = delta2 > 0 ? color_up : color_dn
        color color3 = delta3 > 0 ? color_up : color_dn
    
    
        if barstate.islast
            for i = 0 to period by 1
                values.set(i, math.avg(src[i], src[i + period], src[i + period * 2]))
                delta.set(i, math.avg(delta_vol[i], delta_vol[i + period], delta_vol[i + period * 2]))
    
    
            values.reverse()
    
            series float diff = src - values.first()
            series float vol_delta = delta.avg()
    
            for i = 0 to period by 1
                future_trend.set(i, chart.point.from_index(bar_index + i, diff + values.get(i)))
    
            color := vol_delta > 0 ? color_up : color_dn
    
            polyline.delete(polyline.new(future_trend, true, line_color = color, line_width = 2)[1])
            label lb1 = label.new(future_trend.last(), style = label.style_label_left, color = color)
    
            lb1.set_text(str.tostring(vol_delta, format.volume) + '\n' + str.tostring(lb1.get_y(), '#,###.##'))
            label.delete(lb1[1])
    
            table dash = table.new(position.bottom_right, 10, 10, frame_color = color, bgcolor = color.new(color, 90), frame_width = 2, border_color = color.new(chart.fg_color, 70), border_width = 1)
            for i = 0 to 2 by 1
                index1 = period * (i > 0 ? i + 1 : 1)
                index2 = period * i
                dash.cell(0, i + 2, str.tostring(index1) + ' - ' + str.tostring(index2), text_color = chart.fg_color)
    
            dash.merge_cells(0, 0, 2, 0)
            dash.cell(0, 0, 'Volume Data', text_color = color.new(chart.fg_color, 50))
            dash.cell(1, 2, str.tostring(delta1, format.volume), text_color = color1)
            dash.cell(1, 3, str.tostring(delta2, format.volume), text_color = color2)
            dash.cell(1, 4, str.tostring(delta3, format.volume), text_color = color3)
    
            dash.cell(2, 2, str.tostring(total1, format.volume), text_color = color.new(chart.fg_color, 20))
            dash.cell(2, 3, str.tostring(total2, format.volume), text_color = color.new(chart.fg_color, 20))
            dash.cell(2, 4, str.tostring(total3, format.volume), text_color = color.new(chart.fg_color, 20))
            dash.cell(0, 1, 'Period', text_color = color.new(chart.fg_color, 0))
            dash.cell(1, 1, 'Delta', text_color = color.new(chart.fg_color, 0))
            dash.cell(2, 1, 'Total', text_color = color.new(chart.fg_color, 0))
    
    
    
        draw_boxes(period, color1, color2, color3)
        // }
    
    
    
    // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
    future_trend(period, close)
    // }
    
    #247364 quote
    Iván González
    Moderator
    Master

    Hi. I’ll try to translate it.
    For future posts, please use titles that are related to the content so that other users can benefit from searches.
    I’ve changed it.

    LaMaille thanked this post
    #247381 quote
    Iván González
    Moderator
    Master

    Here you have:

    //---------------------------------------------------//
    //PRC_Three Step Future-Trend
    //version = 0
    //20.05.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //---------------------------------------------------//
    // INPUTS
    //---------------------------------------------------//
    defparam drawonlastbaronly = true
    period = 25
    deltaVolume = 0
    
    IF close > open THEN
    deltaVolume = volume
    ELSE
    deltaVolume = -volume
    ENDIF
    
    // === DELTA PER BLOCK ===
    delta1 = summation[period](deltaVolume)
    delta2 = summation[period * 2](deltaVolume) - delta1
    delta3 = summation[period * 3](deltaVolume) - delta1 - delta2
    
    // === TOTAL VOLUME PER BLOCK ===
    total1 = summation[period](volume)
    total2 = summation[period * 2](volume) - total1
    total3 = summation[period * 3](volume) - total1 - total2
    
    // === COLORS BASED ON TREND ===
    IF delta1 > 0 THEN
    red1 = 0
    green1 = 230
    blue1 = 118
    ELSE
    red1 = 212
    green1 = 37
    blue1 = 131
    ENDIF
    
    IF delta2 > 0 THEN
    red2 = 0
    green2 = 230
    blue2 = 118
    ELSE
    red2 = 212
    green2 = 37
    blue2 = 131
    ENDIF
    
    IF delta3 > 0 THEN
    red3 = 0
    green3 = 230
    blue3 = 118
    ELSE
    red3 = 212
    green3 = 37
    blue3 = 131
    ENDIF
    
    // === VOLUME BLOCK VISUALIZATION ===
    // Box 1 (most recent)
    left1 = barindex - period
    right1 = barindex
    top1 = highest[50](high)
    bot1 = lowest[50](low)
    drawrectangle(left1, top1, right1, bot1) coloured(red1, green1, blue1) fillcolor(red1, green1, blue1, 30)
    
    // Box 2 (previous)
    left2 = barindex - period * 2
    right2 = barindex - period
    top2 = highest[50](high)[period]
    bot2 = lowest[50](low)[period]
    drawrectangle(left2, top2, right2, bot2) coloured(red2, green2, blue2) fillcolor(red2, green2, blue2, 30)
    
    // Box 3 (oldest)
    left3 = barindex - period * 3
    right3 = barindex - period * 2
    top3 = highest[50](high)[period * 2]
    bot3 = lowest[50](low)[period * 2]
    drawrectangle(left3, top3, right3, bot3) coloured(red3, green3, blue3) fillcolor(red3, green3, blue3, 30)
    
    // === FUTURE TREND PROJECTION ===
    refValue = (close[0] + close[period] + close[period * 2]) / 3
    IF islastbarupdate THEN
    cumDelta = 0
    FOR i = 0 TO period DO
    $Value[i] = (close[i] + close[i + period] + close[i + period * 2]) / 3
    $delta[i] = (deltaVolume[i] + deltaVolume[i + period] + deltaVolume[i + period * 2]) / 3
    cumDelta = cumDelta + $delta[i]
    NEXT
    FOR j = 0 TO period DO
    $ValueRev[j] = $Value[period - j]
    NEXT
    diff = close - $ValueRev[0]
    voldelta = cumDelta / period
    IF voldelta > 0 THEN
    r = 0
    g = 230
    b = 118
    ELSE
    r = 212
    g = 37
    b = 131
    ENDIF
    FOR k = 0 TO period DO
    $futureIdx[k] = barindex + k
    $futurePrice[k] = diff + $ValueRev[k]
    drawsegment($futureIdx[k + 1], $futurePrice[k + 1], $futureIdx[k], $futurePrice[k]) coloured(r, g, b)
    NEXT
    
    // === DATA TABLE ===
    // Delta Volume
    drawrectangle(-300, -80, -10, -180) anchor(topright, xshift, yshift)fillcolor(r,g,b,30)
    drawtext("Period", -250, -100) anchor(topright, xshift, yshift)
    drawtext("Delta", -150, -100) anchor(topright, xshift, yshift)
    drawtext("Total", -50, -100) anchor(topright, xshift, yshift)
    drawtext("25-0", -250, -120) anchor(topright, xshift, yshift)
    drawtext("#delta1#", -150, -120) anchor(topright, xshift, yshift)
    drawtext("#total1#", -50, -120) anchor(topright, xshift, yshift)
    drawtext("50-25", -250, -140) anchor(topright, xshift, yshift)
    drawtext("#delta2#", -150, -140) anchor(topright, xshift, yshift)
    drawtext("#total2#", -50, -140) anchor(topright, xshift, yshift)
    drawtext("75-50", -250, -160) anchor(topright, xshift, yshift)
    drawtext("#delta3#", -150, -160) anchor(topright, xshift, yshift)
    drawtext("#total3#", -50, -160) anchor(topright, xshift, yshift)
    // Proyected Price
    FuturePrice=$futurePrice[period]
    drawtext("Proyected Price",-220,-200)anchor(topright,xshift,yshift)
    drawtext("#FuturePrice#",-75,-200)anchor(topright,xshift,yshift)
    drawrectangle(-300,-220,-10,-180)anchor(topright,xshift,yshift)fillcolor(r,g,b,30)
    ENDIF
    //---------------------------------------------------//
    return
    robertogozzi and LucasBest thanked this post
    #247402 quote
    LucasBest
    Participant
    Junior

    Wow that was quick and well done! Muchas gracias Iván

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

Three Step Future Trend Indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
LucasBest @lucasbest Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/19/2025
Status: Active
Attachments: No files
Logo Logo
Loading...