I want to get equity high value to calculate, like the highest equity value of recent one year. But it seems there is no functions in power language. Does anyone know about this issue?
Thank you in advance.
How to get equity high value?
Questions about MultiCharts and user contributed studies.
6 posts • Page 1 of 1
Sure, something like this as a very basic starting point, to give you an idea where to go from here to flesh it out in whatever directions you need:
This is certainly not the only way to do this, and is a little longer than it needs to be, mostly to demonstrate how some of the pieces relate. You might want to enhance it to include open P/L, make the lookback for "highest" adjustable either as an input or perhaps based on a date such as yearly or quarterly, or various other alterations relative to this example starting point.
Code: Select all
// MA crossover
FastMA = AverageFC(close, FastLength);
SlowMA = AverageFC(close, SlowLength);
if FastMA crosses above SlowMA then
buy ("LE") next bar at market
else if FastMA crosses below SlowMA then
sellshort ("SE") next bar at market;
// track closed equity
once ClosedEquity = StartingEquity;
Trades = NumLosTrades + NumEvenTrades + NumWinTrades;
if Trades > Trades then
ClosedEquity = ClosedEquity + PositionProfit(1);
// calculate highest closed equity in last 200 bars
HighestEquity = Highest(ClosedEquity, 200);