The Rank Instruments script is used to set the long and short ranking value using the Ranking Functions of the Instrument Trading Object. If your strategy requires a screen or 'trade only the top x strongest' or some other type of logic that requires ranking the instruments, this is where you set the value to be used in the sort.
Ranking Values and Instrument Ranks
There are separate long and short ranking values. Ranking values are used by Trading Blox Builder to determine the relative ranking of each instrument. After the Rank Instruments script has been called for each instrument in the current Portfolio, Trading Blox Builder sorts the instruments highest to lowest using the long ranking value and then lowest to highest using the short ranking value. It then sets the rank for each instrument based on its position after being sorted by the ranking value.
For long ranking values, the highest values will result in the lowest rank. So an instrument with a rank of 1 represents the instrument with the highest long ranking value for that day.
For short ranking values, the lowest values will result in the lowest rank. So an instrument with a rank of 1 represents the instrument with the lowest short ranking value for that day.
This approach lets you use a single measure for both long and short trades. For example, a strength measure would result in higher strength instrument's rated lower for long trades and lower strength instrument's rated lower for short trades.
Example code for the Rank Instruments script:
' Set the long ranking value for this instrument
instrument.SetLongRankingValue( rsi )
Edit Time: 5/10/2017 8:36:18 AM
Topic ID#: 487