Thanks for your earlier help, admin.
As always, not the Holy Grail, but perhaps just a warning sign to help make a decision if you feel you are in an overbought or oversold position.
Play with the parameters to suit your trading style. Let me know coding errors or improvements. Thanks.
LINE CHART FORMAT
[description=" Drifter. Measures how far closing price tends to drift away before reverting to mean"] [target=default]
cn := input("MA close time periods",10,1); cma := ma(c,cn,simple); drift := c-cma; n := input("MA drift time periods",5,1); method := inputma("Driftma method",SIMPLE); driftma := hist(ma(drift,n,method),1); driftup := if(c>=cma,c-cma,undefined); driftdwn := if(c<cma,cma-c,undefined)*-1; sdfactor := input("Multiple of stdev",1.0,0);
avedriftup := hist(ma(driftup,250,s),1); {average amount drifts up over last 250 periods} sd_driftup := hist(stdev(driftup,250),1); {st dev amount drifts up over last 250 periods} extremdriftup :=avedriftup+(sd_driftup*sdfactor);
avedriftdwn := hist(ma(driftdwn,250,s),1); {average amount drifts down over last 250 periods} sd_driftdwn := hist(stdev(driftdwn,250),1); {st dev amount drifts down over last 250 periods} extremdriftdwn :=avedriftdwn+(sd_driftdwn*sdfactor)*-1;
[horzline=0]
[color=blue;name=drift] drift;
[color=red;name=driftma] driftma;
[color=purple;name=extremdriftup] extremdriftup;
[color=purple;name=extremdriftdwn] extremdriftdwn;
...............................
RIBBON FORMAT
[description=" Drifter. Measures how far closing price tends to drift away before reverting to mean"] [target=ribbon]
cn := input("MA close time periods",10,1); cma := ma(c,cn,simple); drift := c-cma; n := input("MA drift time periods",5,1); method := inputma("Driftma method",SIMPLE); driftma := hist(ma(drift,n,method),1); driftup := if(c>=cma,c-cma,undefined); driftdwn := if(c<cma,cma-c,undefined)*-1; sdfactor := input("Multiple of stdev",1.0,0);
avedriftup := hist(ma(driftup,250,s),1); {average amount drifts up over last 250 periods} sd_driftup := hist(stdev(driftup,250),1); {st dev amount drifts up over last 250 periods} extremdriftup :=avedriftup+(sd_driftup*sdfactor);
avedriftdwn := hist(ma(driftdwn,250,s),1); {average amount drifts down over last 250 periods} sd_driftdwn := hist(stdev(driftdwn,250),1); {st dev amount drifts down over last 250 periods} extremdriftdwn :=avedriftdwn+(sd_driftdwn*sdfactor)*-1;
[color=darkgreen] [fillstyle=solid] drift>=driftma;
[color=red] [fillstyle=solid] drift<driftma;
[color=white]
-------------
|