0

this is a script converted from version 1 to version 5, added the function of Multitimeframe. it is not plotting anything on TradingView Chart. here is the code. any help appreciated.

//@version=5
indicator("GG EhlersEOT V5", shorttitle="GG Ehlers V5", 
overlay=false, timeframe="", timeframe_gaps=true)

period = input(20, "Period")
q1 = input(0.8, "Q1")
q2 = input(0.4, "Q2")
src = input(close, "Source")

var float HP = na
var float Filt = na
var float Pk = na

Quotient(LPPeriod, K) =>
pi = 3.1415926
angle = 0.707 * 2 * pi / 100
alpha1 = (math.cos(angle) + math.sin(angle) - 1) / math.cos(angle)
a1 = math.exp(-1.414 * pi / LPPeriod)
b1 = 2 * a1 * math.cos(1.414 * pi / LPPeriod)
c2 = b1
c3 = -a1 * a1
c1 = 1 - c2 - c3

HP_temp = math.pow((1 - alpha1 / 2), 2) * (close - (2 * close[1]) + close[2]) + 2 * (1 - alpha1) * HP[1]      - math.pow((1 - alpha1), 2) * HP[2]
Filt_temp = c1 * (HP_temp + HP_temp[1]) / 2 + c2 * Filt[1] + c3 * Filt[2]
Pk_temp = (math.abs(Filt_temp) > 0.991 * Pk[1]) ? math.abs(Filt_temp) : 0.991 * Pk[1]
q = (Filt_temp + K) / (K * Filt_temp + 1)

HP_temp

var float redline = Quotient(period, q1) + 2
var float aqualine = Quotient(period, q2) + 2
var float avgline = redline - aqualine
var float eotslope = redline - redline[1]
var bool priceup = src > src[1]
var bool pricedown = src < src[1]
var bool redup = redline > redline[1]
var bool reddown = redline < redline[1]
var color c = (priceup and reddown) ? color.red : (pricedown and redup) ? color.blue : color.black

plot(avgline, color=color.yellow)
plot(eotslope, color=c)
plot(redline, color=color.red)
plot(aqualine, color=color.aqua)
hline(0)

tried converting to version5, not showing results

Ying
  • 1

1 Answers1

0

For HP_temp use Variable reassignment
And the function Quotient, must be indented

Something like this:

//@version=5
indicator(title='Ehlers Early Onset Trend', shorttitle='EOT')
Period = input(20)
Q1 = input(0.8)
Q2 = input(0.4)

Quotient(LPPeriod, K) =>
    PI = 3.1415926
    angle = 0.707 * 2 * PI / 100
    alpha1 = (math.cos(angle) + math.sin(angle) - 1) / math.cos(angle)

    a1 = math.exp(-1.414 * PI / LPPeriod)
    b1 = 2 * a1 * math.cos(1.414 * PI / LPPeriod)
    c2 = b1
    c3 = -a1 * a1
    c1 = 1 - c2 - c3
    HP = 0.0
    HP := math.pow(1 - alpha1 / 2, 2) * (close - 2 * close[1] + close[2]) + 2 * (1 - alpha1) * nz(HP[1]) - math.pow(1 - alpha1, 2) * nz(HP[2])
    Filt = 0.0
    Filt := c1 * (HP + nz(HP[1])) / 2 + c2 * nz(Filt[1]) + c3 * nz(Filt[2])
    Pk = 0.0
    Pk := math.abs(Filt) > 0.991 * nz(Pk[1]) ? math.abs(Filt) : 0.991 * nz(Pk[1])
    X = nz(Filt / Pk)

    q = (X + K) / (K * X + 1)
    q

plot(Quotient(Period, Q1), color=color.new(color.red, 0))
plot(Quotient(Period, Q2), color=color.new(color.aqua, 0))
hline(0)
Gu5tavo71
  • 706
  • 1
  • 4
  • 11