Get Current Equity / Set % Equity in Strategy
Author: GolfPlayer
Creation Date: 12/18/2015 11:45 AM
profile picture


I've got several questions. Please help!
1. It there any function like SetShareSize but which operates with %% of equity but not shares quantity? I want to write a code which can buy shares at a percentage part of capital. For example 50%, 12%, 130%, 178%... depending on market conditions.
2. What kind of function returns current equity size? I need to know it to calculate a capital to use in the trades.
profile picture


The answer is "There isn't." to both.

1. As to "SetShareSize for equity", there exist two solutions:

a. Simply use the Position Options PosSizer's "Use .Tag" feature which allows to assign a % Equity or Max % Risk figure programmatically in your Strategy code.

b. Or build your own programmatic solution if you want something more custom: you could program a D.I.Y. PosSizer:

+ See this thread for a code example
+ Wiki FAQ > How to size a Position based on a DataSeries value? How to limit the number of entered positions based on a DataSeries value?
+ Wiki FAQ > How to pass a value from Strategy to PosSizer for Alert sizing?

2. Here's a workaround that may work out:

WealthScript Techniques | Interacting Dynamically with Portfolio Level Equity
profile picture


And how to use "Use.Tag" in Pos Sizer for changing % Equity programmatically ?
Where can I switсh on this option?
profile picture


Click the link, it contains a sufficient instruction.
profile picture


I've done:
1. installed MS123 PosSizer Library.
2. Chosen in PosSizer "Position Options" then Use.tag and %Equity.

How to set value to %Equity in my code?
I used from your example

Please log in to see this code.

command LastPosition.Tag=20;

It doesn't work :(
What did I wrong?
profile picture


"Doesn't work" just doesn't work here. As many other users who have tried it, I'm sure that it works.

Please read this carefully: How to Report Bugs Effectively > "It doesn't work", then follow author's suggestions and summary. Having finished that, please describe the problem in detail:

* How did you determine that?
* You aren't using this to size Alerts, right? Because for Alerts this doesn't function.
* To clarify explanations, send a screen shot of Position Options by striking the "Print Screen" key and then pasting into Paint or other imaging application. Save as PNG and attach.
* Setting (if required to reproduce): single symbol or Multi-symbol mode, position sizing / data loading settings, symbol(s) and data provider
profile picture


If I use MS123 PosSizer Library and Position Options "using" what shoud I write in the begining of my code to get access to Position Options features?

For example, here there is a description of WLD indicators:
using WealthLab.Indicators;

And for Position Options
using what?
profile picture


Such usage of PosSizers is not supported, so you're on your own with it.
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).