PureBytes Links
Trading Reference Links
|
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
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> 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/
|