Click here to Login





                                                   Filter out some symbols from ranking system

  0

0
Paulo
2015-07-14 11:38:15


In a certain backtest system I would like to get a rank of ONLY some symbols of all the symbols I want to include in my system, how can I do that?

For example I included an internal list which has:
symbol1
symbol2
symbol3
symbol4

Then on my Strategy for the ranking I want to build I want to rank all the symbols but not Symbol4 for example, can I do that with QS language?



QuantShare
2015-07-14 18:24:03

  0

The "comp" function has a parameter that allows you to enter either a symbols list (Symbol -> Symbols View) or symbols separated by semi-colons.

Example 1:
a = comp(close, "rank", 1, 1, "Symbols list name");

Example 2:
a = comp(close, "rank", 1, 1, "SPY;TLT;SHY");



Paulo
2015-07-17 09:55:23

  0

Thanks, that works!

Now another question, I would like to make something like this:
buy = iff(stringequal(name(), "SymbolNameXXX") and rank1 == 1 and level1 == 1, 1, 0);
buy = iff(stringequal(name(), "SymbolNameYYY") and rank1 == 1 and level1 == 1, 1, 0);

Could this work?
It buys the second and stays out when the conditions are not met (which is how I want it) but also stays out when condition of SymbolNameXXX is good.

Many thanks!



QuantShare
2015-07-17 13:11:31

  0

This should buy XXX when its rank = 1 and level1 = 1
and buy YYY when its rank = 1 and level1 = 1



Paulo
2015-07-20 10:03:46

  0

Trying to compare 2 stock, then compare the roc 6 month of first in rank with tax rate, if it's bigger buy stock in rank 1, else buy bonds.

Although this kind of works, in the results at least, it doesn't work like I was expecting! I also made a screener with same rules to compare and I can see that it's not always buying stock in rank 1 don't know why...

Also don't know how to exit position if currently holding Bonds, unless I rebalance every month, which I would not want unless market conditions change.

taxRate = Ticker("Ticker1", close, LastData);
r = roc(126); // Return 6 month
rank1 = comp(r, "rank",1,1,"Stock1; Stock2");
level1 = Iff(r > taxRate, 1, 0); // REturn 6 month bigger than tax Rate?
isMTA = StringEqual(Name(), "Bonds3");
rule1 = rank1 <= 1;
rule2 = level1 == 1; //roc bigger than tax rate
newMonth = month() != ref(month(), -1);

buystock = iff((rule1) and rule2 and newMonth, 1, 0);
buybonds = iff(isMTA and newMonth and !rule2, 1, 0);
buy = iff((buystock == 1),1,buybonds);

sell = newMonth;

Thanks!



QuantShare
2015-07-21 03:16:43

  0

You should probably use "!isMTA" as a rule in "buystock"


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
Trading System with Sharpe-Based Ranking
RSI(3) Ranking System
Intraday Trading System with Daily Ranking
Super Stock Screener Ranking System
Sharpe Ratio Ranking System to Lower Trading Strategies Volatilit...

How-to Lessons
How to generate buy/sell signals from a trading system
How to download a trading item from the Sharing Server
How to run a screen or a watchlist from a script
How to add trades from one portfolio to another one
How to filter stocks in a market composite

Related Forum Threads
Ranking System Help
Ranking with symbols not "date aligned"
Ranking System with Trading System Help, Revisited
Ranking System Optimization
Filter out limit orders that doesn't trade through limit price

Blog Posts
Ranking System Engine
Ranking system calculation methods
Improve your trading system performance by ranking stocks
How to filter quotes data from high and low price spikes
How to Backtest an Intraday Stock Trading System with EOD Ranking









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.