Click here to Login





                                                   Need some insight to the "rank" engine using comp funtion

  0

0
Dave Walton
2013-07-10 11:53:25


Hi, I have a monthly ranking system with the code below:

M = TimeframeApply(31, roc(Close, 3));
M = TimeframeDecompress(M);

Rule 1 = Month() != ref(Month(),1);
Rule2 = (comp(M, "rank")) < (4);
buy = ((Rule1) && (Rule2));
sell = Rule1;

I have set my number of positions to 3 so thus I would expect to have 3 positions opened and closed every month. However, I often find that only 1 or 2 positions are opened. Why is that and how can I fix the problem?



QuantShare
2013-07-11 04:24:19

  0

Make sure you select a "Long" only trading system


Dave Walton
2013-07-11 07:02:43

  0

Yes, my system has "Long" set but yet I have the problem. I was able to work around this by not using the comp function and instead adding this:

SetSimLongRank(M);

Any ideas why the comp function isn't working as I expect? I'd like to understand this for other potential ranking systems.



QuantShare
2013-07-11 20:51:38

  0

It does work, however your buy and sell rules usually give signals at the same time (beginning of a month).
When a sell order is generated (sell at open of tomorrow) then a buy order to purchase the same stock is rejected.

Just add the following line to your trading system:

SetSimTiming(_Sell, _Close, -1); // Sell at close of today



Dave Walton
2013-07-12 18:57:45

  0

OK, but that is not how I want to execute the system. I don't want to be out of the market overnight. Basically this system rebalances monthly. If I currently hold one position that will still be in the top3 the following month, I want rebalance it so that it gets 1/3 of the capital. I thought the easy way to do this was to sell all positions and then buy the top 3 with 100% of capital every month. I actually trade this system and accomplish this using MOC orders for both the buys and the sells in the lfirst day of the month. Maybe that is not the best way to execute the system due to commissions and slippage, but seems the easiest way to do the rebalancing.

Like I said, I'm accomplishing this using the SetSimLongRank command but it might be nice to tell the comp function whether to prioritize buy or sell orders vs. ignoring them when they happen at the same time.



QuantShare
2013-07-12 20:19:33

  0

The "SetSimTiming" command will only specify the order type. Sell orders are initiated only when the "sell" variable is true.



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 rules using the VIX Index
Measure the value of the stock market using the Q-Ratio valuation...
Investing in stocks using the Kelly criterion money management st...
High to low stock pattern for the close price
Trading Rules to use with the Trading System Optimizer

How-to Lessons
How to get stocks for a particular index using the global script
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 perform a basic quantitative analysis using the S&P 500

Related Forum Threads
Basic features and some issues with the background
Can I update the sector and industry information in the stock dat...
comp values stored as a separate field in the db
Trading system optimization using the QuantShare API Simulator
Locks up when market is open while using the *daily* chart with I...

Blog Posts
Create a trading strategy using the money management tool - Part ...
Basic trading system implemented using the money management tool
How to create market indicators using the composite function - Pa...
Charting & Scripts - Manage stock charts using the global script
Create a stock index or a trading indicator using the composite t...









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.