Purple Cloud indicator

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

    Buonasera,

    sarebbe possibile tradurre questo codice di un indicatore che sembra interessante?

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © muratm82

    //@version=5
    indicator(“Purple Cloud [MMD]”,overlay=true, timeframe=””, timeframe_gaps=true)

    atrPeriod = input(10, “Supertrend ATR Length”)
    factor = input.float(3.0, “Supertrend Factor”, step = 0.01)

    [supertrend, direction] = ta.supertrend(factor, atrPeriod)

     

    x1 = input(14, “Period”)
    alpha = input.float(0.7, “Alpha”, step = 0.1)

    bpt=input.float(1.4,”Buying Pressure Threshold %”, step = 0.1)
    spt=input.float(1.4,”Selling Pressure Threshold %”, step = 0.1)

    x2 = ta.atr(x1) * alpha
    xh = close + x2
    xl = close – x2
    a1=ta.vwma(hl2*volume,math.ceil(x1/4))/ta.vwma(volume,math.ceil(x1/4))
    a2=ta.vwma(hl2*volume,math.ceil(x1/2))/ta.vwma(volume,math.ceil(x1/2))
    a3=2*a1-a2
    a4=ta.vwma(a3,x1)

    b1 = 0.0
    b1 := na(b1[1]) ? ta.sma(close, x1) : (b1[1] * (x1 – 1) + close) / x1

    a5=2*a4*b1/(a4+b1)

    buy = a5<=xl and close>b1*(1+bpt*0.01)
    sell = a5>=xh and close<b1*(1-spt*0.01)
    xs = 0
    xs := buy ? 1 : sell ? -1 : xs[1]

    barcolor( color = xs==1 ? color.green :xs==-1? color.red:na)

     

    plotshape(buy and xs != xs[1] , title = “BUY”, text = ‘B’, style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny)
    plotshape(sell and xs != xs[1] , title = “SELL”, text = ‘S’, style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny)

    plotshape(buy and xs != xs[1] and direction < 0 , title = “Strong BUY”, text = ‘🚀’, style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny)
    plotshape(sell and xs != xs[1] and direction > 0 , title = “Strong SELL”, text = ‘☄️’, style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny)

    ema200=input(false,”Ema 200″)
    ema50=input(false,”Ema 50″)
    ema20=input(false,”Ema 20″)

    plot(ta.ema(close,200),color=ema200?color.black:na,title=”Ema 200″,linewidth = 4)
    plot(ta.ema(close,50),color=ema50?color.blue:na,title=”EMA 50″,linewidth = 3)
    plot(ta.ema(close,20),color=ema20?color.orange:na,title=”EMA 20″,linewidth = 2)
    alertcondition(buy and xs != xs[1], “PC Long”, “PC Long”)
    alertcondition(sell and xs != xs[1], “PC Short”, “PC Short”)

    Grazie

    #237359 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Ciao. Eccolo qui: https://www.prorealcode.com/prorealtime-indicators/purple-cloud-indicator/

    //-----------------------------------------------------//
    //-----Inputs------------------------------------------//
    //-----------------------------------------------------//
    atrperiod=10 //SuperTrend ATR length
    factor=3 //Supertrend factor
    
    x1=14
    alpha=0.7
    bpt=1.4//Buying Pressure Threshold %
    spt=1.4//Selling Pressure Threshold %
    
    drawsupertrend=1 //Draw Supertrend
    drawemas=1 //Draw EMAs
    colorcandles=1 //Color candles
    drawsignals=1 //Draw Signals
    //-----------------------------------------------------//
    //-----SuperTrend--------------------------------------//
    //-----------------------------------------------------//
    St=Supertrend[factor,atrperiod]
    //-----------------------------------------------------//
    //-----Up and Down Bands-------------------------------//
    //-----------------------------------------------------//
    x2=averagetruerange[x1](close)*alpha
    xh=close+x2
    xl=close-x2
    a1=VolumeAdjustedAverage[floor(x1/4)]((high+low)/2*volume)/VolumeAdjustedAverage[floor(x1/4)](volume)
    a2=VolumeAdjustedAverage[floor(x1/2)]((high+low)/2*volume)/VolumeAdjustedAverage[floor(x1/2)](volume)
    a3=2*a1-a2
    a4=VolumeAdjustedAverage[x1](a3)
    
    if barindex < x1 then
    b1=average[x1](close)
    else
    b1=(b1[1]*(x1-1)+close)/x1
    endif
    
    a5=2*a4*b1/(a4+b1)
    //-----------------------------------------------------//
    //-----Buy and Sell Signals----------------------------//
    //-----------------------------------------------------//
    buysignal=a5<=xl and close>b1*(1+bpt*0.01)
    sellsignal=a5>=xh and close<b1*(1-spt*0.01)
    
    if buysignal then
    xs=1
    elsif sellsignal then
    xs=-1
    else
    xs=xs[1]
    endif
    //-----------------------------------------------------//
    //-----Plot--------------------------------------------//
    //-----------------------------------------------------//
    //Color Candles
    if xs=1 and colorcandles then
    drawcandle(open,high,low,close)coloured("cyan",100)
    elsif xs=-1 and colorcandles then
    drawcandle(open,high,low,close)coloured("fuchsia",100)
    endif
    //Plot Signals
    if buysignal and xs<>xs[1] and close>st and drawsignals then
    drawtext("STRONG BUY",barindex,low-tr)coloured("green")
    drawtext("▲",barindex,low-0.25*tr)coloured("green")
    elsif buysignal and xs<>xs[1] and drawsignals then
    drawtext("BUY",barindex,low-tr)coloured("green")
    drawtext("▲",barindex,low-0.25*tr)coloured("green")
    elsif sellsignal and xs<>xs[1] and close<st and drawsignals then
    drawtext("STRONG SELL",barindex,high+tr)coloured("red")
    drawtext("▼",barindex,high+0.25*tr)coloured("red")
    elsif sellsignal and xs<>xs[1] and drawsignals then
    drawtext("SELL",barindex,high+tr)coloured("red")
    drawtext("▼",barindex,high+0.25*tr)coloured("red")
    endif
    //Plot EMAs
    if drawemas then
    ema200=average[200,1](close)
    ema50=average[50,1](close)
    ema20=average[20,1](close)
    else
    ema200=undefined
    ema50=undefined
    ema20=undefined
    endif
    //Plot Supertrend
    if drawsupertrend and close>st then
    superT=st
    r=0
    g=255
    elsif drawsupertrend and close<=st then
    superT=st
    r=255
    g=0
    else
    superT=undefined
    endif
    //-----------------------------------------------------//
    return superT as "SuperTrend"coloured(r,g,0)style(line,3),ema200 as "EMA 200" style(line,4),ema50 as "EMA 50" style(line,3)coloured("lightblue"),ema20 as "EMA 20" style(line,2)coloured("orange")
    #237518 quote
    StenozarStenozar
    Participant
    Master

    Thanks Ivan!

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Purple Cloud indicator


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Stenozar @stenozar Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by StenozarStenozar
2 years ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 09/08/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...