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

RE: [amibroker] Re: WMA problem



PureBytes Links

Trading Reference Links



The problem starts with the AB WMA assigning values to the empty spaces in WMA values at the beginning of the data series. It keeps doing that until there are approximately WMA period * (Expand Period + 1) bars available which is apparently considered the 1st bar with good or usable data. In addition I really don’t understand why so many bars are required: One would think that to plot the first expansion bar only (WMA Period + Expansion Period) bars are required.  Also the expandperiod itself seems to be off: When selecting expandperiod =n  it expands n+1. This is easy to check with the new XBar indicator of the cross Hair.  It seems a typical case of 5 trees and 5 spaces. Below an AFL which demonstrates it in grinding detail.

 

Before I switched over for compatibility, when it became available, to TJ’s Timeset/restore/expand stuff I used my own time compressed formulas. Thise had the additional advantage that I could select a rolling week, month what provided me with half an interval earlier data. However, I have no idea on all my hard drives where they are. All I know I have them, the question is:where?

/*

1. Click first on WMAFormVerON|Off parameter to see the difference between the common WMA and the AB-WMA

2. Thereafter turn the parameter off and play with the WMAON_Off parameter with various periods

3. For comparison an EMA is included.

4. Minimum # of bars required = WMA period * (Expand Period + 1) bars (approximately).

*/

 

Title = EncodeColor(4)+ _DEFAULT_NAME()+";  "+EncodeColor(1) + StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g (%.1f%%)

{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );     

 

WMAFormulaVerON_Off=ParamToggle("WMAFormVerON|Off","WMAVerON|Off",1);

WMAON_Off=ParamToggle("WMA ON|Off","WMAON|Off",1);

MAPeriod=Param("MAPeriod",9,1,40,1);

ExpandPeriod=Param("ExpandPeriod",5,1,100,1);

///////////////////////////WMA Formula Verification////////////////////////////////////////

if (WMAFormulaVerON_Off==0)

{

C1=Ref(C,-1);C2=Ref(C,-2);C3=Ref(C,-3);C4=Ref(C,-4);

WMASelf5 = (5*C+ 4*C1+ 3*C2+ 2*C3+ 1*C4)/15;

Plot(WMASelf5,"WMA - Joris",colorGreen,5);

Plot(WMA(C,5),"WMA - AB",colorRed,5);

}

///////////////////////////TimeFrameSet/Restore/Expand() Verification////////////////////////////////////////

if (WMAFormulaVerON_Off==1)

{

TimeFrameSet( inDaily ); // switch now to Daily

maDEMA = EMA( C, MAPeriod); TimeFrameRestore(); // restore time frame to original

 

TimeFrameSet( inDaily*ExpandPeriod); // switch now to Daily

maD5EMA = EMA( C, MAPeriod);

TimeFrameRestore(); // restore time frame to original

 

Plot( Close, "Price", colorBlack, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( maDEMA , inDaily ),"\n"WriteVal(MAPeriod,1.0)+"bar EMA from Daily bars", colorRed );

Plot( TimeFrameExpand( maD5EMA , inDaily*ExpandPeriod),  WriteVal(MAPeriod,1.0)+" bar EMA from Daily*"+WriteVal(ExpandPeriod,1.0)+" bars", colorGreen,expandFirst );

if(WMAON_Off==0)

{

TimeFrameSet( inDaily ); // switch now to Daily

maD = WMA( C, MAPeriod);

TimeFrameRestore(); // restore time frame to original

 

TimeFrameSet( inDaily*ExpandPeriod); // switch now to Daily

maD5 = WMA( C, MAPeriod);

TimeFrameRestore(); // restore time frame to original

MinBarsReq = MAPeriod * (ExpandPeriod + 1);

Plot( Close, "Price", colorBlack, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( maD, inDaily ),"\n"+ WriteVal(MAPeriod,1.0)+" bar WMA from Daily bars", colorBlue );

Plot( TimeFrameExpand( maD5, inDaily*ExpandPeriod),  WriteVal(MAPeriod,1.0)+" bar WMA from Daily*"+WriteVal(ExpandPeriod,1.0)+" bars", colorViolet );

Plot( TimeFrameExpand( maD5, inDaily*ExpandPeriod), "Minimum bars required = "+WriteVal( MinBarsReq,1.0), colorViolet );

}

}

 

 

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of johncw_97
Sent: Wednesday, September 16, 2009 5:46 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: WMA problem

 

 

--- In amibroker@xxxxxxxxxxxxxxx, "rkp1" <ralphpatriquin@xxx> wrote:
>
> Hi folks. I'm having a problem with the WMA function in TimeFrames. When I use the following code in the default Price chart:
>
> TimeFrameSet(inDaily * 5);
> mw = WMA(C, 39);
> TimeFrameRestore();
> mwx = TimeFrameExpand(mw, inDaily * 5);
> Plot(mwx, "WMA", colorRed, styleThick);
>
> I get 4 {EMPTY} bars followed by almost 200 bars starting at -9,500,000,256.00 to -12,820,173.00 before the WMA settles down. Could others verify this, and is there a way to eliminate it?
>
> Thanks,
>
> Ralph
>

About 6 years ago, I had the same experience. My workaround
is an AFL function wrapper for WMA() so that when used with
TF functions, produces what I expect. I am not on my own
computer now - email if you want the wrapper and I will send it
to you.

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.100/2375 - Release Date: 09/16/09 05:51:00



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___