Convert code – pivot ribbon

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #233359 quote
    Faisalx
    Participant
    New
    I would appreciate if you can convert the following code below  
    // Saty Pivot Ribbon
    // Copyright (C) 2022-2023 Saty Mahajan
    //
    // A 3 EMA Ribbon system that simplifies measuring and using emas for trend and support/resistance.
    // Special thanks to Ripster for his education and EMA Clouds which inspired this indicator. 
    
    //@version=5
    indicator('Saty Pivot Ribbon', 'Saty Pivot Ribbon', overlay=true)
    
    // Settings
    time_warp = input.string("off", 'Time Warp', options=["off", "1m", "2m", "3m", "4m", "5m", "10m", "15m", "20m", "30m", "1h", "2h", "4h", "D", "W", "M", "Y"])
    fast_ema = input(title='Fast EMA Length', defval=8)
    pivot_ema = input(title='Pivot EMA Length', defval=21)
    slow_ema = input(title='Slow EMA Length', defval=34)
    bullish_fast_cloud_color = input(color.green, 'Bullish Fast Cloud Color')
    bearish_fast_cloud_color = input(color.red, 'Bearish Fast Cloud Color')
    bullish_slow_cloud_color = input(color.aqua, 'Bullish Slow Cloud Color')
    bearish_slow_cloud_color = input(color.orange, 'Bearish Slow Cloud Color')
    cloud_transparency = input(title='Cloud Transparency (0-100)', defval=60)
    show_fast_ema_highlight = input(false, 'Show Fast EMA Highlight')
    fast_ema_highlight_color = input(color.white, 'Fast EMA Highlight Color')
    show_pivot_ema_highlight = input(false, 'Show Pivot EMA Highlight')
    pivot_ema_highlight_color = input(color.white, 'Pivot EMA Highlight Color')
    show_slow_ema_highlight = input(false, 'Show Slow EMA Highlight')
    slow_ema_highlight_color = input(color.white, 'Slow EMA Highlight Color')
    show_conviction_arrows = input(true, 'Show Conviction Arrows')
    bullish_conviction_color = input(color.aqua, 'Bullish Conviction Arrow Color')
    bearish_conviction_color = input(color.yellow, 'Bearish Conviction Arrow Color')
    show_fast_conviction_ema = input(true, 'Show Fast Conviction EMA')
    fast_conviction_ema = input(13, 'Fast Conviction EMA Length')
    fast_conviction_ema_color = input(color.silver, 'Fast Conviction EMA Color')
    show_slow_conviction_ema = input(true, 'Show Slow Conviction EMA')
    slow_conviction_ema = input(48, 'Slow Conviction EMA Length')
    slow_conviction_ema_color = input(color.purple, 'Slow Conviction EMA Color')
    show_candle_bias = input(false, "Show Candle Bias")
    bias_ema = input(21, 'Bias EMA')
    
    // Time Warp timeframe
    // Set the appropriate timeframe based on trading mode
    timeframe_func() =>
        timeframe = timeframe.period 
        if time_warp == 'off'
            timeframe := timeframe.period
        else if time_warp == '1m'
            timeframe := '1'
        else if time_warp == '2m'
            timeframe := '2'
        else if time_warp == '3m'
            timeframe := '3'
        else if time_warp == '4m'
            timeframe := '4'
        else if time_warp == '5m'
            timeframe := '5'
        else if time_warp == '10m'
            timeframe := '10'
        else if time_warp == '15m'
            timeframe := '15'
        else if time_warp == '20m'
            timeframe := '20'
        else if time_warp == '30m'
            timeframe := '30'
        else if time_warp == '1h'
            timeframe := '60'
        else if time_warp == '2h'
            timeframe := '120'
        else if time_warp == '4h'
            timeframe := '240'
        else if time_warp == 'D'
            timeframe := 'D'
        else if time_warp == 'W'
            timeframe := 'W'
        else if time_warp == 'M'
            timeframe := 'M'
        else if time_warp == 'Y'
            timeframe := '12M'
        else
            timeframe := timeframe.period
    
    // Calculations
    ticker = ticker.new(syminfo.prefix, syminfo.ticker, session=session.extended)
    price = request.security(ticker, timeframe_func(), close, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
    
    fast_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, fast_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    pivot_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, pivot_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    slow_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, slow_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    fast_conviction_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, fast_conviction_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    slow_conviction_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, slow_conviction_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    
    // Create plots
    fast_ema_plot = plot(fast_ema_value, color=show_fast_ema_highlight ? fast_ema_highlight_color : na, title='Fast EMA')
    pivot_ema_plot = plot(pivot_ema_value, color=show_pivot_ema_highlight ? pivot_ema_highlight_color : na, title='Pivot EMA')
    slow_ema_plot = plot(slow_ema_value, color=show_slow_ema_highlight ? slow_ema_highlight_color : na, title='Slow EMA')
    
    // Fill in the plots to create clouds
    fast_cloud_color = fast_ema_value >= pivot_ema_value ? color.new(bullish_fast_cloud_color, cloud_transparency) : color.new(bearish_fast_cloud_color, cloud_transparency)
    fill(fast_ema_plot, pivot_ema_plot, color=fast_cloud_color, title='Fast Cloud', transp=90)
    slow_cloud_color = pivot_ema_value >= slow_ema_value ? color.new(bullish_slow_cloud_color, cloud_transparency) : color.new(bearish_slow_cloud_color, cloud_transparency)
    fill(pivot_ema_plot, slow_ema_plot, color=slow_cloud_color, title='Slow Cloud', transp=90)
    
    // Conviction Arrows (default based on 13/48)
    bullish_conviction = fast_conviction_ema_value >= slow_conviction_ema_value
    bearish_conviction = fast_conviction_ema_value < slow_conviction_ema_value
    bullish_conviction_confirmed = bullish_conviction[0] == true and bullish_conviction[1] == false
    bearish_conviction_confirmed = bearish_conviction[0] == true and bearish_conviction[1] == false
    plotshape(bullish_conviction_confirmed and show_conviction_arrows, style=shape.triangleup, color=bullish_conviction_color, location=location.belowbar, size=size.small)
    plotshape(bearish_conviction_confirmed and show_conviction_arrows, style=shape.triangledown, color=bearish_conviction_color, location=location.abovebar, size=size.small)
    fast_conviction_ema_plot = plot(fast_conviction_ema_value, color=show_fast_conviction_ema ? fast_conviction_ema_color : na, title='Fast Conviction EMA')
    slow_conviction_ema_plot = plot(slow_conviction_ema_value, color=show_slow_conviction_ema ? slow_conviction_ema_color : na, title='Slow Conviction EMA')
    
    // Candle Bias
    bias_ema_value = request.security(syminfo.tickerid, timeframe_func(), ta.ema(price, bias_ema)[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
    above_pivot = close >= bias_ema_value
    below_pivot = close < bias_ema_value
    up = open < close
    doji = open == close
    down = open > close
    bias_candle_color = above_pivot and up and show_candle_bias ? bullish_fast_cloud_color :
             below_pivot and up and show_candle_bias ? bearish_slow_cloud_color :
             above_pivot and down and show_candle_bias ? bullish_slow_cloud_color :
             below_pivot and down and show_candle_bias ? bearish_fast_cloud_color :
             doji and show_candle_bias ? color.gray :
             na
    
    plotcandle(open,high,low,close,color = bias_candle_color, bordercolor = bias_candle_color, wickcolor = bias_candle_color)
    

    #233434 quote
    Iván González
    Moderator
    Master
    Hi! Here you have the code:
    //---------------------------------------------------------------------------//
    //PRC_Saty Pivot Ribbon
    //version = 0
    //03.06.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-----Inputs----------------------------------------------------------------//
    fastemaperiod=8
    fastconvictionemaperiod=13
    pivotemaperiod=21
    slowemaperiod=34
    slowconvictionemaperiod=48
    biasemaperiod=21
    transparency=100
    showemas=0//boolean "Show EMAs"
    colorcandles=0//boolean "Color Candles"
    showarrows=1//boolean "Show Arrows"
    //---------------------------------------------------------------------------//
    fastema=average[fastemaperiod,1](close)
    pivotema=average[pivotemaperiod,1](close)
    slowema=average[slowemaperiod,1](close)
    fastconvictionema=average[fastconvictionemaperiod,1](close)
    slowconvictionema=average[slowconvictionemaperiod,1](close)
    //---------------------------------------------------------------------------//
    //-----Clouds----------------------------------------------------------------//
    if fastema>=pivotema then
    rfc=76
    gfc=175
    bfc=80
    else
    rfc=255
    gfc=82
    bfc=82
    endif
    if pivotema>=slowema then
    rsc=0
    gsc=188
    bsc=212
    else
    rsc=255
    gsc=152
    bsc=0
    endif
    colorbetween(pivotema,fastema,rfc,gfc,bfc,transparency)
    colorbetween(pivotema,slowema,rsc,gsc,bsc,transparency)
    //---------------------------------------------------------------------------//
    //-----Conviction Arrows-----------------------------------------------------//
    bullishconviction=fastconvictionema>=slowconvictionema
    bearishconviction=fastconvictionema<slowconvictionema
    bullishconvictionconfirmed=bullishconviction and bullishconviction[1]=0
    bearishconvictionconfirmed=bearishconviction and bearishconviction[1]=0
    
    if bullishconvictionconfirmed and showarrows then
    drawarrowup(barindex,low-0.35*tr)coloured(0,188,212)
    elsif bearishconvictionconfirmed and showarrows then
    drawarrowdown(barindex,high+0.35*tr)coloured(255,235,59)
    endif
    //---------------------------------------------------------------------------//
    //-----Candle Bias-----------------------------------------------------------//
    biasema=average[biasemaperiod,1](close)
    abovepivot=close>=biasema
    belowpivot=close<biasema
    up=open<close
    doji=open=close
    down=open>close
    if colorcandles then
    if abovepivot and up then
    rbar=76
    gbar=175
    bbar=80
    elsif belowpivot and up then
    rbar=255
    gbar=152
    bbar=0
    elsif abovepivot and down then
    rbar=0
    gbar=188
    bbar=212
    elsif belowpivot and down then
    rbar=255
    gbar=82
    bbar=82
    elsif doji then
    rbar=120
    gbar=123
    bbar=134
    endif
    drawcandle(open,high,low,close)coloured(rbar,gbar,bbar)
    endif
    //---------------------------------------------------------------------------//
    //-----Plot EMAs-------------------------------------------------------------//
    if showemas then
    a=255
    else
    a=0
    endif
    //---------------------------------------------------------------------------//
    return fastema as "Fast EMA" coloured(255,255,255,a),pivotema as "Pivot EMA" coloured(255,255,255,a),slowema as "Slow EMA" coloured(255,255,255,a),fastconvictionema as "Fast Conviction EMA" coloured("silver")style(line,2), slowconvictionema as "Slow Conviction EMA" coloured("purple")style(line,2)
    
    JS and Faisalx thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Convert code – pivot ribbon


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Faisalx @faisalx Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 8 months ago.

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