novacisko

KondiciogramMax

Apr 3rd, 2019
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. //@version=3
  2. study("KondiciogramMax")
  3. data_source = input(type=source, title="Source", defval=close)
  4. measure_period = input(type=integer, title="Measure period", defval=65, minval=1, step=1)
  5. ema_weight = input(type=float, title="EMA weight", defval=0.408163, minval=-1, maxval = 1, step=0.1)
  6. linreg_weight = input(type=float, title="LinReg weight", defval=0.591837, minval=-1, maxval = 1, step=0.1)
  7. cycle_length = input(type=float, title="Desired cycle (bars)", minval=1,defval=14.14, step=0.25)
  8. wave_1_weight = input(type=float, title="Wave 1 weight", defval=-0.7, minval=-1, maxval = 1, step=0.1)
  9. wave_2_weight = input(type=float, title="Wave 2 weight", defval=0.4, minval=-1, maxval = 1, step=0.1)
  10. wave_3_weight = input(type=float, title="Wave 3 weight", defval=-0, minval=-1, maxval = 1, step=0.1)
  11. wave_4_weight = input(type=float, title="Wave 4 weight", defval=0.5, minval=-1, maxval = 1, step=0.1)
  12. result_smooth = input(type=float, title="smooth", defval=4.16, minval=0.1, step=0.1)
  13. cmp_interval = input(type=float, title="Compare interval", defval = 7.6, minval = 1, step = 1.0)
  14.  
  15. smooth_result=0.0
  16.  
  17. getintr(series, pos)=>
  18. k = floor(pos)
  19. f = pos - k
  20. nz(series[k])*(1-f) + nz(series[k+1])*f
  21.  
  22.  
  23. base_function=(linreg_weight*linreg(data_source, measure_period, 0) + ema_weight*ema(data_source, measure_period))
  24. a = base_function[0]
  25. b = getintr(base_function,cycle_length)
  26. c = getintr(base_function,cycle_length*2)
  27. d = getintr(base_function,cycle_length*3)
  28. e = getintr(base_function,cycle_length*4)
  29. wave_1 = a-b
  30. wave_2 = a-2*b+c
  31. wave_3 = a-3*b+3*c-d
  32. wave_4 = a-4*b+6*c-4*d+e
  33.  
  34. result = (wave_1*wave_1_weight + wave_2*wave_2_weight + wave_3*wave_3_weight + wave_4*wave_4_weight)
  35. smooth_result := (nz(smooth_result[1])*(result_smooth-1)+result)/result_smooth
  36. hist_sr = getintr(smooth_result,cmp_interval)
  37.  
  38. plot(wave_1/data_source)
  39. plot(wave_2/data_source)
  40. plot(wave_3/data_source)
  41. plot(wave_4/data_source)
  42. plot(smooth_result/data_source, title="Control", linewidth=2, color=black)
  43. plot(hist_sr/data_source, title="Hist", linewidth=2, color=black)
  44. plot((smooth_result-hist_sr)/data_source, title="Result", style=area, color=#440088)
  45.  
  46. hline(0)
Advertisement
Add Comment
Please, Sign In to add comment