Hello everybody,
I try to understand "How to use StaticVarGenerateRanks in Analysis window" example from Amibroker Help and not sure if I get the rankig part right. Would apprichiate if someone could agree, disagree and/or comment.
01. if ( Status("stocknum")== 0 ) //GENERATE RANKING WHEN WE ARE ON VERY FIRST SYMBOL
02. {
03. StaticVarRemove( "values*" );
04.
05. for (n = 0; ( Symbol = StrExtract(List, n ) ) != ""; n++ )
06. {
07. SetForeign (symbol );
08. values = RSI();
09. RestorePriceArrays();
10. StaticVarSet ( "values" + symbol,values );
11. _TRACE(symbol );
12. }
13.
14. StaticVarGenerateRanks( "rank", "values", 0, 1224 );
15. }
Line 01.: we are making sure, that ranking is done only if symbol with index 0 (first symbol in the database or in selected watchlist) is selected. Without it the following for-loop (5. - 12.) would be executed for every symbol in database or watchlist, which is not neccesary as we would get exactly the same rankings.
Line 03.: remove all static variables
Line 05.: we initialize a loop over all tickers in database/watchlist and assign them to a variable Symbol one after other.
Line 07.: we replace current price arrays with arrays form ticker stored in variable Symbol.
My questions here are, why do we call "symbol" instead of "Symbol" and in case of n=0 we actually do not have to replace arrays as we have them already?
Line 08.: calculate RSI array
Line 09.: restore price arrays. With this we get price arrays from first ticker from database or watchlist. My question here is, why we have to do this? Would it not be enough to get new arrays with SetForeign(symbol) for next n in the for-loop?
Line 10.: we assing RSI values to valuesSymbol. My question here is, is valuesSymbol ticker an array and if so can I operate on it like on default price arrays, e.g. calculate avarages, etc.?
Line 11.: ouput symbol to log window. My question here is, why I do not see any output in my log window even though Preferences > AFL > _TRACE() output > Internal is activated
Line 14.: generate ranking and store it in rank. Also here, is this an array and if so can I operate on it like on default price arrays?
Sorry for my long post but I feel it is essential to understannd the basic concepts before takling complex tasks like becktesting.
Thanks in advance!