Can someone help on the proper use of 'addtextcolumn' function ???

#11
Using the logic within a ranking column...

Dear OptionTrades,
c/o: Happy_Singh & MM007

I think the function 'PercentRank' seems feasible if one could explain what it is actually calculating as when i passed it through the exploration - the results were not as expected.

The good thing is that PercentRank creates an array which is easier to process from an Amibroker standpoint and the range can be used as the logic. But, what is it really calculating ?

I remain.

ResPartner (Mike-Ekwueme)...
 

mastermind007

Well-Known Member
#12
Re: Using the logic within a ranking column...

Dear OptionTrades,
c/o: Happy_Singh & MM007

I think the function 'PercentRank' seems feasible if one could explain what it is actually calculating as when i passed it through the exploration - the results were not as expected.

The good thing is that PercentRank creates an array which is easier to process from an Amibroker standpoint and the range can be used as the logic. But, what is it really calculating ?

I remain.

ResPartner (Mike-Ekwueme)...
Mike and TradeOptions

AFAIK, PercentRank is strictly an inter-stock function. i.e. It will compare and rank data of the same stock over different candles. There is another sister function named Percentile that kinda works in tandem with PercentRank

AddRankColumn is for adding rank to exploration and is just means to get amibroker to provide sneak peek on how it does exploration sorting when SetSortColumn is used

StaticVarGenerateRanks is primarily an intra-stock function and it makes use of static variables to get it right. Also, if you are using this function while dealing with fast filling data feed over reasonably large data set, this function keeps getting thread-interrupted and you have to deal with threading and semaphore management.

There is no reliable self-sufficient example that I have come across on the StaticVarGenerateRanks function. Default example provided in the amibroker help neatly avoids all the real trading implementation problems ...

Also, if you use this function, values of static variables will remain set even after you shutdown and restart Amibroker!. They remain set even if you shutdown and restart your computer. Therefore, you have to be very careful to prevent ending up with stale out-dated rank OR {EMPTY} value staring back at you. :eek:

Code:
///////////////////////////////// 
// Example 1. code for normal ranking mode 
// (everything done is done in one pass, can be used in indicator): 
///////////////////////////////// 

symlist = "C,CAT,DD,GE,IBM,INTC,MSFT"; 

// delete static variables - DO NOT forget the asterisk (wildcard) at the end 
StaticVarRemove( "ValuesToSort*" ); 

// fill input static arrays 

for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
{ 
    SetForeign( sym ); 
     Value = ROC( C, 10 ); 
    RestorePriceArrays(); 
    StaticVarSet( "ValuesToSort" + sym, Value ); 
} 

// perform ranking 
StaticVarGenerateRanks( "rank", "ValuesToSort", 0, 1224 ); // normal rank mode 

// read ranking 
for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
{ 
    Plot( StaticVarGet( "RankValuesToSort" + sym ), sym, colorCustom10 + i ); 
}
 
Last edited:
#13
Re: Using the logic within a ranking column...

Dear MM007,
c/o: OptionTrades & Happy_Singh,

Great thanks for the clarification of the various ranking functions thus it is clear that one should focus on the function combo => SetSortColumn + AddRankColumn

SetSortColumn is the only inter-stock ranking function i am aware of for now...

My initial intention was to use the ranking result from SetSortColumn + AddRankColumn to further create a ranking logic as can be done on Excel. Amibroker works better with array - unfortunately, the ranking result cannot be described as an array. It seemed like a scalar (correct me if i am wrong pls.).

To be purposeful, how can the scalar ranking result (from SetSortColumn + AddRankColumn) be transformed into an array ??? If this is achieved, then ranking logic is applicable on the resultant array.

This is the coding logic i am recommending. Please kindly correct me if i am wrong. Any better approach ???

I remain.

ResPartner
 

TradeOptions

Well-Known Member
#14
Re: Using the logic within a ranking column...

Mike and TradeOptions

AFAIK, PercentRank is strictly an inter-stock function. i.e. It will compare and rank data of the same stock over different candles. There is another sister function named Percentile that kinda works in tandem with PercentRank

AddRankColumn is for adding rank to exploration and is just means to get amibroker to provide sneak peak on how it does exploration sorting when SetSortColumn is used

StaticVarGenerateRanks is primarily an intra-stock function and it makes of static variables to get it right. Also, if you are using this function while dealing with fast filling data feed over reasonably large data set, this function keeps getting thread-interrupted and you have to deal with threading and semaphore managements.

There is no reliable self-sufficient example that I have come across on the StaticVarGenerateRanks function. Default example provided in the amibroker help neatly avoids all the real trading implementation problems ...

Also, if you this function, values of static variables will remain set even after you shutdown and restart Amibroker!. They remain set even if you shutdown and restart your computer. Therefore, you have to be very careful to prevent ending up with stale out-dated rank OR {EMPTY} value staring back at you. :eek:

Code:
///////////////////////////////// 
// Example 1. code for normal ranking mode 
// (everything done is done in one pass, can be used in indicator): 
///////////////////////////////// 

symlist = "C,CAT,DD,GE,IBM,INTC,MSFT"; 

// delete static variables - DO NOT forget the asterisk (wildcard) at the end 
StaticVarRemove( "ValuesToSort*" ); 

// fill input static arrays 

for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
{ 
    SetForeign( sym ); 
     Value = ROC( C, 10 ); 
    RestorePriceArrays(); 
    StaticVarSet( "ValuesToSort" + sym, Value ); 
} 

// perform ranking 
StaticVarGenerateRanks( "rank", "ValuesToSort", 0, 1224 ); // normal rank mode 

// read ranking 
for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
{ 
    Plot( StaticVarGet( "RankValuesToSort" + sym ), sym, colorCustom10 + i ); 
}
Thank you so much for sharing the details mastermind. You have extensive in-depth understanding of practical aspects of Amibroker Programming :thumb:
Someone who is comparable to programming skills that other TJ member "trash" has got. But you are 100 times better then him in communicating your message, without hurting any novice programmers, who are taking their initial steps in Amibroker Programming Field. :clapping:
Thank you so much for your insights.


Best Regards
 

mastermind007

Well-Known Member
#15
Re: Using the logic within a ranking column...

Dear MM007,
c/o: OptionTrades & Happy_Singh,

Great thanks for the clarification of the various ranking functions thus it is clear that one should focus on the function combo => SetSortColumn + AddRankColumn

SetSortColumn is the only inter-stock ranking function i am aware of for now...

My initial intention was to use the ranking result from SetSortColumn + AddRankColumn to further create a ranking logic as can be done on Excel. Amibroker works better with array - unfortunately, the ranking result cannot be described as an array. It seemed like a scalar (correct me if i am wrong pls.).

To be purposeful, how can the scalar ranking result (from SetSortColumn + AddRankColumn) be transformed into an array ??? If this is achieved, then ranking logic is applicable on the resultant array.

This is the coding logic i am recommending. Please kindly correct me if i am wrong. Any better approach ???

I remain.

ResPartner
respartner

Like I said in post one of mine of this thread, I haven't got a clue as to what you are trying to do with ranking functions. Until you replied back, I was assuming that you were trying to perform intra-stock ranking
 
#16
Re: Using the logic within a ranking column...

MM007,

I am trying to use the ranking result from SetSortColumn + AddRankColumn operation (which is usually in whole numbers) to further create a 2nd ranking logic as can be done on Excel.

For example, if i got a 1st number ranking result of the stocks from 1 - 73 in a ranking column called rank(volatility) from a "SetSortColumn + AddRankColumn" operation. I want to execute a 2nd number ranking of stocks in which only the stocks with the ranks from 1 to 40 are shown....

My problem is that Amibroker works better with array - unfortunately, the 1st ranking result cannot be described as an array. It seems to be scalar (correct me if i am wrong pls.).

I remain.

ResPartner (Mike)
 
#17
Re: Using the logic within a ranking column...

Dear Happy_Singh,
c/o: MM007,

StaticVarRemove("ValuesToSort*");
SetForeign("rank(volatility)");
temp = StaticVarGet("rank(volatility)");
temp = WriteIf(temp < 41,Name(),"");
RestorePriceArrays();
StaticVarSetText("ValuesToSort"+"rank(volatility)",temp);
StaticVarGenerateRanks("rank","ValuesToSort",0,1224 );

=======================================

This is my rough coding of the task...as explaining in my earlier post.
Can anybody advise where my mistakes are ???
I remain.

ResPartner (Mike-Ekwueme)
 
#18
Re: Using the logic within a ranking column...

Dear Happy_Singh,
c/o: MM007,

I have made forward improvements to the code for the following ranking task:

Task: If i got a 1st ranking result of the stocks from 1 - 73 in a rank column called rank(volatility) from a "SetSortColumn + AddRankColumn" functions operation. I want to execute a 2nd ranking of another column of stocks (called Navigator Watchlist) in which only the stocks with their respective rank(volatility) between 1 to 40 are shown....

Code:
newwl=CategoryCreate("Navigator Watchlist",categoryWatchlist);
if(LastValue(MA(EstSec_3,260))>0 AND LastValue(EstSec_5)>1 AND LastValue(EstSec_7)>0)
{
CategoryAddSymbol("",categoryWatchlist,newwl);
}
symlist=CategoryGetSymbols(categoryWatchlist,newwl,0);
StaticVarRemove("StrongBuyStocks*");
for (i=0;(sym=StrExtract(symlist,i))!="";i++)
{
SetForeign("rank(volatility)");
temp=WriteIf(StaticVarGet("rank(volatility)")<41,Name(),"");
RestorePriceArrays();
StaticVarSetText("StrongBuyStocks"+sym,"temp");
}
StaticVarGenerateRanks("rank","StrongBuyStocks",0,1224);
for (i=0;(sym=StrExtract(symlist,i))!="";i++)
{
Plot(StaticVarGet("RankStrongBuyStocks"+sym),sym,colorCustom10+i);
}

Problem: No result shown !!! where did i go wrong ???

Guys & Ladies, i really need yr help. Can anybody advise where my mistakes are ???

I remain.

ResPartner (Mike-Ekwueme)
 

Similar threads