[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Help with Variable moving average



PureBytes Links

Trading Reference Links

I am trying to write a simple "Variable Moving Average"(VMA) in 
AFL.  Please excuse the poor coding.  I have searched the web and 
found the formula for VMA:

VMA = (0.78*(volatility index) * close) + (1-0.078 * volatility 
index)*yesterday's VMA 

volatility index = Chande Momentum Oscillator(CMO) of 9 Periods.

I then went to the Amibroker Lib. and found the Chande Momentum 
Oscillator and took a function( thanks to the Author for that!).

Here is my code, but I have a question about the periods of the 
VMA.  Does it affect the actual MA or does it affect the CMO period?

function VR_Fnc(VR_periods) {
//VR_Fnc = Chande Momentum Oscillator 
local cmo_1;
local cmo_2;
local cmo;

cmo_1=Sum( IIf( C > Ref( C, -1 ) , ( C - Ref( C ,-1 ) ) ,0 ) , 
VR_periods) ;
cmo_2=Sum( IIf( C < Ref( C ,-1 ) , ( Ref( C ,-1 ) - C ) ,0 ) , 
VR_periods);
cmo=100 * (( cmo_1 -cmo_2) /( cmo_1+cmo_2));
return cmo;
}
VR = VR_Fnc(9);

//Definition of VMA   -  VMA = (0.78*(volatility index) * close) + 
(1-0.078 * volatility index)*yesterday's VMA 

Vma = 1; //get error if not initialized 
VMA = ((0.0788 * VR) * Close) + ((1- 0.078 * VR) * Ref(VMA,-1));

Plot(C,"Close",colorBlack,styleLine);
Plot(VMA, "VMA", colorRed, styleLine);


Any help would be great!

Thanks

Robert



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/