|
Steve, A rhetorical question, but; Have you worked with the bands long enough to have some comments on how they should be worked and evaluated for best performance. I have been trying it as an indicator with subtle results, even a little confusion. Marshall
-------Original Message-------
Date: 05/31/05 15:18:38
Subject: Re: [amibroker] Re: Moving Average Channels
I sent it as an attachment. If you dont receive these posts as e-mails, I guess you wouldn't see it. I have included it below.
Steve
----------------------------------------------------------------
// user defined params
Field = Avg;
MovAvgPds = 13;
LookbackPds = 63;
StepPct = 0.25; // increment bands by this percent each step
WantInChan = 85; // want 85% of bars to be inside channel
// error handling for stocks with very few bars
MovAvgPds = Min( MovAvgPds, BarCount - 3 );
LookbackPds = Min( LookbackPds, BarCount );
// optimization loop
StepAmt = LastValue( Field ) * StepPct / 100; // calculate % for each stock
MovAvg = MA( Field, MovAvgPds );
UpperBand = LowerBand = MovAvg;
KeepLooping = True;
for( Incr = StepAmt; Incr < LastValue( Field ) AND KeepLooping; Incr = Incr + StepAmt )
{
UpperBand = MovAvg + Incr;
LowerBand = MovAvg - Incr;
InChan = High < UpperBand AND Low > LowerBand;
TotalInChan = Sum (InChan, LookbackPds );
PctInChan = LastValue( TotalInChan / Min( LookbackPds, BarsSince( IsEmpty( MovAvg ) ) ) * 100 ); // more error handling
if( PctInChan >= WantInChan )
{
KeepLooping = False;
ChanPts = UpperBand - MovAvg;
ChanPct = ChanPts / MovAvg * 100;
}
}
// plot indicator
Plot( Close, "Close", colorBlack, styleCandle );
Plot( MovAvg, "MA", colorWhite, styleLine|styleNoTitle );
Plot( MovAvgPds, "MA Pd", colorDarkRed, styleOwnScale|styleNoLine|styleNoLabel );
Plot( LookbackPds, "LB Pd", colorDarkRed, styleOwnScale|styleNoLine|styleNoLabel );
Plot( TotalInChan, "Inside Bars", colorDarkRed, styleOwnScale|styleNoLine|styleNoLabel );
Plot( PctInChan, "% Inside Bars", colorDarkRed, styleOwnScale|styleNoLine|styleNoLabel );
Plot( UpperBand, "Upper Band", colorBlue, styleLine|styleNoTitle );
Plot( LowerBand, "Lower Band", colorBlue, styleLine|styleNoTitle );
Plot( ChanPts, "Chan $", colorBlue, styleOwnScale|styleNoLine|styleNoLabel );
Plot( ChanPct, "Chan %", colorBlue, styleOwnScale|styleNoLine|styleNoLabel );
----- Original Message ----- From: "ckinsey2003" <ckinsey2003@xxxxxxxxx> To: <amibroker@xxxxxxxxxxxxxxx> Sent: Tuesday, May 31, 2005 9:27 AM Subject: Re: [amibroker] Re: Moving Average Channels
> Steve, Thanks for fixing it but I don't see the new code ?? <G> > > Ever hopefull, Jack > > > > > > 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 other support material please check also: > http://www.amibroker.com/support.html > > > Yahoo! Groups Links > > > > > > >
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 other support material please check also: http://www.amibroker.com/support.html
|