Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © fikira
- //@version=5
- indicator('Euler Cubes', shorttitle='Cubᵋ', overlay=true)
- extN = 'extend none'
- extL = 'extend left'
- extR = 'extend right'
- extB = 'extend both'
- useDt = input.bool(false, title='', group='Year - Month - Day', inline='date')
- Year = input.int(2021, title='', group='Year - Month - Day', inline='date')
- Month = input.int(5, minval=1, maxval=12, title='', group='Year - Month - Day', inline='date')
- Day = input.int(18, minval=1, maxval=31, title='', group='Year - Month - Day', inline='date')
- Time = timestamp(Year, Month, Day, hour, minute, second)
- Tdiff = useDt ? math.floor((timenow - Time) / (time_close[1] - time_close[2])) : 0
- iLbsB = input.int(1, minval=0, title='Bars Back', group='source low', inline='low') + Tdiff + 1
- iLsrc = input.source(low, title='', group='source low', inline='low')
- iHbsB = input.int(1, minval=0, title='Bars Back', group='source high', inline='high') + Tdiff + 1
- iHsrc = input.source(high, title='', group='source high', inline='high')
- // Euler-Mascheroni constant gamma γ = 0.57721566490153286060651209008240243...
- // ('Euler's constant', not to be confused with the constant e=2.718281...)
- // golden ratio conjugate constant = 0.6180339887498948 = math.rphi
- // the golden ratio constant = 1.6180339887498948 = math.phi
- // Euler's number (Leonhard Euler) e = 2,71828182845904523536028747135266249... = math.e
- // Archimedes' constant pi π = 3.1415926535897932 = math.pi
- // constant of Mitchell Feigenbaum δ ≈ 4.66920160910299067185320382046620161...
- C_ = input.string('Euler', title='constant', options=['Euler-Mascheroni', 'Golden Ratio conjugate', 'Golden Ratio', 'Euler', 'Pi', 'Feigenbaum'])
- C = C_ == 'Euler-Mascheroni' ? 0.57721566490153286060651209008240243 : C_ == 'Golden Ratio conjugate' ? math.rphi : C_ == 'Golden Ratio' ? math.phi : C_ == 'Euler' ? math.e : C_ == 'Pi' ? math.pi : 4.66920160910299067185320382046620161
- i_e = input(6., title='x times \'e\'') * C / 10
- i_deg_ = input.int(0, minval=-90, maxval=90, step=1, title='Degrees')
- i_ext_ = input.string(extN, options=[extN, extL, extR, extB], title='extend lines')
- i_eulma = input.bool(false, title='\'Eulma\'', group='Show Euler SMA/EMA', inline='eul')
- i_eulema = input.bool(false, title='\'Eulema\'', group='Show Euler SMA/EMA', inline='eul')
- i_ext = i_ext_ == extN ? extend.none : i_ext_ == extL ? extend.left : i_ext_ == extR ? extend.right : extend.both
- a_angle = array.new_float()
- // https://www.mathcelebrity.com/anglebasic.php?entry=78&pl=cos
- // sin 90° - sin 61°
- array.push(a_angle, 1.)
- array.push(a_angle, 0.99985)
- array.push(a_angle, 0.99939)
- array.push(a_angle, 0.99863)
- array.push(a_angle, 0.99756)
- array.push(a_angle, 0.99619)
- array.push(a_angle, 0.99452)
- array.push(a_angle, 0.99255)
- array.push(a_angle, 0.99027)
- array.push(a_angle, 0.98769)
- array.push(a_angle, 0.98481)
- array.push(a_angle, 0.98163)
- array.push(a_angle, 0.97815)
- array.push(a_angle, 0.97437)
- array.push(a_angle, 0.9703)
- array.push(a_angle, 0.966)
- array.push(a_angle, 0.96126)
- array.push(a_angle, 0.9563)
- array.push(a_angle, 0.95106)
- array.push(a_angle, 0.94552)
- array.push(a_angle, 0.93969)
- array.push(a_angle, 0.93358)
- array.push(a_angle, 0.92718)
- array.push(a_angle, 0.9205)
- array.push(a_angle, 0.91355)
- array.push(a_angle, 0.90631)
- array.push(a_angle, 0.89879)
- array.push(a_angle, 0.891)
- array.push(a_angle, 0.88295)
- array.push(a_angle, 0.87462)
- // sin 60° - sin 31°
- array.push(a_angle, 0.866)
- array.push(a_angle, 0.85717)
- array.push(a_angle, 0.84805)
- array.push(a_angle, 0.83867)
- array.push(a_angle, 0.82904)
- array.push(a_angle, 0.81915)
- array.push(a_angle, 0.80902)
- array.push(a_angle, 0.79864)
- array.push(a_angle, 0.78801)
- array.push(a_angle, 0.77715)
- array.push(a_angle, 0.76604)
- array.push(a_angle, 0.75471)
- array.push(a_angle, 0.74314)
- array.push(a_angle, 0.73135)
- array.push(a_angle, 0.71934)
- array.push(a_angle, 0.70711)
- array.push(a_angle, 0.69466)
- array.push(a_angle, 0.682)
- array.push(a_angle, 0.66913)
- array.push(a_angle, 0.65606)
- array.push(a_angle, 0.64279)
- array.push(a_angle, 0.62932)
- array.push(a_angle, 0.61566)
- array.push(a_angle, 0.60182)
- array.push(a_angle, 0.58779)
- array.push(a_angle, 0.57358)
- array.push(a_angle, 0.55919)
- array.push(a_angle, 0.54464)
- array.push(a_angle, 0.52992)
- array.push(a_angle, 0.51504)
- // sin 30° - sin 0°
- array.push(a_angle, 0.5)
- array.push(a_angle, 0.48481)
- array.push(a_angle, 0.46947)
- array.push(a_angle, 0.454)
- array.push(a_angle, 0.43837)
- array.push(a_angle, 0.42262)
- array.push(a_angle, 0.40674)
- array.push(a_angle, 0.39073)
- array.push(a_angle, 0.37461)
- array.push(a_angle, 0.35837)
- array.push(a_angle, 0.34202)
- array.push(a_angle, 0.32557)
- array.push(a_angle, 0.30902)
- array.push(a_angle, 0.29237)
- array.push(a_angle, 0.27564)
- array.push(a_angle, 0.25882)
- array.push(a_angle, 0.24192)
- array.push(a_angle, 0.22495)
- array.push(a_angle, 0.20791)
- array.push(a_angle, 0.19081)
- array.push(a_angle, 0.17365)
- array.push(a_angle, 0.15643)
- array.push(a_angle, 0.13917)
- array.push(a_angle, 0.12187)
- array.push(a_angle, 0.10453)
- array.push(a_angle, 0.08716)
- array.push(a_angle, 0.06976)
- array.push(a_angle, 0.05234)
- array.push(a_angle, 0.0349)
- array.push(a_angle, 0.01745)
- array.push(a_angle, 0.)
- f_time(x) =>
- (time - time[1]) * math.round(x)
- i_deg = math.abs(i_deg_)
- deg_0_end = array.get(a_angle, i_deg)
- deg_end_0 = i_deg_ >= 0 ? array.get(a_angle, array.size(a_angle) - i_deg - 1) : -array.get(a_angle, array.size(a_angle) - i_deg - 1)
- f_update(mult) =>
- xbl = timenow - (time - time[1]) * math.round(iLbsB)
- xbr = timenow - (time - time[1])
- xtl = timenow - (time - time[1]) * math.round(iLbsB)
- xtr = timenow - (time - time[1])
- ybl = iLsrc[iLbsB - 1]
- ybr = iLsrc[iLbsB - 1]
- ytl = iHsrc[iHbsB - 1]
- ytr = iHsrc[iHbsB - 1]
- Hx = xbr - xbl
- Hy = ytl - ybl
- xbr := xbl + math.round(mult * Hx * deg_0_end)
- ybr := ybl + mult * Hy * deg_end_0
- xtl -= math.round(mult * Hx * deg_end_0)
- ytl := ybl + mult * Hy * deg_0_end
- xtr := xtl + math.round(mult * Hx * deg_0_end)
- ytr := ytl + mult * Hy * deg_end_0
- [xbl, ybl, xbr, ybr, xtl, ytl, xtr, ytr]
- [xbl, ybl, xbr, ybr, xtl, ytl, xtr, ytr] = f_update(1)
- [xbl2, ybl2, xbr2, ybr2, xtl2, ytl2, xtr2, ytr2] = f_update(i_e)
- [xbl3, ybl3, xbr3, ybr3, xtl3, ytl3, xtr3, ytr3] = f_update(i_e * i_e)
- [xbl4, ybl4, xbr4, ybr4, xtl4, ytl4, xtr4, ytr4] = f_update(i_e * i_e * i_e)
- [xbl5, ybl5, xbr5, ybr5, xtl5, ytl5, xtr5, ytr5] = f_update(i_e * i_e * i_e * i_e)
- f_line(xbl, ybl, xbr, ybr, xtl, ytl, xtr, ytr, xdashed, ydashed, color, ext) =>
- l_b = line.new(xbl, ybl, xbr, ybr, xloc=xloc.bar_time, color=color, width=1, extend=extend.none)
- line.delete(l_b[1])
- l_l = line.new(xbl, ybl, xtl, ytl, xloc=xloc.bar_time, color=color, width=1, extend=extend.none)
- line.delete(l_l[1])
- l_r = line.new(xbr, ybr, xtr, ytr, xloc=xloc.bar_time, color=color, width=1, extend=extend.none)
- line.delete(l_r[1])
- l_t = line.new(xtl, ytl, xtr, ytr, xloc=xloc.bar_time, color=color, width=1, extend=ext)
- line.delete(l_t[1])
- l_ = line.new(xdashed, ydashed, xtr, ytr, xloc=xloc.bar_time, color=color, style=line.style_dotted)
- line.delete(l_[1])
- if i_ext != extend.none
- _l = line.new(xbl, ybl, xbr, ybr, xloc=xloc.bar_time, color=color.white, extend=ext)
- line.delete(_l[1])
- if barstate.islast
- f_line(xbl, ybl, xbr, ybr, xtl, ytl, xtr, ytr, xbl, ybl, color.lime, i_ext)
- f_line(xbl, ybl, xbr2, ybr2, xtl2, ytl2, xtr2, ytr2, xtr, ytr, color.red, i_ext)
- f_line(xbl, ybl, xbr3, ybr3, xtl3, ytl3, xtr3, ytr3, xtr2, ytr2, color.yellow, i_ext)
- f_line(xbl, ybl, xbr4, ybr4, xtl4, ytl4, xtr4, ytr4, xtr3, ytr3, color.aqua, i_ext)
- f_line(xbl, ybl, xbr5, ybr5, xtl5, ytl5, xtr5, ytr5, xtr4, ytr4, color.fuchsia, i_ext)
- labL = label.new(bar_index[iLbsB - 1], ybl, yloc=yloc.price, style=label.style_label_up, color=color.lime, size=size.tiny)
- label.delete(labL[1])
- labH = label.new(bar_index[iHbsB - 1], ytl, yloc=yloc.price, style=label.style_label_down, color=color.red, size=size.tiny)
- label.delete(labH[1])
- lineD = line.new(xbl, ybl, xtl2, ytl2, xloc=xloc.bar_time, extend=extend.none, width=1, color=color.red)
- line.delete(lineD[1])
- //if barstate.islast
- // f_line(xbl , ybl, xbr , ybr , xtl , ytl , xtr , ytr, color.lime , extend.none)
- // f_line(xbr , ybr, xbr2, ybr2, xtm2, ytm2, xtr2, ytr2, color.red , extend.none)
- // f_line(xbr , ybr, xbr3, ybr3, xtm3, ytm3, xtr3, ytr3, color.yellow, extend.none)
- //ratio = 1.0000000 - (1.0000000 / i_e) // 0.666666
- //xbm2 := round(avg(xbl2, xbr2))
- //xtm2 := round(xtr2 - ((xtr2 - xtl2)*ratio)) // !!!!!!!!!!!!!!!!!!
- //ybm2 := avg(ytl2, ybl2)
- //ytm2 := ytr2 - ((ytr2 - ytl2)*ratio) // !!!!!!!!!!!!!!!!!!
- // Euler SMA - EMA
- i_len1 = math.round(C * 10 * 1)
- i_len2 = math.round(C * 10 * 2)
- i_len3 = math.round(C * 10 * 3)
- i_len4 = math.round(C * 10 * 4)
- i_len5 = math.round(C * 10 * 5)
- i_len6 = math.round(C * 10 * 6)
- i_len7 = math.round(C * 10 * 7)
- i_len8 = math.round(C * 10 * 8)
- eulma1 = float(na)
- eulma2 = float(na)
- eulma3 = float(na)
- eulma4 = float(na)
- eulma5 = float(na)
- eulma6 = float(na)
- eulma7 = float(na)
- eulma8 = float(na)
- eulema1 = float(na)
- eulema2 = float(na)
- eulema3 = float(na)
- eulema4 = float(na)
- eulema5 = float(na)
- eulema6 = float(na)
- eulema7 = float(na)
- eulema8 = float(na)
- if i_eulma
- eulma1 := ta.sma(close, i_len1) // 27
- eulma2 := ta.sma(close, i_len2) // 54
- eulma3 := ta.sma(close, i_len3) // 82
- eulma4 := ta.sma(close, i_len4) // 109
- eulma5 := ta.sma(close, i_len5) // 136
- eulma6 := ta.sma(close, i_len6) // 163
- eulma7 := ta.sma(close, i_len7) // 190
- eulma8 := ta.sma(close, i_len8) // 217
- eulma8
- if i_eulema
- eulema1 := ta.ema(close, i_len1) // 27
- eulema2 := ta.ema(close, i_len2) // 54
- eulema3 := ta.ema(close, i_len3) // 82
- eulema4 := ta.ema(close, i_len4) // 109
- eulema5 := ta.ema(close, i_len5) // 136
- eulema6 := ta.ema(close, i_len6) // 163
- eulema7 := ta.ema(close, i_len7) // 190
- eulema8 := ta.ema(close, i_len8) // 217
- eulema8
- plot(eulma1, color=color.new(color.yellow, 0))
- plot(eulma2, color=color.new(color.aqua, 0))
- plot(eulma3, color=color.new(color.orange, 0))
- plot(eulma4, color=color.new(color.white, 0))
- plot(eulma5, color=color.new(color.orange, 0))
- plot(eulma6, color=color.new(color.fuchsia, 0))
- plot(eulma7, color=color.new(color.red, 0))
- plot(eulma8, color=color.new(color.maroon, 0), linewidth=2)
- plot(eulema1, color=color.new(color.yellow, 0), style=plot.style_circles)
- plot(eulema2, color=color.new(color.aqua, 0), style=plot.style_circles)
- plot(eulema3, color=color.new(color.orange, 0), style=plot.style_circles)
- plot(eulema4, color=color.new(color.white, 0), style=plot.style_circles)
- plot(eulema5, color=color.new(color.orange, 0), style=plot.style_circles)
- plot(eulema6, color=color.new(color.fuchsia, 0), style=plot.style_circles)
- plot(eulema7, color=color.new(color.red, 0), style=plot.style_circles)
- plot(eulema8, color=color.new(color.maroon, 0), style=plot.style_circles, linewidth=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement