How to get equity high value?

Questions about MultiCharts and user contributed studies.
TW
Posts: 31
Joined: 14 Dec 2009
Has thanked: 5 times
Been thanked: 1 time

How to get equity high value?

Postby TW » 18 Mar 2010

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.

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 18 Mar 2010

Assign the equity to a numeric series variable, then use the "highest" function to return the high within X bars. Or, you could track it and look back in another way, such as to Jan 1.

TW
Posts: 31
Joined: 14 Dec 2009
Has thanked: 5 times
Been thanked: 1 time

Postby TW » 18 Mar 2010

Hi Bruce, thanks for replying.

I'm a beginner, would you please just give me a simple example? Thank you very much!

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 18 Mar 2010

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:

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);
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.

TW
Posts: 31
Joined: 14 Dec 2009
Has thanked: 5 times
Been thanked: 1 time

Postby TW » 18 Mar 2010

You are so professional! I will try it later.
Thanks for your help!

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 18 Mar 2010

Thanks for your kind words. You are welcome. Good luck to you.


Return to “MultiCharts”