Trade only top 5 drops from the alert list
Author: llhk
Creation Date: 1/5/2012 3:14 AM
profile picture

llhk

#1
I have written a strategy to buy at limit among a dataset, but due to the limitation of capital , would like to only trade the 5 symbols with biggest daily drop within the my buy signals. By studying the "RSI Rotation" example, I know how to code to get the biggest daily drop from my dataset but my question is I would like to get the biggest daily drop from my alert list but not whole dataset.

Is it possible to do so? If yes, may I have the example code of it?
Thanks!
profile picture

Eugene

#2
Assign the daily drop figure to Position.Priority. Strip the minus sign to take the biggest losers i.e.
QUOTE:
-ROC.Series(Close,1)[bar]

In the Position Options PosSizer, activate "Max open positions" and enter "5" in the input field.

In addition, you can configure the "Priority" field there to take only trades with a priority below some threshold e.g. still take 5 trades but only if the biggest drop (assigned via the Position.Priority) was worse than e.g. -2.0.
profile picture

llhk

#3
I made it exactly what I want to. Eugene, really thanks for your help!
profile picture

Christos

#4
Eugene,

I am trying to perform the same task as it is stated in the post's name but I can't make it work.

My strategy buys at limit at a specified level (calculated from daily data) and exits the position at the end of the day. So this is an intraday strategy but utilising only daily data. See below for part of the code.

CODE:
Please log in to see this code.


I test that with S&P 500 and limit the max open positions to 100, each one sized at 1% of the available equity.

I check the Signal Names as of 3rd of December 2012 but the trades on the 4th of November are not correct based on priorities.

Could you provide some help please?

Christos
profile picture

Eugene

#5
Everything works correctly for me. Don't forget that signal names are inverted (i.e. biggest negative numbers are the day's biggest winners and vice versa).

Note that sorting by Signal Name on Alerts tab is string-based. It does not correctly reflect priorities in a DataSet because these are double values, and signal names are strings. Take a look and see for yourself:



By the way, I'd recommend to check for LastPosition not being null to avoid exiting a unrelated Position or producing a potential NullReferenceException if a BuyAtLimit fails:
CODE:
Please log in to see this code.
profile picture

Christos

#6
Maybe I haven't correctly described what I want to do. I will give an example.

Assuming that on day one I get 400 Limit buy order alerts, each one given a certain priority. What I would like to do, is actually reduce the amount of alerts to 100 based on that priority.

From my understanding, the solution suggested on the previous posts does not limit the number of alerts to 100, but the number of trades (conditional on exceeding the position sizer threshhold) executing by highest priority.

It seems to me that what I want to achieve can only be done via a rotation strategy where I would create and sort a list of symbols based on certain values.
profile picture

Eugene

#7
QUOTE:
From my understanding, the solution suggested on the previous posts does not limit the number of alerts to 100,

Yes it does. Invert the ROC (done), assign the priority (done), set the number to 100 (done), click the "Max open positions" button, you're done. Have you enabled the option by clicking that button?
profile picture

Christos

#8
Yes, I have enabled the option and I see 490 alerts.
profile picture

Eugene

#9
Sorry, until now I didn't realize you were talking about alerts. Please disregard.

Reducing the amount of alerts can be done in PosSizer, but a live bug will not let you do it in 6.4: "QC 62853 In PosSizers, the Candidates list is empty for Alert sizing".
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).