How do I get the current level of equity?
In WL4 I used this:
QUOTE:
Equity(BarCount-1)
I already had a look at the WL5 Wiki atricle on "Interacting dynamically with Portfolio level equity". However, this was quite confusing to me, as I only need this on figure!
Size:
Color:
Getting the current level of equity is not supported in WL5. Otherwise it would be documented in the QuickRef and I wouldn't have to create this workaround. But you can still give the Wiki article a go, these examples are quite illustrative and simple:
CODE:
Please log in to see this code.
Size:
Color:
But if you were used to access the portfolio equity in simuscripts i.e. "
Equity(BarCount-1)", this is still quite easily possible in WL5 using PosSizers. Although the API documentation is currently unaccessible, this will be supported and requires no programming tricks (e.g.
Trading the Equity Curve PosSizer).
Size:
Color:
QUOTE:
DataSeries globalEquity = sr.EquityCurve;...PlotSeries( gEqPane, globalEquity, Color.DarkGreen, LineStyle.Histogram, 2 );
I dont understand where "sr" is coming from.
Size:
Color:
You don't have to, it's an "programming trick" from Community.Components'
Utility.cs that uses some undocumented (unsupported) classes. Try using the data series as a regular data series:
CODE:
Please log in to see this code.
Size:
Color:
Sorry, I dont get it. Next trades size should depend on current equity.
CODE:
Please log in to see this code.
Size:
Color:
In this case, you should use "bar", and not "Bars.Count-1". The latter syntax is for finding the equity value on the last bar outside of the trading loop.
Size:
Color:
"Tne name'globalEquity' does not exist in the current context."
Sorry, I meant "The name 'sr' dpes not exist...".
Size:
Color:
Right, it doesn't - because you have arbitrarily removed many necessary lines of code from the Wiki example.
Size:
Color:
Like I said. I do not understand it. Now, I added some lines. But still does not work.
"Object referencet not set to an instace of an object.
at WealthLab.Strategies.MyStrategies.Execute()
at Community.Components.Utility.runDonor
CODE:
Please log in to see this code.
Size:
Color:
The code runs fine, it just wouldn't produce any results because its "donor system" code is missing, so the equity is 0 at all times:
CODE:
Please log in to see this code.
P.S. Another forum thread to look for the hints:
Save Equity Curve Data
Size:
Color:
There is a donor code at the end. I just modified it, so that there are no trades and the equity will stay at the level I enter in the Position size tab.
Size:
Color:
I couldn't duplicate the error, but in any case, please try restarting WLD or simply running ClearGlobals once to clear WL's global memory.
Size:
Color: