logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kthakker0  
#1 Posted : Wednesday, October 17, 2012 6:45:59 AM(UTC)
kthakker0

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.
jjstein  
#2 Posted : Wednesday, October 17, 2012 7:28:05 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
You need to use the CODE tags (see below) for your code to post correctly.
mstt  
#3 Posted : Wednesday, October 17, 2012 2:49:33 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

As discussed in Decemeber 2009 and two subsequent MSTT issues, the Adaptive indicators released with MetaStock version 11 are suspect in several ways.

Firstly as I recall, most adaptive indicators have 6 PREV functions, and some as many as 12 PREV functions. Two thirds of these can be easily eliminated simply by rearranging the "Final Calculation and Plot" section of code shown below...

Code:

{-----Final Calculation and Plot------}

If(method=1,
RSquared(C,LastValue(Rnd(LookbackMethod1)+PREV-PREV)),
If(method=2,
RSquared(C,LastValue(Rnd(LookbackMethod2)+PREV-PREV)),
If(method=3,
RSquared(C,LastValue(Rnd(LookbackMethod3)+PREV-PREV)),0)))


then becomes...

Code:

{-----Final Calculation and Plot------}

Method:=Rnd(If(Method=1,LookbackMethod1,
If(Method=2,LookbackMethod2,Lookbackmethod3)));
rSquared(C,LastValue(Method+PREV-PREV));


Secondly, results from either of the PREV layouts shown above generate irregular but persistent anomalies that are clearly not the correct value. These anomalies appear in all adaptive functions and are not confined to just rSquared().

Thirdly, PREV can be eliminated from most adaptive functions simply by repacing the standard MetaStock function with the Forum DLL version or by recreating the function with a combination of MFL and the Forum DLL. By eliminating PREV the above mentioned anomalies disappear and the shackles are removed in terms of execution speed.

Finally, the Cycle method of generating an adaptive lookback range, as used in methods 1 and 3, is fundamentally flawed. It can be easily demonstrated that the cycle method's "adaptive" ability progressively reduces as the amount of data loaded increases. Therefore, it would seem that only method 2 is of any practical use.

Roy
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.