Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("KondiciogramMax")
- data_source = input(type=source, title="Source", defval=close)
- measure_period = input(type=integer, title="Measure period", defval=65, minval=1, step=1)
- ema_weight = input(type=float, title="EMA weight", defval=0.408163, minval=-1, maxval = 1, step=0.1)
- linreg_weight = input(type=float, title="LinReg weight", defval=0.591837, minval=-1, maxval = 1, step=0.1)
- cycle_length = input(type=float, title="Desired cycle (bars)", minval=1,defval=14.14, step=0.25)
- wave_1_weight = input(type=float, title="Wave 1 weight", defval=-0.7, minval=-1, maxval = 1, step=0.1)
- wave_2_weight = input(type=float, title="Wave 2 weight", defval=0.4, minval=-1, maxval = 1, step=0.1)
- wave_3_weight = input(type=float, title="Wave 3 weight", defval=-0, minval=-1, maxval = 1, step=0.1)
- wave_4_weight = input(type=float, title="Wave 4 weight", defval=0.5, minval=-1, maxval = 1, step=0.1)
- result_smooth = input(type=float, title="smooth", defval=4.16, minval=0.1, step=0.1)
- cmp_interval = input(type=float, title="Compare interval", defval = 7.6, minval = 1, step = 1.0)
- smooth_result=0.0
- getintr(series, pos)=>
- k = floor(pos)
- f = pos - k
- nz(series[k])*(1-f) + nz(series[k+1])*f
- base_function=(linreg_weight*linreg(data_source, measure_period, 0) + ema_weight*ema(data_source, measure_period))
- a = base_function[0]
- b = getintr(base_function,cycle_length)
- c = getintr(base_function,cycle_length*2)
- d = getintr(base_function,cycle_length*3)
- e = getintr(base_function,cycle_length*4)
- wave_1 = a-b
- wave_2 = a-2*b+c
- wave_3 = a-3*b+3*c-d
- wave_4 = a-4*b+6*c-4*d+e
- result = (wave_1*wave_1_weight + wave_2*wave_2_weight + wave_3*wave_3_weight + wave_4*wave_4_weight)
- smooth_result := (nz(smooth_result[1])*(result_smooth-1)+result)/result_smooth
- hist_sr = getintr(smooth_result,cmp_interval)
- plot(wave_1/data_source)
- plot(wave_2/data_source)
- plot(wave_3/data_source)
- plot(wave_4/data_source)
- plot(smooth_result/data_source, title="Control", linewidth=2, color=black)
- plot(hist_sr/data_source, title="Hist", linewidth=2, color=black)
- plot((smooth_result-hist_sr)/data_source, title="Result", style=area, color=#440088)
- hline(0)
Advertisement
Add Comment
Please, Sign In to add comment