Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // @author LazyBear
- //
- study(title = "Fractal Adaptive Moving Average [LazyBear]", shorttitle="FRAMA_LB", overlay=true)
- length=input(16, title="Period of Fractal AMA (even #)",minval=4,maxval=60)
- w=input(-4.6, title="W", type=float)
- src=hl2
- n3=(highest(high,length)-lowest(low,length))/length
- hd2=highest(high,length/2)
- ld2=lowest(low,length/2)
- n2=(hd2-ld2)/(length/2)
- n1=(nz(hd2[round(length/2)])-nz(ld2[round(length/2)]))/round(length/2)
- dimen=(n1>0 and n2>0 and n3>0 ? (log(n1+n2)-log(n3))/log(2) : 0)
- alpha=exp(w*(dimen-1))
- sc=(alpha<.01 ? .01 : (alpha>1 ? 1 : alpha))
- //prev(x) => not na(x[1]) ? x[1] : 0
- frama=(cum(1)<=2*length ? src : src*sc+nz(frama[1])*(1-sc))
- plot(frama, color=orange, linewidth=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement