PureBytes Links
Trading Reference Links
|
Dave,
Prior to Amibroker adding the ability to loop, I wrote the code listed at
the end of this note.
Will someone with programming experience please convert to looping.
That is the reason I
am not posting the code.
SEE AT END OF EMAIL FOR CODE. POST IN "INDICATOR".
Frank
At 11:08 PM 9/10/03 -0400, you wrote:
>does anyone know how to automatically calculate channel (envelope)
widths
>like dr. elder intends? far as I can tell, this is idiosyncratic to
him;
>everywhere else I've found references to channels, they just mean
the
>general idea of constant ratio above and below an EMA.
>
>here's what he says in Come Into My Trading Room:
>
>----------
>Upper channel line = EMA + (EMA * Channel coefficient)
>Lower channel line = EMA - (EMA * Channel coefficient)
>
>A well-drawn channel contains the bulk of prices, with only a few
extremes
>poking out. Adjust the coefficient until the channel contains
approximately
>95 percent of all prices for the past several months. Mathematicians
call
>the "second standard deviation channel". Most software
packages make this
>adjustment very easy.
>----------
>
>I don't know how to turn the reference to standard deviation into
code. he
>specifically contrasts channels to Bollinger Bands, which are plotted
some
>number of standard deviations away from the EMA.
>
>anyone understand this better than me?
>
>dave
**********************************************************************************************************************
/*93% Bands
Prior to Looping added to Amibroker, a "crude" looping program to get bands where all of the price action of a stock is 93% included within bands. Bands are computed around a simple 21 day moving average of the close with a lookback period of one year (252 trading days)
*/
MovAvg = MA(C,21);
FirstSweep = 0;Bands = 0;Step = 1;Kntr = 0;
Lookback = 252;Pcnt = 0;BandFlag = 0;Step1 = .1;
BandFlag1 = 0;Bands = 0;InsideBands1 = 0;Pcnt1 = 0;
//MS=GetExtraData("MONEYSTREAM");//TC2000 moneystream indicator
/* Insidebands look to see if the high is less than the moving average plus an incrememted percent of moving average, and the low is more than the moving average
minus an incremented percent of moving average
Counters and flags are set to compute bands that will as closely as possible
account for price action remaining within 93% bands.
*/
//1
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg* Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//2
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg* Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//3
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//4
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//5
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg* Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//6
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//7
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//8
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg* Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//9
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg* Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//10
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//11
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag == 1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//12
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg+ MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//13
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//14
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg- MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//15
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg+ MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//16
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg* Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//17
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//18
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//19
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//20
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//21
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//22
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//23
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//24
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//25
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//26
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//27
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//28
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//29
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//30
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//31
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//32
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//33
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//34
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//35
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//36
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//37
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//38
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//39
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//40
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//41
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//42
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg* Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//43
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//44
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//45
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//46
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//47
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//48
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//49
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
//50
Kntr = Kntr + Step;
InsideBands = IIf(High < (MovAvg + MovAvg * Kntr/100) AND Low > (MovAvg - MovAvg * Kntr/100),1,0);
FirstSweep = IIf(FirstSweep == 0 AND 100 -100*LastValue(Sum(InsideBands,Lookback))/Lookback < 8, Kntr,FirstSweep);
BandFlag = IIf(Ref(BandFlag,-1) == 0 AND 100*LastValue(Sum(InsideBands,Lookback))/Lookback > 93,1,Ref(BandFlag,-1) );
Pcnt = IIf(Pcnt == 0 AND BandFlag ==1 AND FirstSweep > 0,100 *LastValue(Sum(InsideBands,252))/252,Pcnt);
/* Last steps set bands to within one-tenth*/
//Mandate a 21% Band if Percent = 0;
FirstSweep = IIf(Pcnt == 0, 21,FirstSweep);
Kntr1 = FirstSweep - 1;
//X.1
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.2
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.3
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.4
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.5
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands> 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.6
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.7
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.8
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.9
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//X.10
Kntr1 = Kntr1 + Step1;
InsideBands1 = IIf(High < (MovAvg + MovAvg * Kntr1/100) AND Low > (MovAvg - MovAvg * Kntr1/100),1,0);
Bands = IIf(Bands == 0 AND 100 - 100*LastValue(Sum(InsideBands1,Lookback))/Lookback < 8, Kntr1,Bands);
Pcnt1 = IIf(Bands > 0,100 *LastValue(Sum(InsideBands1,252))/252,Pcnt1);
//Mandatee Bands = FirstSweep if Bands = 0
Bands = IIf(Bands == 0,FirstSweep,Bands);
PlotOHLC(O,H,L,C,"Bar Chart with 21 Day MA",1,styleBar);
Plot(MovAvg,"",4);
Plot(MovAvg + MovAvg*Bands/100,"",4);
Plot(MovAvg - MovAvg*Bands/100,"",4);
//Plot(MS,"",6,1|styleOwnScale);//TC2000 Moneystream
Title = Name() + " Bands = " + WriteVal(2*Bands,1.1) + "%" + " (" + WriteVal(Pcnt1,1.2) + "%)" + " BandWidth = " + WriteVal(2*MovAvg * Bands/100,1.2)+ " Points" + "\nClose = " + WriteVal(C,1.2)+ " Upper Band = " + WriteVal(MovAvg + MovAvg*Bands/100,1.2);// + "\nMoneyStream is Blue Line";
***********************************************************************************************************************
>
>
>------------------------ Yahoo! Groups Sponsor ---------------------~-->
>Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
>Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
>http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
>---------------------------------------------------------------------~->
>
>Send BUG REPORTS to bugs@xxxxxxxxxxxxx
>Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
>-----------------------------------------
>Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>(Web page: http://groups.yahoo.com/group/amiquote/messages/)
>--------------------------------------------
>Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
Yahoo! Groups Sponsor
ADVERTISEMENT
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|