Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 5/8/2010(UTC) Posts: 28 Location: Mumbai (India)
Thanks: 1 times
|
method:=Input("Method (1=Cycle, 2=Volatility, 3=Combined): ", 1,3,1);
{-----Begin Cycle Method----------}
plot:=Zig(MESASineWave(70),10,%);
top:=plot<ref(plot,-1) AND Ref(plot,-1)>Ref(plot,-2);
NumberOfPeaks:=Cum(top);
BarsBetweenPeaks:=If(top,Ref(BarsSince(top),-1),0);
TotalBarsBetPeaks:=Cum(BarsBetweenPeaks);
AvgBarsBetweenPeaks:=TotalBarsBetPeaks/NumberOfPeaks;
LookBackMethod1:=Int(Rnd(AvgBarsBetweenPeaks/2));
{-----Begin Normalized Volatility Method----------}
Volatility:=(LinRegSlope((STE(C,20)/C)*100 ,9)/If(STE((STE(C,20)/C)*100,9)=0,.0001,STE((STE(C,20)/C)*100,9))) *100;
divisor:=If(volatility<=0,1-(Abs(volatility)/1000),1+(Abs(volatility)/1000));
{the smaller the divisor(i.e., higher volatility) the shorter the lookback periods}
LookbackMethod2:=20/(1.5*divisor);
Lookbackmethod3:=LookbackMethod1/(1.5*divisor);
{-----Final Calculation and Plot------}
{Note: Longer moving average is FIXED at twice the shorter MA}
If(method=1,
OscP(LastValue(Rnd(0.25*LookbackMethod1)+PREV-PREV),LastValue(Rnd(LookbackMethod1)+PREV-PREV),E,$),
If(method=2,
OscP(LastValue(Rnd(0.25*LookbackMethod2)+PREV-PREV),LastValue(Rnd(LookbackMethod2)+PREV-PREV),E,$),
If(method=3,
OscP(LastValue(Rnd(0.25*LookbackMethod3)+PREV-PREV),LastValue(Rnd(LookbackMethod3)+PREV-PREV),E,$),0)))
======================================
The above formula is of MS 11 Adaptive Volume Oscillator.
Can any one add the required code where in I can change the color when the indicator oscillates below and above 0.
|