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

[amibroker] top5/bottom5 [was Re: RSI -Last 5 highest ]



PureBytes Links

Trading Reference Links

Ooops !
We dont need the multiple IIf statement !!
Here is the top10/bottom10 with the respective digits !!
The multiple IIf may be replaced with one single line
shape=2*Counter+31;
which will do the same job !!

// Top10/bottom10 of an oscillator
R= StochD();// Any [0,100] oscillator
Plot(R,"",colorYellow,1);
X0=R;Y0=R;
L1=LastValue(Cum(1));
N=50;// lookback period
TOP=10;
Counter=0;
Title=Name()+",\n";
for(K=1;K<=TOP;K++)
{
X1=LastValue(HHV(X0,n));
BAR1=LastValue((ValueWhen(X0==X1,Cum(1)-1)));
X0[BAR1]=-10;
Y1=LastValue(LLV(Y0,n));
BAR2=LastValue((ValueWhen(Y0==Y1,Cum(1)-1)));
Y0[BAR2]=110;
Counter=Counter+1;
shape=2*Counter+31;
PlotShapes((Cum(1)==bar1+1)*shape,colorRed,0,Graph0,5);
PlotShapes((Cum(1)==bar2+1)*shape,colorBrightGreen,0,Graph0,5);
Title=Title+"top"+WriteVal(Counter,1.0)+")"+WriteVal(X1)+" ["+WriteVal
(L1-bar1-1,1.0)+"]"+"    bottom"+WriteVal(Counter,1.0)+")"+WriteVal
(Y1)+" ["+WriteVal(L1-bar2-1,1.0)+"]"+"\n";
}
COLOR=IIf(X0==-10,colorRed,IIf(Y0==110,colorBrightGreen,colorBlack));
Plot((Cum(1)>L1-N)*R,"",COLOR,2);
Plot(0,"",1,1);
GraphXSpace=3;
/*
shapedigit1 (up position) is equivalent to 35
shapeDigit1 (dn position) is equivalent to 36 
and so on, until
shapedigit9==51 up
shapedigit9==52 dn
*/

Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> Enjoy also the [more detailed]
> 
> // Top5/bottom5 for the last N bars of an oscillator
> R= StochD();// Any [0,100] oscillator
> Plot(R,"",colorYellow,1);
> X0=R;Y0=R;
> L1=LastValue(Cum(1));
> N=50;// lookback period
> TOP=5;
> Counter=0;
> Title=Name()+",\n";
> for(K=1;K<=TOP;K++)
> {
> X1=LastValue(HHV(X0,n));
> BAR1=LastValue((ValueWhen(X0==X1,Cum(1)-1)));
> X0[BAR1]=-10;
> Y1=LastValue(LLV(Y0,n));
> BAR2=LastValue((ValueWhen(Y0==Y1,Cum(1)-1)));
> Y0[BAR2]=110;
> Counter=Counter+1;
> shape=IIf(Counter==1,shapeDigit1,
> IIf(Counter==2 ,shapeDigit2,
> IIf(Counter==3 ,shapeDigit3,
> IIf(Counter==4 ,shapeDigit4,shapeDigit5))));
> PlotShapes((Cum(1)==bar1+1)*shape,colorRed,0,Graph0,5);
> PlotShapes((Cum(1)==bar2+1)*shape,colorBrightGreen,0,Graph0,5);
> Title=Title+"top"+WriteVal(Counter,1.0)+")"+WriteVal(X1)+" 
["+WriteVal
> (L1-bar1-1,1.0)+"]"+"    bottom"+WriteVal(Counter,1.0)+")"+WriteVal
> (Y1)+" ["+WriteVal(L1-bar2-1,1.0)+"]"+"\n";
> }
> COLOR=IIf(X0==-10,colorRed,IIf
(Y0==110,colorBrightGreen,colorBlack));
> Plot((Cum(1)>L1-N)*R,"",COLOR,2);
> Plot(0,"",1,1);
> GraphXSpace=3;
> 
> It works for [0,100] oscillators and marks the top5 [red points] 
and 
> the bottom5 [green points], their rank, their value and how many 
bars 
> ago .
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "run_for_your_life2003" 
> <run_for_your_life2003@xxxx> wrote:
> > Thanks for your help. That's exactly what I wanted!
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" 
> > <TSOKAKIS@xxxx> wrote:
> > > You may see both top10 and bottom10 in the same graph.
> > > 
> > > // Highest 10/Lowest 10 from 200
> > > R=RSI();
> > > X0=RSI();Y0=RSI();
> > > L1=LastValue(Cum(1));
> > > N=200;// the lookback period
> > > TOP=10;// the topX calibration
> > > for(K=1;K<=TOP;K++)
> > > {
> > > X1=LastValue(HHV(X0,n));
> > > BAR1=LastValue((ValueWhen(X0==X1,Cum(1)-1)));
> > > X0[BAR1]=-10;
> > > Y1=LastValue(LLV(Y0,n));
> > > BAR2=LastValue((ValueWhen(Y0==Y1,Cum(1)-1)));
> > > Y0[BAR2]=110;
> > > }
> > > COLOR=IIf(X0==-10,colorRed,IIf
> > (Y0==110,colorBrightGreen,colorBlack));
> > > Plot(IIf(Cum(1)>L1-N,R,-1E10),"RSI",COLOR,2);
> > > 
> > > For easier reading select Scaling : Custom min=0, max=100
> > > Dimitris Tsokakis
> > > --- In amibroker@xxxxxxxxxxxxxxx, "run_for_your_life2003" 
> > > <run_for_your_life2003@xxxx> wrote:
> > > > I read this on the message board but what do I add to the AFL 
> > code 
> > > > that it also looks at the lowest low 5 values  of the 200 
bars.
> > > > 
> > > > Could anyone tell me what to add so it looks at the lowest 5 
> RSI 
> > > > values  together with the last 5 highest values of the 200 
> bars.?
> > > > I'm be using the 50% mark as the zero mark of the RSI.
> > > > 
> > > > Comments with AFL code:
> > > > /*
> > > > 
> > > > Since we paint the top 10 points Outside the loop execution, 
we 
> > > know 
> > > > all the rest details, when it happened, the respected value, 
> > > Outside 
> > > > the loop, 
> > > > consequently the result is ready for any further use.
> > > > The trick was to find the Highest value, find the bar it 
> happens 
> > > AND 
> > > > then, in the very next step, make this value negative [-10 in 
> > the 
> > > > example]. 
> > > > The next cycle of the loop will search for the 2nd Highest 
> value 
> > > etc.
> > > > for other indicators, replace -10 with another, enough 
negative 
> > > > value, lower than the usual indicator values, to ensure that 
> you 
> > > > will excude this
> > > > bar from the next cycle of the loop. if you do NOT know the 
> > > negative 
> > > > values, a Lowest(Indicator)-1 is enough.
> > > > */
> > > > 
> > > > // Top 5 from 200
> > > > R=RSI();
> > > > L0=RSI();
> > > > L1=LastValue(Cum(1));
> > > > N=200;// the lookback period
> > > > TOP=5;// the topX calibration
> > > > for(K=1;K<=TOP;K++)
> > > > {
> > > > H1=LastValue(HHV(L0,n));
> > > > BAR1=LastValue((ValueWhen(L0==H1,Cum(1)-1)));
> > > > L0[BAR1]=-10;
> > > > }
> > > > Plot(IIf(Cum(1)>L1-N,R,-1E10),"",IIf(L0==-
> > > 10,colorRed,colorBlack),2);
> > > > 
> > > >  Title = Name()+"   "+FullName()+
> > > > "  RSI Count=200  Last 5 High = Red (Sell Zone)";


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Remanufactured Ink Cartridges & Refill Kits at MyInks.com for: HP $8-20. Epson $3-9, Canon $5-15, Lexmark $4-17. Free s/h over $50 (US & Canada).
http://www.c1tracking.com/l.asp?cid=6351
http://us.click.yahoo.com/0zJuRD/6CvGAA/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/