Rain On Me PRO 3/3

This is the part 3 of Rain On Me PRO. It follow my two other indicators “Rain On Me” and “Rain On Me V2”. This version is called “PRO” because it is less “user-friendly” than my two previous versions. But the indicator load more faster, and it’s cleaner than ever! This indicator is separated into 3 parts. You can find all parts here in the “free indicators” menu or into my Tradingview profile in the « Scripts » section. Once the 3 parts together, the indicator is ready.

Rain On Me PRO 3/3 in action on US OIL WTI CFD.

Screenshot taken from the Settings menu of Rain On Me PRO 3/3.

Here is the complete list of indicators present in this indicator :

  • Improved Fibonacci code
  • Fibonacci information panel
  • Standard Deviation on chart
  • Ichimoku Cloud with Trend Alerts Condition

All indicators have their original default settings. You need to be able to readjust them depending on the market instrument you want to analyze. You have the possibility to put alerts which will notify you when an indicator gives a new signal. When placing an alert, be sure to choose the “once per bar” option each time you place an alert.

Rate this Indicator?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this Indicator.

5
(2)

Or copy / paste the source code into your pine editor :

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RickSimpson
//@version=4

study(title="Rain On Me PRO 3/3", shorttitle="ROM PRO 3/3", overlay=true, max_bars_back=300)

//Inputs

showfib  = input(defval=true,  title="Show Fibonacci?")
showpan  = input(defval=false, title="Show Fibonacci Info Panel?")
showsd   = input(defval=false, title="Show Standard Deviation?")
showichi = input(defval=true,  title="Show Ichimoku?")

//Fibonacci (Original Code Author @ QuantNomad - Ultimate Pivot Points Alerts at https://www.tradingview.com/script/l53FXt9D-QuantNomad-Ultimate-Pivot-Points-Alerts/)

//Settings

is_newbar(res) =>
    ch = 0
    if(res == 'Y')
        t   = year(time('D'))
        ch := change(t) != 0 ? 1 : 0
    else
        t   = time(res)
        ch := change(t) != 0 ? 1 : 0
    ch

nround(x) => 
    n = round(x / syminfo.mintick) * syminfo.mintick
    
RoundToTick( _price) => round(_price / syminfo.mintick) * syminfo.mintick
 
Round( _val, _decimals) => 
    _p = pow(10, _decimals)
    round(abs(_val) * _p) / _p * sign(_val)

is_srnewbar(res) =>
    ch = 0
    if(res == 'Y')
        t   = year(time('D'))
        ch := change(t) != 0 ? 1 : 0
    else
        t   = time(res)
        ch := change(t) != 0 ? 1 : 0

//Inputs

pp_period = input(defval="Day", title="Fibonacci Period", type=input.string, options=['Day','Week','Month','Year'])

//Constants

pp_type                = "Fibonacci"
show_historical_levels = false
show_level_value       = true

//Calculation

pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y' 

open_cur  = 0.0
open_cur := is_newbar(pp_res) ? open : open_cur[1]
popen     = 0.0
popen    := is_newbar(pp_res) ? open_cur[1] : popen[1]
high_cur  = 0.0
high_cur := is_newbar(pp_res) ? high : max(high_cur[1], high)
phigh     = 0.0
phigh    := is_newbar(pp_res) ? high_cur[1] : phigh[1]
low_cur   = 0.0
low_cur  := is_newbar(pp_res) ? low : min(low_cur[1], low)
plow      = 0.0
plow     := is_newbar(pp_res) ? low_cur[1] : plow[1]
pclose    = 0.0
pclose   := is_newbar(pp_res) ? close[1] : pclose[1]

//Pivots

PP = 0.0
R1 = 0.0, R2 = 0.0, R3 = 0.0, R4 = 0.0, R5 = 0.0, R6 = 0.0, R7 = 0.0, R8 = 0.0, R9 = 0.0, R10 = 0.0
S1 = 0.0, S2 = 0.0, S3 = 0.0, S4 = 0.0, S5 = 0.0, S6 = 0.0, S7 = 0.0, S8 = 0.0, S9 = 0.0, S10 = 0.0
  
if (pp_type == "Fibonacci")
    PP  := (phigh + plow + pclose) / 3
    R1  := PP + (phigh - plow) * 0.235
    S1  := PP - (phigh - plow) * 0.235
    R2  := PP + (phigh - plow) * 0.382
    S2  := PP - (phigh - plow) * 0.382
    R3  := PP + (phigh - plow) * 0.5
    S3  := PP - (phigh - plow) * 0.5
    R4  := PP + (phigh - plow) * 0.618
    S4  := PP - (phigh - plow) * 0.618
    R5  := PP + (phigh - plow) * 0.728
    S5  := PP - (phigh - plow) * 0.728
    R6  := PP + (phigh - plow) * 1.000
    S6  := PP - (phigh - plow) * 1.000
    R7  := PP + (phigh - plow) * 1.235
    S7  := PP - (phigh - plow) * 1.235
    R8  := PP + (phigh - plow) * 1.328
    S8  := PP - (phigh - plow) * 1.328
    R9  := PP + (phigh - plow) * 1.5
    S9  := PP - (phigh - plow) * 1.5
    R10 := PP + (phigh - plow) * 1.618
    S10 := PP - (phigh - plow) * 1.618

bars_sinse  = 0
bars_sinse := is_newbar(pp_res) ? 0 : bars_sinse[1] + 1

//Fibonacci Info Panel

srposition         = R6
h                  = srposition
info_label_off     = 50
info_label_size    = size.small
info_panel_x       = timenow + round(change(time) * info_label_off)
info_panel_y       = h
info_title         = "-=-=- Fibonacci Info Panel -=-=-"
info_div           = "\n\n------------------------------"
info_current_close = "\n\nCurrent Close : " + tostring(close)
srpp = "\n\ PP : " + tostring(RoundToTick(PP)) 
srr1 = "\n\ R1 : " + tostring(RoundToTick(R2))
srr2 = "\n\ R2 : " + tostring(RoundToTick(R4))
srr3 = "\n\ R3 : " + tostring(RoundToTick(R6))
srs1 = "\n\ S1 : " + tostring(RoundToTick(S2))
srs2 = "\n\ S2 : " + tostring(RoundToTick(S4))
srs3 = "\n\ S3 : " + tostring(RoundToTick(S6))
info_text  = info_title + info_current_close + srr3 + srr2 + srr1 + srpp + srs1 + srs2 + srs3
info_panel = showpan ? label.new(x=info_panel_x, y=info_panel_y, text=info_text, xloc=xloc.bar_time, yloc=yloc.price, color=color.black, style=label.style_labelup, textcolor=color.white, size=info_label_size) : na
label.delete(info_panel[1])

//Plotting Pivots Levels

vpp_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], PP,  bar_index, PP, color=color.gray,   style = line.style_dashed, extend = extend.right) : na
vs1_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S1,  bar_index, S1, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs2_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S2,  bar_index, S2, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs3_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S3,  bar_index, S3, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs4_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S4,  bar_index, S4, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs5_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S5,  bar_index, S5, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs6_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S6,  bar_index, S6, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs7_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S7,  bar_index, S7, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs8_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S8,  bar_index, S8, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs9_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], S9,  bar_index, S9, color=color.red,    style =  line.style_solid, extend = extend.right) : na
vs10_p = showfib ? line.new(bar_index[min(bars_sinse, 300)], S10, bar_index, S10, color=color.red,   style =  line.style_solid, extend = extend.right) : na
vr1_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R1,  bar_index, R1, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr2_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R2,  bar_index, R2, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr3_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R3,  bar_index, R3, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr4_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R4,  bar_index, R4, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr5_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R5,  bar_index, R5, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr6_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R6,  bar_index, R6, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr7_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R7,  bar_index, R7, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr8_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R8,  bar_index, R8, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr9_p  = showfib ? line.new(bar_index[min(bars_sinse, 300)], R9,  bar_index, R9, color=color.green,  style =  line.style_solid, extend = extend.right) : na
vr10_p = showfib ? line.new(bar_index[min(bars_sinse, 300)], R10, bar_index, R10, color=color.green, style =  line.style_solid, extend = extend.right) : na

//Delete Previous Lines

if (not is_newbar(pp_res) or not show_historical_levels)
    line.delete(vpp_p[1])
    line.delete(vs1_p[1])
    line.delete(vs2_p[1])
    line.delete(vs3_p[1])
    line.delete(vs4_p[1])
    line.delete(vs5_p[1])
    line.delete(vs6_p[1])
    line.delete(vs7_p[1])
    line.delete(vs8_p[1])
    line.delete(vs9_p[1])
    line.delete(vs10_p[1])
    line.delete(vr1_p[1])
    line.delete(vr2_p[1])
    line.delete(vr3_p[1])
    line.delete(vr4_p[1])
    line.delete(vr5_p[1])
    line.delete(vr6_p[1])
    line.delete(vr7_p[1])
    line.delete(vr8_p[1])
    line.delete(vr9_p[1])
    line.delete(vr10_p[1])

//Plotting Labels

label_vpp  = showfib ? label.new(bar_index, PP,  text=show_level_value ? ("                                  0      "  + " " +    tostring(nround(PP)))  : "P",   style= label.style_none, textcolor = color.gray)  : na
label_vs1  = showfib ? label.new(bar_index, S1,  text=show_level_value ? ("                                  0.235      " + " " + tostring(nround(S1)))  : "S1",  style= label.style_none, textcolor = color.red)   : na
label_vs2  = showfib ? label.new(bar_index, S2,  text=show_level_value ? ("                                  0.382      " + " " + tostring(nround(S2)))  : "S2",  style= label.style_none, textcolor = color.red)   : na
label_vs3  = showfib ? label.new(bar_index, S3,  text=show_level_value ? ("                                  0.5      " + " " +   tostring(nround(S3)))  : "S3",  style= label.style_none, textcolor = color.red)   : na
label_vs4  = showfib ? label.new(bar_index, S4,  text=show_level_value ? ("                                  0.618      " + " " + tostring(nround(S4)))  : "S4",  style= label.style_none, textcolor = color.red)   : na
label_vs5  = showfib ? label.new(bar_index, S5,  text=show_level_value ? ("                                  0.728      " + " " + tostring(nround(S5)))  : "S5",  style= label.style_none, textcolor = color.red)   : na
label_vs6  = showfib ? label.new(bar_index, S6,  text=show_level_value ? ("                                  1.000      " + " " + tostring(nround(S6)))  : "S6",  style= label.style_none, textcolor = color.red)   : na
label_vs7  = showfib ? label.new(bar_index, S7,  text=show_level_value ? ("                                  1.235      " + " " + tostring(nround(S7)))  : "S7",  style= label.style_none, textcolor = color.red)   : na
label_vs8  = showfib ? label.new(bar_index, S8,  text=show_level_value ? ("                                  1.328      " + " " + tostring(nround(S8)))  : "S8",  style= label.style_none, textcolor = color.red)   : na
label_vs9  = showfib ? label.new(bar_index, S9,  text=show_level_value ? ("                                  1.5      " + " " +   tostring(nround(S9)))  : "S9",  style= label.style_none, textcolor = color.red)   : na
label_vs10 = showfib ? label.new(bar_index, S10, text=show_level_value ? ("                                  1.618      " + " " + tostring(nround(S10))) : "S10", style= label.style_none, textcolor = color.red)   : na
label_vr1  = showfib ? label.new(bar_index, R1,  text=show_level_value ? ("                                  0.235      " + " " + tostring(nround(R1)))  : "R1",  style= label.style_none, textcolor = color.green) : na
label_vr2  = showfib ? label.new(bar_index, R2,  text=show_level_value ? ("                                  0.382      " + " " + tostring(nround(R2)))  : "R2",  style= label.style_none, textcolor = color.green) : na
label_vr3  = showfib ? label.new(bar_index, R3,  text=show_level_value ? ("                                  0.5      " + " " +   tostring(nround(R3)))  : "R3",  style= label.style_none, textcolor = color.green) : na
label_vr4  = showfib ? label.new(bar_index, R4,  text=show_level_value ? ("                                  0.618      " + " " + tostring(nround(R4)))  : "R4",  style= label.style_none, textcolor = color.green) : na
label_vr5  = showfib ? label.new(bar_index, R5,  text=show_level_value ? ("                                  0.728      " + " " + tostring(nround(R5)))  : "R5",  style= label.style_none, textcolor = color.green) : na
label_vr6  = showfib ? label.new(bar_index, R6,  text=show_level_value ? ("                                  1.000      " + " " + tostring(nround(R6)))  : "R6",  style= label.style_none, textcolor = color.green) : na
label_vr7  = showfib ? label.new(bar_index, R7,  text=show_level_value ? ("                                  1.235      " + " " + tostring(nround(R7)))  : "R7",  style= label.style_none, textcolor = color.green) : na
label_vr8  = showfib ? label.new(bar_index, R8,  text=show_level_value ? ("                                  1.328      " + " " + tostring(nround(R8)))  : "R8",  style= label.style_none, textcolor = color.green) : na
label_vr9  = showfib ? label.new(bar_index, R9,  text=show_level_value ? ("                                  1.5      " + " " +   tostring(nround(R9)))  : "R9",  style= label.style_none, textcolor = color.green) : na
label_vr10 = showfib ? label.new(bar_index, R10, text=show_level_value ? ("                                  1.618      " + " " + tostring(nround(R10))) : "R10", style= label.style_none, textcolor = color.green) : na

//Delete Previous Labels  
    
label.delete(label_vpp[1])
label.delete(label_vs1[1])
label.delete(label_vs2[1])
label.delete(label_vs3[1])
label.delete(label_vs4[1])
label.delete(label_vs5[1])
label.delete(label_vs6[1])
label.delete(label_vs7[1])
label.delete(label_vs8[1])
label.delete(label_vs9[1])
label.delete(label_vs10[1])
label.delete(label_vr1[1])
label.delete(label_vr2[1])
label.delete(label_vr3[1])
label.delete(label_vr4[1])
label.delete(label_vr5[1])
label.delete(label_vr6[1])
label.delete(label_vr7[1])
label.delete(label_vr8[1])
label.delete(label_vr9[1])
label.delete(label_vr10[1])

//Alerts

alertcondition(not is_newbar(pp_res) and crossover(close, S1),  "Fib DownTrend Crossover 0.235", "Fib DownTrend Crossover 0.235")
alertcondition(not is_newbar(pp_res) and crossover(close, S2),  "Fib DownTrend Crossover 0.382", "Fib DownTrend Crossover 0.382")
alertcondition(not is_newbar(pp_res) and crossover(close, S3),  "Fib DownTrend Crossover 0.5",   "Fib DownTrend Crossover 0.5")
alertcondition(not is_newbar(pp_res) and crossover(close, S4),  "Fib DownTrend Crossover 0.618", "Fib DownTrend Crossover 0.618")
alertcondition(not is_newbar(pp_res) and crossover(close, S5),  "Fib DownTrend Crossover 0.728", "Fib DownTrend Crossover 0.728")
alertcondition(not is_newbar(pp_res) and crossover(close, S6),  "Fib DownTrend Crossover 1.000", "Fib DownTrend Crossover 1.000")
alertcondition(not is_newbar(pp_res) and crossover(close, S7),  "Fib DownTrend Crossover 1.235", "Fib DownTrend Crossover 1.235")
alertcondition(not is_newbar(pp_res) and crossover(close, S8),  "Fib DownTrend Crossover 1.328", "Fib DownTrend Crossover 1.328")
alertcondition(not is_newbar(pp_res) and crossover(close, S9),  "Fib DownTrend Crossover 1.5",   "Fib DownTrend Crossover 1.5")
alertcondition(not is_newbar(pp_res) and crossover(close, S10), "Fib DownTrend Crossover 1.618", "Fib DownTrend Crossover 1.618")
alertcondition(not is_newbar(pp_res) and crossover(close, R1),  "Fib UpTrend Crossover 0.235",   "Fib UpTrend Crossover 0.235")
alertcondition(not is_newbar(pp_res) and crossover(close, R2),  "Fib UpTrend Crossover 0.382",   "Fib UpTrend Crossover 0.382")
alertcondition(not is_newbar(pp_res) and crossover(close, R3),  "Fib UpTrend Crossover 0.5",     "Fib UpTrend Crossover 0.5")
alertcondition(not is_newbar(pp_res) and crossover(close, R4),  "Fib UpTrend Crossover 0.618",   "Fib UpTrend Crossover 0.618")
alertcondition(not is_newbar(pp_res) and crossover(close, R5),  "Fib UpTrend Crossover 0.728",   "Fib UpTrend Crossover 0.728")
alertcondition(not is_newbar(pp_res) and crossover(close, R6),  "Fib UpTrend Crossover 1.000",   "Fib UpTrend Crossover 1.000")
alertcondition(not is_newbar(pp_res) and crossover(close, R7),  "Fib UpTrend Crossover 1.235",   "Fib UpTrend Crossover 1.235")
alertcondition(not is_newbar(pp_res) and crossover(close, R8),  "Fib UpTrend Crossover 1.328",   "Fib UpTrend Crossover 1.328")
alertcondition(not is_newbar(pp_res) and crossover(close, R9),  "Fib UpTrend Crossover 1.5",     "Fib UpTrend Crossover 1.5")
alertcondition(not is_newbar(pp_res) and crossover(close, R10), "Fib UpTrend Crossover 1.618",   "Fib UpTrend Crossover 1.618")

alertcondition(not is_newbar(pp_res) and crossunder(close, S1),  "Fib DownTrend Crossunder 0.235", "Fib DownTrend Crossunder 0.235")
alertcondition(not is_newbar(pp_res) and crossunder(close, S2),  "Fib DownTrend Crossunder 0.382", "Fib DownTrend Crossunder 0.382")
alertcondition(not is_newbar(pp_res) and crossunder(close, S3),  "Fib DownTrend Crossunder 0.5",   "Fib DownTrend Crossunder 0.5")
alertcondition(not is_newbar(pp_res) and crossunder(close, S4),  "Fib DownTrend Crossunder 0.618", "Fib DownTrend Crossunder 0.618")
alertcondition(not is_newbar(pp_res) and crossunder(close, S5),  "Fib DownTrend Crossunder 0.728", "Fib DownTrend Crossunder 0.728")
alertcondition(not is_newbar(pp_res) and crossunder(close, S6),  "Fib DownTrend Crossunder 1.000", "Fib DownTrend Crossunder 1.000")
alertcondition(not is_newbar(pp_res) and crossunder(close, S7),  "Fib DownTrend Crossunder 1.235", "Fib DownTrend Crossunder 1.235")
alertcondition(not is_newbar(pp_res) and crossunder(close, S8),  "Fib DownTrend Crossunder 1.328", "Fib DownTrend Crossunder 1.328")
alertcondition(not is_newbar(pp_res) and crossunder(close, S9),  "Fib DownTrend Crossunder 1.5",   "Fib DownTrend Crossunder 1.5")
alertcondition(not is_newbar(pp_res) and crossunder(close, S10), "Fib DownTrend Crossunder 1.618", "Fib DownTrend Crossunder 1.618")
alertcondition(not is_newbar(pp_res) and crossunder(close, R1),  "Fib UpTrend Crossunder 0.235",   "Fib UpTrend Crossunder 0.235")
alertcondition(not is_newbar(pp_res) and crossunder(close, R2),  "Fib UpTrend Crossunder 0.382",   "Fib UpTrend Crossunder 0.382")
alertcondition(not is_newbar(pp_res) and crossunder(close, R3),  "Fib UpTrend Crossunder 0.5",     "Fib UpTrend Crossunder 0.5")
alertcondition(not is_newbar(pp_res) and crossunder(close, R4),  "Fib UpTrend Crossunder 0.618",   "Fib UpTrend Crossunder 0.618")
alertcondition(not is_newbar(pp_res) and crossunder(close, R5),  "Fib UpTrend Crossunder 0.728",   "Fib UpTrend Crossunder 0.728")
alertcondition(not is_newbar(pp_res) and crossunder(close, R6),  "Fib UpTrend Crossunder 1.000",   "Fib UpTrend Crossunder 1.000")
alertcondition(not is_newbar(pp_res) and crossunder(close, R7),  "Fib UpTrend Crossunder 1.235",   "Fib UpTrend Crossunder 1.235")
alertcondition(not is_newbar(pp_res) and crossunder(close, R8),  "Fib UpTrend Crossunder 1.328",   "Fib UpTrend Crossunder 1.328")
alertcondition(not is_newbar(pp_res) and crossunder(close, R9),  "Fib UpTrend Crossunder 1.5",     "Fib UpTrend Crossunder 1.5")
alertcondition(not is_newbar(pp_res) and crossunder(close, R10), "Fib UpTrend Crossunder 1.618",   "Fib UpTrend Crossunder 1.618")
alertcondition(not is_newbar(pp_res) and cross(close, S2) or cross(close, S4) or cross(close, S6) or cross(close, S8) or cross(close, S10) or cross(close, R2) or cross(close, R4) or cross(close, R6) or cross(close, R8) or cross(close, R10), "Important Fib Level Has Been Crossed!", 'Important Fib Level Has Been Crossed!')

//Standard Deviation

//Inputs

sdper     = input(defval=20,    title="Standard Deviation Period")
showsdf   = input(defval=false, title="Show Standard Deviation Forecasting?")
esdatr    = input(defval=false, title="Enable Standard Deviation ATR Smoothing?")
atrsdper  = input(defval=14,    title="Standard Deviation ATR Smoothing Period")
atrsdmult = input(defval=2,     title="Standard Deviation ATR Smoothing Multiplier")
esdma     = input(defval=false, title="Enable Standard Deviation MA Smoothing?")
sdmatype  = input(defval="SMA", title="Standard Deviation MA Smoothing Type", type=input.string, options=["SMA","EMA","DEMA","TEMA","ZLEMA","WMA","SMMA","VWMA","HMA","ALMA","JMA","Donchian","KijunSource","LSMA","Triangular","SuperSmooth","KAMA","GF","DSMA","Median","McGinley"])

//Calculation

sdsrc          = close
sd_alma_offset = 0.85
sd_alma_sigma  = 6
sd_power       = 1
sd_phase       = 50
sd_s_maoffset  = 0
sd_pn          = 4
sd_percentage  = 50
sd_phaseratio  = sd_phase < -100 ? 0.5 : sd_phase > 100 ? 2.5 : sd_phase / 100 + 1.5
sd_beta        = 0.45 * (sdper - 1) / (0.45 * (sdper - 1) + 2)
sd_alpha       = pow(sd_beta, sd_power)
e              = false
sdsdper        = 0.94
sdlog          = log(close / close[1])
sdplog         = log(high / low)
sdsec          = 1 / (4 * log(2))
sdfrac         = 0.0
sdfrac        := sdsdper * nz(sdfrac[1]) + (1 - sdsdper) * pow(sdplog, 2)
sdfhi          = sqrt(sdsec * sdfrac)
sdfl           = 0.0
sdfl          := sdsdper * nz(sdfl[1]) + (1-sdsdper) * pow(sdlog, 2)
sdhighvolf     = sqrt(sdfl)
sduxp          = exp(sdhighvolf * sqrt(sdper))
sdforecast1    = sdsrc * (sduxp)
sdforecast2    = sdsrc / (sduxp)

//Settings

get_jurik(sdsrc, sdpergth, sd_phase, sd_power) =>
    sd_phaseratio = sd_phase < -100 ? 0.5 : sd_phase > 100 ? 2.5 : sd_phase / 100 + 1.5
    sd_beta       = 0.45 * (sdpergth - 1) / (0.45 * (sdpergth - 1) + 2)
    sd_alpha      = pow(sd_beta, sd_power)
    jma           = 0.0
    e0            = 0.0
    e0           := (1 - sd_alpha) * sdsrc + sd_alpha * nz(e0[1])
    e1            = 0.0
    e1           := (sdsrc - e0) * (1 - sd_beta) + sd_beta * nz(e1[1])
    e2            = 0.0
    e2           := (e0 + sd_phaseratio * e1 - nz(jma[1])) * pow(1 - sd_alpha, 2) + 
       pow(sd_alpha, 2) * nz(e2[1])
    jma          := e2 + nz(jma[1])
    jma

donchian(sdper) => avg(lowest(sdper), highest(sdper))

PI  = 2 * asin(1)
tau = 2 * PI

S(sdsrc, sdper) =>
    arg  = sqrt(2) * PI / sdper
    a1   = exp(-arg)
    b1   = 2 * a1 * cos(arg)
    c2   = b1
    c3   = -pow(a1, 2)
    c1   = 1 - c2 - c3
    ssf  = 0.0
    ssf := c1 * (sdsrc + nz(sdsrc[1])) / 2 + c2 * nz(ssf[1]) + c3 * nz(ssf[2])

KAMA(sdsrc,sdper) =>
    mom          = abs(change(sdsrc, sdper))
    volatility   = sum(abs(change(sdsrc)), sdper)
    er           = volatility != 0 ? mom / volatility : 0
    fastsd_alpha = 0.666
    slowsd_alpha = 0.0645
    sc           = pow(er * (fastsd_alpha - slowsd_alpha) + slowsd_alpha, 2)
    kama         = 0.0
    kama        := sc * sdsrc + (1 - sc) * nz(kama[1])

bet  = (1 - cos(2 * PI / sdper)) / (pow(2, 1 / sdper) - 1)
alph = -bet + sqrt(pow(bet, 2) + 2 * bet)

getGF(poles) =>
	filter = 0.0
 
	if poles  == 1
		filter := alph * sdsrc + (1 - alph) * nz(filter[1])
 
	if  poles == 2
		filter := pow(alph, 2) * sdsrc + 2 * (1 - alph) * nz(filter[1]) - pow(1 - alph, 2) * nz(filter[2])
 
	if poles  == 3
		filter := pow(alph, 3) * sdsrc + 3 * (1 - alph) * nz(filter[1]) - 3 * pow(1 - alph, 2) * nz(filter[2]) + pow(1 - alph, 3) * nz(filter[3])
 
	if poles  == 4
		filter := pow(alph, 4) * sdsrc + 4 * (1 - alph) * nz(filter[1]) - 6 * pow(1 - alph, 2) * nz(filter[2]) + 4 * pow(1 - alph, 3) * nz(filter[3]) - pow(1 - alph, 4) * nz(filter[4])
 
	filter
	
gf = getGF(sd_pn)

D(sdsrc,sdper) =>
    A1         = exp(-sqrt(2) * PI) / (0.5 * sdper)
    b1         = 2 * A1 * cos(sqrt(2) * PI / (0.5 * sdper))
    c2         = b1
    c3         = - A1 * A1
    c1         = 1 - c2 - c3
    Zeros      = sdsrc - sdsrc[2]
    DSMA       = 0.0
    sd_alpha1  = 0.0
    Filt       = 0.0
    Filt      := c1 * ( Zeros + Zeros[1] ) / 2 + c2 * nz(Filt[1]) + c3 *nz(Filt[2])
    RMS        = stdev(Filt, sdper)
    ScaledFilt = Filt / RMS
    sd_alpha1 := (abs(ScaledFilt) * 5) / sdper
    DSMA      := (sd_alpha1 * sdsrc) + (( 1 - sd_alpha1 ) * nz(DSMA[1]))

M(sdsrc,sdper)=>
    mg  = 0.0
    mg := na(mg[1]) ? ema(sdsrc, sdper) : mg[1] + (sdsrc - mg[1]) / (sdper * pow(sdsrc / mg[1], 4))
    mg

ma(type, sdsrc, sdper) =>
    float result = 0
    if type=="SMA"
        result := sma(sdsrc, sdper)
    if type=="EMA"
        result := ema(sdsrc, sdper)
    if type=="DEMA"
        EMA1=ema(sdsrc, sdper)
        EMA2=ema(EMA1,  sdper)
        result := 2 * EMA1 - EMA2
    if type=="TEMA"
        xEMA1 = ema(sdsrc, sdper)
        xEMA2 = ema(xEMA1, sdper)
        xEMA3 = ema(xEMA2, sdper)
        result := 3 * xEMA1 - 3 * xEMA2 + xEMA3
    if type=="ZLEMA"
        lag = floor((sdper - 1) / 2)
        result := ema(sdsrc + (sdsrc - sdsrc[lag]), sdper)
    if type=="WMA"
        result := wma(sdsrc, sdper)
    if type=="SMMA"
        w = wma(sdsrc, sdper)
        result := na(w[1]) ? sma(sdsrc, sdper) : (w[1] * (sdper - 1) + sdsrc) / sdper
    if type=="VWMA"
        result := vwma(sdsrc, sdper)
    if type=="HMA"
        result := wma(2 * wma(sdsrc, sdper / 2) - wma(sdsrc, sdper), round(sqrt(sdper)))
    if type=="ALMA"
        result := alma(sdsrc, sdper, sd_alma_offset, sd_alma_sigma)
    if type=="JMA"
        result := get_jurik(sdsrc,sdper, sd_phase, sd_power)
    if type=="Donchian"
        result := donchian(sdper)
    if type=="KijunSource"
        result := (highest(sdsrc, sdper) + lowest(sdsrc, sdper)) / 2
    if type=="LSMA"
        result := linreg(sdsrc, sdper, sd_s_maoffset)
    if type=="Triangular"
        result := sma(sma(sdsrc, ceil(sdper / 2)), floor(sdper / 2) + 1)
    if type=="SuperSmooth"
        result := S(sdsrc, sdper)
    if type=="KAMA"
        result := KAMA(sdsrc, sdper)
    if type=="GF"
        result := gf
    if type=="DSMA"
        result := D(sdsrc, sdper)    
    if type=="Median"
        result:= percentile_nearest_rank(sdsrc, sdper, sd_percentage)
    if type=="McGinley"
        result:= M(sdsrc, sdper)

    result
 
sdm   = ma(sdmatype, sdsrc, sdper)
stdv  = iff(esdma,stdev(sdm, sdper),stdev(sdsrc, sdper))
sd    = esdatr ? atr(atrsdper) : stdv
sd2   = sdm + atrsdmult * sd
sd3   = sdm - atrsdmult * sd
sderr = sd / sqrt(sdper)

//Plotting

plot(showsd  ? sd2 : na, color=color.blue,  transp=0)
plot(showsd  ? sd3 : na, color=color.blue,  transp=0)
plot(showsdf ? sdforecast1 : na, color=color.blue, transp=0, linewidth=2, offset=1, show_last=1)
plot(showsdf ? sdforecast2 : na, color=color.blue, transp=0, linewidth=2, offset=1, show_last=1)
plot(showsdf ? sdforecast1 : na, color=color.blue, transp=0, linewidth=2, offset=2, show_last=1)
plot(showsdf ? sdforecast2 : na, color=color.blue, transp=0, linewidth=2, offset=2, show_last=1)
plot(showsdf ? sdforecast1 : na, color=color.blue, transp=0, linewidth=2, offset=3, show_last=1)
plot(showsdf ? sdforecast2 : na, color=color.blue, transp=0, linewidth=2, offset=3, show_last=1)

//Ichimoku

//Inputs

conversionPeriods   =input(defval=9,   title="Ichimoku Conversion Line Period", minval=1)
basePeriods         =input(defval=103, title="Ichimoku Base Line Period",       minval=1)
laggingSpan2Periods =input(defval=52,  title="Ichimoku Lagging Span 2 Period",  minval=1)
displacement        =input(defval=26,  title="Ichimoku Displacement",           minval=1)

//Settings

donchian2(len) => avg(lowest(len), highest(len))
conversionLine = donchian2(conversionPeriods)
baseline       = donchian2(basePeriods)
leadline1      = avg(conversionLine, baseline)
leadline2      = donchian2(laggingSpan2Periods)
ichibuy        = crossover(conversionLine, baseline)
ichisell       = crossunder(conversionLine, baseline)

//Plotting

plot(showichi ? baseline : na, title="BaseLine", color=color.new(#991515, 0))
plot(showichi ? close    : na, title="Lagging Span/Barney", color=color.new(#9C27B0, 100), linewidth=0, offset=-displacement)
p1ichi = plot(showichi ? leadline1 : na, title="Lead 1", color=color.new(color.green, 100), offset=displacement)
p2ichi = plot(showichi ? leadline2 : na, title="Lead 2", color=color.new(color.red,   100), offset=displacement)
fill(p1ichi, p2ichi, title="Ichimoku Cloud", color=leadline1 > leadline2 ? color.new(color.aqua, 65) : color.new(color.purple, 65))

//Alerts

alertcondition(ichisell, title="Ichimoku Sell", message='Ichimoku Sell')
alertcondition(ichibuy,  title="Ichimoku Buy",  message='Ichimoku Buy')

The content covered on this website is NOT investment advice and I am not a financial advisor.