PureBytes Links
Trading Reference Links
|
Ok i'll try it and come back on this subject in few days. it that
represents for me one of the key of a EOD winning trading system.
I send the attachment comparing osake hermann and manual.
Thanks for your help.
> Stephane,
>
> The simplest way to debug any code is to insert _TRACE() statements inside
> the loops and use DebugView. That way you will get a complete report
> of each
> step through the code and each step through each loop.
>
> herman
>
>
>
> -----Original Message-----
> From: Stephane Carrasset [mailto:s.carrasset@xxxxxxxxxxx]
> Sent: Tuesday, August 03, 2004 2:38 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] average of top ranked tickers in a given
> watchlist
>
>
> Hermann & All,
>
> I have tried two differents codes to built an average of top n tickers
> of a watchlist ( looks like a real time composite)
> unfortunately the two codes return wrong results.
>
> I have tried your code and a Tomasz code written with osaka plugin (
> the formulas are below )
> I have reduced The watchlist zero to 5 tickers and want the average
> for an idicator of the 3 first tickers for each bar.
> I have choosen the RSI ( a positive indicator)
> So i can check manually the result
>
> for example the image attached speak itself for the last bar .
>
> I hope the next pastis.dll will save us... ^_^ ( thanks dingo for all
> these information)
>
>
>
>
> FORMULAS
>
> //////////OSAKA////////////
> /*
> As for hints: you would do the following:
> 1. iterate through watch list and store scores (in case of osaka plugin
> osTabSetNumber)
> 2. find top ranked symbols (this can be done even entriely in AFL as
> Dimitris has shown,
> or using Osaka plugin sort capability - osTabSort function)
> 3. create average from top ranked symbols.
> Below is the code that uses Osaka plugin 1.4.
>
> */
>
> osInitialize();
> List = GetCategorySymbols(categoryWatchlist, 0 ); // <-- change wl
> number here
> table=osTabCreate();
> // setup columns
> osTabAddColumn( "Ticker", 2, table, 25 );
> for( j = 0; j < BarCount; j++ )
> {
> osTabAddColumn( "Score"+j, 1, table );
> osTabAddColumn( "Close"+j, 1, table );
> }
> // CALCULATING SCORES and saving them to the table
> for(i=0; ( ticker = StrExtract( List, i ) ) != ""; i++)
> {
> SetForeign(ticker);
> osTabSetString( ticker, i, 0, table );
> score = RSIa(C,14); // YOUR SCORE CALCULATION HERE
> for( j = 0; j < BarCount; j++)
> {
> osTabSetNumber( abs( Nz( score[ j ] ) ), i, 2 * j + 1, table );
> osTabSetNumber( Close[ j ], i, 2 * j + 2, table ); // for calculation of
> average
> }
> }
> // you can export for debugging
> // osTabExport( "test.csv", ",", table );
> // SORTING SCORES AND finding top ranks:
> average = 0; // init avarage
> for( j = 0; j < BarCount; j++)
> {
> osTabSort( table, 2 * j + 1, False );
> average[ j ] = 0;
> topnum = 3; // TOPNUM
> for( k = 0; k < topnum ; k++ ) //
> {
> fc = osTabGet( k, 2 * j + 2, table );
> average[ j ] = average[ j ] + fc;
> }
> average[ j ] = average[ j ]/topnum; // calculate average from top N
> symbols at given bar
> }
> osTabDelete( table );
> Filter=1;
> AddColumn(average, "AVG top10 (each bar different)" );
> Plot( average, "AVG top10 (each bar different)", colorRed );
>
> ///////////END OSAKA //////////////////////////
>
>
> ///////////////HERMAN/////////////////
> function GetScore( )
> {
> return RSIa(C,14); // Substitute your function
> }
>
> function padString( InString, Length )
> {
> SpaceFill = " ";
> SL = StrLen(InString);
> NS=StrLeft(SpaceFill, Length-SL);
> return NS+Instring;
> }
>
> procedure getPositionScores( WatchList, BarNum, NumTickers )
> {
> TickerList= GetCategorySymbols( categoryWatchlist, WatchList);
> CurrentTicker = Name();
> TickerScoreList = "";
>
> // Create Scores array
> for( n=0; (Ticker=StrExtract( TickerList, n)) != ""; n++)
> {
> SetForeign(Ticker);
> TickerScores[n] = LastValue(ValueWhen(BarIndex() == BarNum,
> SelectedValue(GetScore())));
> TickerIndex[n] = n;
> }
>
> TickerCount= n;
>
> // Sort Tickers by rank
> for(i = n; i>=0; i--)
> {
> for (j = 1; j <= i; j++)
> {
> if (TickerScores[j-1] > TickerScores[j])
> {
> temp = TickerScores[j-1]; TickerScores[j-1] = TickerScores[j];
> TickerScores[j] = temp;
> temp = TickerIndex[j-1]; TickerIndex[j-1] = TickerIndex[j];
> TickerIndex[j] = temp;
> }
> }
> }
>
> TopTickerList = TopTickerNum = TopTickerScore = "";
> i=0; P=10; TopComposite = 0;
> if( NumTickers > TickerCount ) NumTickers = TickerCount;
>
> // Format Top numTickers and create composite
> for(n=TickerCount; n>=TickerCount-NumTickers; n--)
> {
> T5[i++] = TickerIndex[n];
> TopTickerList = TopTickerList +
> PadString(StrExtract(Tickerlist,T5[i-1]),P)+",";
> TopTickerScore = TopTickerScore +
> PadString(NumToStr(TickerScores[n],1.3),P)+",";
> TopTickerNum = TopTickerNum +
> PadString(NumToStr(TickerIndex[n],1.0),P)+",";
> TopComposite = TopComposite + getScore();
> }
>
> VarSet("TopComposite",TopComposite/numtickers);
> StaticVarSetText("TopTickerList",TopTickerList);
> StaticVarSetText("TopTickerScore ",TopTickerScore );
> StaticVarSetText("TopTickerNum ",TopTickerNum );
> }
>
> WatchList = Param("WatchList",0,0,1,1);
> BarNum = SelectedValue(BarIndex());
> NthScore = Param("Nth TickerDown",3,0,100,1);
> // TOPNUM
> getPositionScores( WatchList, BarNum, NthScore );
> TopTickerScore =StaticVarGet("TopTickerScore ");
> TopTickerList=StaticVarGet("TopTickerList");
> TopTickerNum =StaticVarGet("TopTickerNum ");
> Plot(VarGet("TopComposite") ,"",2,1);
>
> Title =
> TopTickerList + "\n"+
> TopTickerScore + "\n"+
> TopTickerNum + "\n"+
> "Number "+NumToStr(NthScore+1,1.0)+" from the Top:
> "+StrExtract(TopTickerList ,NthScore);
> //////////////////END HERMAN/////////////////////////////
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
Attachment:
Description: ""
|