Advertisement
Guest User

Fractal Adaptive Moving Average [TradingView]

a guest
Apr 26th, 2014
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. //
  2. // @author LazyBear
  3. //
  4. study(title = "Fractal Adaptive Moving Average [LazyBear]", shorttitle="FRAMA_LB", overlay=true)
  5. length=input(16, title="Period of Fractal AMA (even #)",minval=4,maxval=60)
  6. w=input(-4.6, title="W", type=float)
  7. src=hl2
  8. n3=(highest(high,length)-lowest(low,length))/length
  9. hd2=highest(high,length/2)
  10. ld2=lowest(low,length/2)
  11. n2=(hd2-ld2)/(length/2)
  12. n1=(hd2[length/2]-ld2[length/2])/(length/2)
  13. dimen=(n1>0 and n2>0 and n3>0 ? (log(n1+n2)-log(n3))/log(2) : 0)
  14. alpha=exp(w*(dimen-1))
  15. sc=(alpha<.01 ? .01 : (alpha>1 ? 1 : alpha))
  16. frama=(cum(1)<=2*length ? src : src*sc+nz(frama[1])*(1-sc))
  17. plot(frama, color=orange, linewidth=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement