Click here to Login





                                                   Inverse rank, ie smallest to largest using comp()?

  0

0
Jeff D
2014-01-15 17:45:07


I'll continue here comments from the blog:

You suggested this code to add a second parameter with weights to rank and trade:

// This will calculate percentile (0 - 100) - The higher the better
res = comp(value1, "percentile", 1, filter1) * weight1 + comp(value2, "percentile", 1, filter1) * weight2;
// Then calculate ranking
res = comp(res, "rank", 1, filter1);

The question I have is, how do I reverse the percentile rank of value2, i.e. value1 is ranked smallest to highest where the highest value is ranked 1, while I wanted to rank highest to lowest value2 where the lowest value is ranked 1.

The reason for this is that I want to use Sttdev as the parameter for value2 and I;m interested in a lower volatility stock being ranked higher than a high volatility stock.

Thanks.



QuantShare
2014-01-15 20:02:30

  0

Best Answer
To do that simply use "-value1" or "1/value1"
Example:
comp(-value1, "percentile", 1, filter1)



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Percentile Rank of PEG, Price/Free Cash Flow and Price/Sales
Trading System Based on the CloseHL Percent Rank Oscillator
Percentile - Percent Rank of a Trading Indicator
NORMINV - Inverse of the Normal Cumulative Distribution
Rank Industries based on the average Relative Strength Index

How-to Lessons
How to draw an horizontal segment line using QS language
How to plot a stock using different periods in the same chart
How to calculate the average of a time series using the money man...
How to debug a trading system using the money management tool
How to get stocks for a particular index using the global script

Related Forum Threads
Rank using simulation
Composite rank vs SimLongRank
Ranking using Pivot Tables
Inverse Ranking
Backtesting: Using lookback money management feature

Blog Posts
Trading Indicators using the Rank and Percentile functions
Charting, Backtesting and Trading using Fundamental Data
Fundamental Stock Analysis: Rank stocks based on a valuation rati...
Inverse Fisher Transform: Indicator, composite and trading system
3 ways to rank stocks in a trading system - Simulator and Potfoli...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.