- Katılım
- 23 Eki 2020
- Mesajlar
- 1,828
The oscillator below measures a Up/Down bar count against an unchanged bar count. It doesn't use any smoothing so there are no lag effects, and its overBought/Sold signals are quite good in sideways markets. Like most price-based overBought/Sold oscillators, the UpDown osc doesn't like strong trends, so use only when the underlying market trend is weak. MetaStock -> Tools -> Indicator Builder -> New -> copy & paste complete formula: |
|
UpDown Oscillator { Up/Down bar Oscillator v2.0 Measures Up/Down bar count against unchanged bar count. Incorporating automatic overBought/Sold levels. Trade at own risk. ©Copyright 2005-2007 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. http://www.metastocktools.com } { Indicator Inputs } pds:=Input("Lookback periods",1,2600,10); plot:=Input("[1]UpDown Osc, [2]Buy/Sell zones, [3]Signals",1,3,1); { Up/Down ratio } up:=Sum(C>Ref(C,-pds),pds); down:=Sum(C<Ref(C,-pds),pds); neutral:=Max(Sum(C=Ref(C,-pds),pds),1); x:=(up/neutral-down/neutral)*50/pds+50; { Automatic overBought/Sold Osc levels } avg:=Cum(x)/Cum(IsDefined(x)); pk:=Ref(x,-1)=HHV(x,3) AND Ref(x,-1)>avg; pkVal1:=ValueWhen(1,pk,Ref(x,-1)); pkVal2:=ValueWhen(2,pk,Ref(x,-1)); oBought:=Cum(pkVal1)/Cum(IsDefined(pkVal1)); tr:=Ref(x,-1)=LLV(x,3) AND Ref(x,-1)<avg; trVal1:=ValueWhen(1,tr,Ref(x,-1)); trVal2:=ValueWhen(2,tr,Ref(x,-1)); oSold:=Cum(trVal1)/Cum(IsDefined(trVal1)); { OverBought/Sold signals } entry:=x<oSold; exit:=x>oBought; { Clean signals } init:=Cum(IsDefined(entry+exit))=1; bin:=ValueWhen(1,entry-exit<>0 OR init,entry); entry:=bin*(Alert(bin=0,2) OR entry*Cum(entry)=1); exit:=(bin=0)*(Alert(bin,2) OR exit*Cum(exit)=1); { Plot in own window } If(plot=1,oBought,0); {Grey} If(plot=1,avg,0); {Grey} If(plot=1,oSold,0); {Grey} If(plot=1,x,If(plot=2,(x<oSold)-(x>oBought), entry-exit)) |
jose '-) http://www.metastocktools.com | |
| |
Source / From: |