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

Re: [amibroker] Create a new WatchList !!



PureBytes Links

Trading Reference Links

Dimitris,

One suggestion to make code shorter:
instead of:

shape=IIf(Counter%10==1,shapeDigit1,
IIf(Counter%10==2 ,shapeDigit2,
IIf(Counter%10==3 ,shapeDigit3,
IIf(Counter%10==4 ,shapeDigit4,
IIf(Counter%10==5 ,shapeDigit5,
IIf(Counter%10==6 ,shapeDigit6,
IIf(Counter%10==7 ,shapeDigit7,
IIf(Counter%10==8 ,shapeDigit8,
IIf(Counter%10==9 ,shapeDigit9,shapeDigit0)))))))));

you can write just:

shape = shapeDigit0 + 2 * (Counter%10);

Now instead of:

shape1=IIf(floor(Counter/10)==1,shapeDigit1,
IIf(floor(Counter/10)==2 ,shapeDigit2,
IIf(floor(Counter/10)==3 ,shapeDigit3,
IIf(floor(Counter/10)==4 ,shapeDigit4,
IIf(floor(Counter/10)==5 ,shapeDigit5,
IIf(floor(Counter/10)==6 ,shapeDigit6,
IIf(floor(Counter/10)==7 ,shapeDigit7,
IIf(floor(Counter/10)==8 ,shapeDigit8,
IIf(floor(Counter/10)==9 ,shapeDigit9,
shapeNone)))))))));


you can write:

shape1 = IIF( Counter < 10, shapeNone, shapeDigit0 + 2 * floor( Counter/ 10 ) );


The effect is the same, but code is much shorter.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, November 07, 2003 7:41 PM
Subject: [amibroker] Create a new WatchList !!


> The top3 MACDs may define a new, on-code, effective WatchList W.
> The effective WL is defined outside the loop and may have any further 
> use, as if it was one of the 64 available WLs. Its use is limited 
> inside the code, we can not call it from another IB window.
> An elementary example is at the end of the code.
> We could say we have a "conditional WatchList".
> 
> // Conditional WatchList creation, by D. Tsokakis, Nov2003
> No=0;
> GraphXSpace=5;
> list = GetCategorySymbols( categoryWatchlist, No );
> R = 0; 
> COUNT=0;// the final COUNT value is the population of the WL
> for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
> {
> SetForeign(sym);
> f=MACD();
> R[BarCount-1-i] = LastValue(ValueWhen(Cum(1)==LastValue(Cum(1)-
> 10),f));
> COUNT=COUNT+1;
> }
> Plot(r,"R",2,2); 
> G=0;L1=LastValue(Cum(1));TOP=3;W="";
> Counter=0;Title="Top3 MACD"+"\n";
> for(K=1;K<=TOP;K++)
> {
> H1=LastValue(HHV(R,COUNT));
> BAR1=LastValue((ValueWhen(R==H1,Cum(1)-1)));
> R[BAR1]=-100000;
> Counter=Counter+1;
> G[L1-CountER]=-H1;
> shape=IIf(Counter%10==1,shapeDigit1,
> IIf(Counter%10==2 ,shapeDigit2,
> IIf(Counter%10==3 ,shapeDigit3,
> IIf(Counter%10==4 ,shapeDigit4,
> IIf(Counter%10==5 ,shapeDigit5,
> IIf(Counter%10==6 ,shapeDigit6,
> IIf(Counter%10==7 ,shapeDigit7,
> IIf(Counter%10==8 ,shapeDigit8,
> IIf(Counter%10==9 ,shapeDigit9,shapeDigit0)))))))));
> shape1=IIf(floor(Counter/10)==1,shapeDigit1,
> IIf(floor(Counter/10)==2 ,shapeDigit2,
> IIf(floor(Counter/10)==3 ,shapeDigit3,
> IIf(floor(Counter/10)==4 ,shapeDigit4,
> IIf(floor(Counter/10)==5 ,shapeDigit5,
> IIf(floor(Counter/10)==6 ,shapeDigit6,
> IIf(floor(Counter/10)==7 ,shapeDigit7,
> IIf(floor(Counter/10)==8 ,shapeDigit8,
> IIf(floor(Counter/10)==9 ,shapeDigit9,
> shapeNone)))))))));
> PlotShapes((Cum(1)==bar1+1)*shape,colorBlue,0,Graph0,5);
> PlotShapes((Cum(1)==bar1+1)*shape1,colorRed,0,Graph0,15);
> Title=Title+WriteVal(Counter,1.0)+")"+WriteVal(H1)+ " ["+WriteVal(L1-
> bar1-1,1.0)+"-" +StrExtract(LIST,L1-BAR1-1)+"]\n";
> w=w+StrExtract(List,L1-bar1-1)+WriteIf(k<top,",","");
> }
> Title=Title+"The topMACD stock is "+StrExtract(w,0);
> 
> Note1: In StrExtract( list, item ) description we read the example
> StrExtract( "MSFT,AAPL,AMD,INTC", 2 ) 
> I could not reproduce the "" but they are not necessary.
> My output is simply MSFT,AAPL,AMD,INTC and it works fine with 
> StrExtract() function.
> 
> Dimitris Tsokakis
> 
> 
> 
> 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 ---------------------~-->
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/mOAaAA/3exGAA/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/