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?
- Bruce DeVault
- Posts: 438
- Joined: 19 Jan 2010
- Location: Washington DC
- Been thanked: 2 times
- Contact:
- Bruce DeVault
- Posts: 438
- Joined: 19 Jan 2010
- Location: Washington DC
- Been thanked: 2 times
- Contact:
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
inputs:
FastLength(10),
SlowLength(20),
StartingEquity(100000);
variables:
FastMA(0),
SlowMA(0),
ClosedEquity(0),
Trades(0),
HighestEquity(0);
// 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[1] then
ClosedEquity = ClosedEquity + PositionProfit(1);
// calculate highest closed equity in last 200 bars
HighestEquity = Highest(ClosedEquity, 200);
- Bruce DeVault
- Posts: 438
- Joined: 19 Jan 2010
- Location: Washington DC
- Been thanked: 2 times
- Contact: