Use Tag in Position Options
Author: Christos
Creation Date: 4/23/2012 8:55 AM
profile picture

Christos

#1
I would like to use multiple limit orders each one of them sized differently. What would be the way to do it using Tag (% Equity)? Is it possible to provide a code snipset? To be more precise, what I would like to do is the following: For a given symbol create 5 buy limit orders each one sized for example 1%, 2%, 3%, 4%, 5%.
profile picture

Eugene

#2
Such code snippet is provided one the online help page:

Position Options

I believe this is sufficient because the subject is utterly simple (assigning a double value based on a condition).
profile picture

Christos

#3
I read this one but I am still having problems with the code. Apparently I haven't correctly understood how "Tag" really works. The example code assigns different values of % Equity to LastPosition whereas I want to assign different values of % Equity to different limit orders of the same symbol. Here is how I tried to use LastPosition.Tag unsuccesfully:

CODE:
Please log in to see this code.
profile picture

Eugene

#4
After enabling "Use Tag" with "% Equity" selected, your code works exactly as planned. Of course, assuming that your strategy takes multiple positions.
profile picture

Christos

#5
I am afraid this is not the case. For example check with BAC for the past 15 weeks.
profile picture

Eugene

#6
Precisely, what should I find? Be verbose please.
profile picture

Cone

#7
Also, for EOD strategies that use this design, you must ensure that the priority of the signals are correct. In other words, the signal hitting the 5% target should be sized before the one for the 6% dip, and so on. Here's a looping construction with the proper setting of priority.

CODE:
Please log in to see this code.
profile picture

Christos

#8
Priority setting was the problem. Thanks a lot for your help.
profile picture

Christos

#9
I just found another problem while using this design. Although the strategy is correctly backtested the alerts generated are not correctly sized. Each one of these are sized with the exact same % of equity.
profile picture

Eugene

#10
This is by design. Script-based percent equity can't be used for alert sizing. The situation is explained in this FAQ, with a workaround (requiring you to code a custom PosSizer):

How to pass a value from Strategy to PosSizer for Alert sizing?

To clarify things further, as the Position object is null for alert sizing, the "Use Tag" feature is limited to the sizing of historical trades. Since Alert size can not be determined, the PosSizer has to fall back to a default value specified in its settings (e.g. 5% equity). On a closing note, the Bars.Tag workaround from the FAQ will not be included in "Position Options" to avoid over-complication.
profile picture

Christos

#11
Eugene, thanks a lot for your detailed reply.
profile picture

Eugene

#12
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).