Voss Predictor Strat – Signal School

You can unlock the code by using any tier subscription or you can just watch the video and see the code directly from there for free.

//@version=5
strategy("Voss Predictor (A Peek Into the Future) - Dr. John Ehlers", "VPF", true, format.price, 3, initial_capital = 100, commission_type = strategy.commission.percent, commission_value = 0.1, default_qty_type = strategy.fixed, currency = currency.USDT, default_qty_value = 100)

// bgcolor(color.new(#000000,20), title="Dark Background")
// var color_none = color(na)

whiten(Series) =>
    0.5 * (Series - nz(Series[2], nz(Series[1], Series)))

bpf(Series, Period, Bandwidth) => // Ehler's BandPass Filter
    var PIx2  = 4.0 * math.asin(1.0) // 6.28318530718 Constant
    var alpha = PIx2 / Period
    var gamma = math.cos(alpha * Bandwidth)
    var delta = 1.0 / gamma - math.sqrt(1.0 / math.pow(gamma, 2.0) - 1.0)
    float bandPass = na,  bandPass := (1.0 - delta) * whiten(  Series   ) +
                         math.cos(alpha) * (1.0 + delta) *     nz(bandPass[1]) -
                                             delta  *     nz(bandPass[2])
    bandPass

vpf(Series, BarsOfPrediction) => // Ehler's Voss Predictive Filter
    var order  = 3.0 * math.min(3.0, BarsOfPrediction)
    float voss = na
    E = 0.0, for i=0 to int(order-1)
    	E := nz(voss[order - i]) * (  1 + i    ) / order  + E
    voss  :=                 0.5 * (3.0 + order) * Series - E
    voss

source         = close
// showAreaBP     = input(          true,              "Display Bandpass Area", input.bool   )
periodBandpass = input.int(            20,                    "Bandpass Period",  minval=   2)
bandWidth      = input.float(          0.25,                        "  Bandwidth"  ,  minval=0.05, maxval=1.0, step=0.05)
barsPrediction = input.float(           3.0,                 "Bars of Prediction"  ,  minval=0.5 , maxval=3.0, step=0.5 )
// showCorrColor  = input.b(          true, "===== Show Correlation Color =====", input.bool   )
syncCorrPeriod = input.string("Synchronized",               " Correlation Control", options=["Independent", "Synchronized"])
periodCorr     = input.int(            40,                " Correlation Period",   minval=2)
var periodCorrelation = syncCorrPeriod=="Synchronized" ? periodBandpass : periodCorr

BPF = bpf(  source, periodBandpass, bandWidth)
VPF = vpf(     BPF, barsPrediction)

// colorFill =  BPF>0.0 and VPF>BPF ? #00FF00 :
//              BPF<0.0 and VPF<BPF ? #FF0000 : color_none
// plot(showAreaBP ? BPF : na, "Area", color=#AAFFFF80, style=plot.style_area)
// plotVPF = plot(   VPF,       "VPF", color= VPF>0.0 ? #00FF00 : #FF0000)
// plotBPF = plot(   BPF,       "BPF", color=#EEEEEEff, linewidth= 2)
// fill(plotBPF, plotVPF,   colorFill, 75, "", editable=false)

//===== Correlation Color
// correlate = correlation(source, bar_index, periodCorrelation)
// colorCorrelate = correlate> 0.75 ? #00FF00ff :
//                  correlate> 0.50 ? #00C000ff :
//                  correlate> 0.25 ? #008000ff :
//                  correlate> 0.0  ? #004000ff :
//                  correlate>-0.25 ? #400000ff :
//                  correlate>-0.50 ? #800000ff :
//                  correlate>-0.75 ? #C00000ff : #FF0000ff
// plot( showCorrColor ? 0.0 : na, color=colorCorrelate, style=plot.style_circles, editable=false, linewidth=3, title="CorrColor")

//===== Zero Lines
// plot( showCorrColor ? na : 0.0, color=#FFFF0022, linewidth=7, title="Zero"  , editable=false)
// hline(                     0.0, color=showCorrColor ? color_none : #CCCCCCff, editable=false)

stFactor = input.float(3.9)
stPeriod = input.int(11)

[superTrend, dir] = ta.supertrend(stFactor, stPeriod)


longit = input(true)
shortit = input(true)

long = dir == -1 
short = dir == 1 

entryThr = input(70)
exitThr = input(50)

longEntry = ta.crossover(VPF, BPF) and VPF <= entryThr * -1
longExit = ta.crossunder(BPF, exitThr * -1)

plotshape(longEntry, "Long",shape.labelup, location.belowbar, long and longit?  color.green : color.black, text = "E", textcolor = long?color.white:color.gray)
plotshape(longExit, "Long X",shape.labelup, location.belowbar, long and longit?color.white: color.black, text = "X", textcolor =long? color.green: color.gray)

shortEntry = ta.crossunder(VPF, BPF) and VPF >= entryThr
shortExit = ta.crossover(BPF, exitThr)

plotshape(shortEntry, "Short",shape.labeldown, location.abovebar,short and shortit? color.red: color.black, text = "E", textcolor = short ?color.white : color.gray)
plotshape(shortExit, "Short X",shape.labeldown, location.abovebar,short and shortit?color.white: color.black, text = "X", textcolor = short ? color.red :color.gray)

longSLp  = input(0.0, inline = "sl", group="sl") / 100
atr2x = input(false, inline = "sl", group="sl") 
atr = ta.atr(2)
longSL = longSLp > 0 ? close - close * longSLp : na
longSL := atr2x ? close - atr : longSL

dealOpenMsg = input.string("deal open msg",group="3commas")
dealCloseMsg = input.string("deal close msg",group="3commas")

// strategy("Exit Demo", pyramiding = 2, overlay = true)
if long and longEntry and longit
    strategy.entry("long", strategy.long, alert_message = dealOpenMsg)
    strategy.exit("stop", from_entry = "long",stop = longSL, alert_loss = dealCloseMsg)
else if longExit or short
    strategy.close("long", alert_message = dealCloseMsg)



if short and shortEntry and shortit
    strategy.entry("short",strategy.short)
else if shortExit or long
    strategy.close("short")

// plot(strategy.position_avg_price, "avg", color = nz(strategy.position_avg_price) != 0 ? color.white : na)

Featured products and TTP memberships