Conversion from TRading View to PRT : Fibonacci Golden wave indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #234447 quote
    Philouxp
    Participant
    New

    Hello Nico, Ivan and other,

    could you please convert this trading view indicator to PRT : Fibonacci Golden Wave?

     

    I would like backtest this indicator by combination with vwap divergence

    Details  of the fibo indicator here :

    https://www.tradingview.com/script/SWe51Ddl-Fibonacci-Golden-Wave-Flux-Charts/

    Explanations:

    Fibonacci retracement tool is typically used to find entries after a pullback in an uptrend or downtrend. The Fibonacci Golden Wave can be used in the same way. It can be used to find entries after markets retrace. In this example, the Fibonacci Golden Wave is able to catch 2 pullback opportunities to enter long in the market with the trend.

    SETTINGS
    1. General Configuration

    Swing Range -> This setting determines how the highest high / lowest low levels are calculated. This essentially means that the script will look back X bars before the current bar in calculation to find the highest / lowest wick points.

    2. Golden Zone

    Here you can select which range of the Fibonacci retracement levels should be considered as the golden zone. The default value is 0.5 – 0.618.

     

    Please see the code below:

    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

    // © fluxchart

     

     

    //@version=5

    const bool DEBUG = false

    const int maxBarsBack = 1250

    const int textBack = 2

    indicator(“Fibonacci Golden Wave | Flux Charts”, overlay = true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500, max_bars_back = 5000)

    // Settings

    pivotRange = input.int(20, “Swing Range”, group = “General Configuration”)

    usePivots = DEBUG ? input.bool(false, “Use Pivots”, group = “General Configuration”) : false

    fibArea1 = input.float(0.5, “”, options = [0.236, 0.382, 0.5, 0.618, 0.786], group = “Golden Zone”, inline = “zone”)

    fibArea2 = input.float(0.618, ” – “, options = [0.236, 0.382, 0.5, 0.618, 0.786], group = “Golden Zone”, inline = “zone”)

    gzLineColor = input.color(color.new(color.yellow, 80), “Golden Zone Lines”, group = “Style”)

    showArea = input.bool(true, “Show Area”, group = “Style”, inline = “area”)

    gzAreaColor = input.color(color.new(color.yellow, 90), “”, group = “Style”, inline = “area”)

    textSize = input.string(“Normal”, “Text Size”, options = [“Auto”, “Small”, “Normal”], group = “Style”, inline = “text”)

    textColor = input.color(color.new(color.white, 30), “”, group = “Style”, inline = “text”)

    type pivot

    bool isHigh

    float price

    int barTime

    var pivot[] highPivots = array.new<pivot>(0)

    var pivot[] lowPivots = array.new<pivot>(0)

    var box tf1Text = na

    float pivotHigh = na

    float pivotLow = na

    int pHighTime = na

    int pLowTime = na

    // SWING

    if not usePivots

    pivotHigh := ta.highest(high, pivotRange)

    pHighTime := time[math.abs(ta.highestbars(high, pivotRange))]

    pivotLow := ta.lowest(low, pivotRange)

    pLowTime := time[math.abs(ta.lowestbars(low, pivotRange))]

    else

    pivotHigh := ta.pivothigh(pivotRange, pivotRange)

    pHighTime := time[pivotRange]

    pivotLow := ta.pivotlow(pivotRange, pivotRange)

    pLowTime := time[pivotRange]

    formatTimeframeString (formatTimeframe) =>

    timeframeF = formatTimeframe == “” ? timeframe.period : formatTimeframe

    if str.contains(timeframeF, “D”) or str.contains(timeframeF, “W”) or str.contains(timeframeF, “S”) or str.contains(timeframeF, “M”)

    timeframeF

    else

    seconds = timeframe.in_seconds(timeframeF)

    if seconds >= 3600

    hourCount = int(seconds / 3600)

    str.tostring(hourCount) + ” Hour” + (hourCount > 1 ? “s” : “”)

    else

    timeframeF + ” Min”

    getFibonacciLevels (fib1, fib2) =>

    if highPivots.size() > 0 and lowPivots.size() > 0

    highPivot = highPivots.get(0)

    lowPivot = lowPivots.get(0)

    top = highPivot.price

    bottom = lowPivot.price

    difference = top – bottom

    fib050 = top – (difference * fib1)

    fib061 = top – (difference * fib2)

    [fib050, fib061]

    else

    [na, na]

    if last_bar_index – bar_index < maxBarsBack

    if not na(pivotHigh)

    highPivots.unshift(pivot.new(true, pivotHigh, pHighTime))

    if not na(pivotLow)

    lowPivots.unshift(pivot.new(false, pivotLow, pLowTime))

    fib1 = fibArea1

    fib2 = fibArea2

    [fib05, fib061] = getFibonacciLevels(fib1, fib2)

    line05 = plot(fib05, color = gzLineColor, linewidth = 1, style = plot.style_line)

    line061 = plot(fib061, color = gzLineColor, linewidth = 1, style = plot.style_line)

    fill(line05, line061, color = showArea ? gzAreaColor : na)

    if barstate.islast

    box.delete(tf1Text)

    //tf1Text := box.new(bar_index – textBack, fib05[textBack / 2], bar_index, fib061[textBack / 2], text = formatTimeframeString(timeframe.period), text_color = textColor, bgcolor = na, border_width = 0, text_size = (textSize == “Auto” ? size.auto : textSize == “Normal” ? size.normal : size.small))

     

    Thank you in advance!

    Best Regards

    #234484 quote
    Iván González
    Moderator
    Master

    Hi. Here you have the code.

    //-------------------------------------------------------------------//
    //PRC_Fibonacci Golden Wave
    //version = 0
    //13.03.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------------------------------//
    //-------------------------------------------------------------------//
    prd=20
    usepivots=0 //Boolean/ 0=Calculate Donchian Channel / 1=Calculate Pivot Points
    level1=3 //1=0.236 / 2=0.382 / 3=0.500 / 4=0.618 / 5=0.786
    level2=4//1=0.236 / 2=0.382 / 3=0.500 / 4=0.618 / 5=0.786
    //-------------------------------------------------------------------//
    //-----Level 1 Selection---------------------------------------------//
    if level1=1 then
    fibArea1=0.236
    elsif level1=2 then
    fibArea1=0.382
    elsif level1 = 4 then
    fibArea1=0.618
    elsif level1=5 then
    fibArea1=0.786
    else
    fibArea1=0.500
    endif
    //-------------------------------------------------------------------//
    //-----Level 2 Selection---------------------------------------------//
    if level2=1 then
    fibArea2=0.236
    elsif level2=2 then
    fibArea2=0.382
    elsif level2=3 then
    fibArea2=0.500
    elsif level2=5 then
    fibArea2=0.786
    else
    fibArea2=0.618
    endif
    //-------------------------------------------------------------------//
    //-----Level Top and Bottom Calculation------------------------------//
    if usepivots then
    //-----Pivot Points Method----------------------------------------//
    src1 = low
    src2 = high
    //-----pivots low
    if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
    $ply[z+1] = src1[prd]
    $plx[z+1] = barindex[prd]
    z = z+1
    endif
    //-----pivots high
    if src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then
    $phy[t+1]=src2[prd]
    $phx[t+1]=barindex[prd]
    t=t+1
    endif
    //-----Top and Bottom level
    if isset($phy[t]) and isset($ply[z]) then
    fibtop=$phy[t]
    fibbot=$ply[z]
    diff=fibtop-fibbot
    fib1=fibtop-(diff*fibArea1)
    fib2=fibtop-(diff*fibArea2)
    endif
    else
    //-----Donchian----- Method----------------------------------------//
    fibtop=highest[prd](high)
    fibbot=lowest[prd](low)
    diff=fibtop-fibbot
    fib1=fibtop-(diff*fibArea1)
    fib2=fibtop-(diff*fibArea2)
    endif
    //-------------------------------------------------------------------//
    colorbetween(fib1,fib2,"orange",100)
    //-------------------------------------------------------------------//
    myfib1=round(fib1,2)
    myfib2=round(fib2,2)
    if islastbarupdate then
    drawtext("Fibo Level #fibArea1#: #myfib1#",barindex+5,fib1)
    drawtext("Fibo Level #fibArea2#: #myfib2#",barindex+5,fib2)
    endif
    //-------------------------------------------------------------------//
    return fib1 as "Fibonacci Level1" coloured("orange"), fib2 as "Fibonacci Level2" coloured("orange")//, fibtop coloured("blue"), fibbot coloured("red")
    
    #236767 quote
    Philouxp
    Participant
    New

    Hello,

    Sorry for the delay, Tk u very much Ivan!!

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

Conversion from TRading View to PRT : Fibonacci Golden wave indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Philouxp @philouxp Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Philouxp
1 year, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/27/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...