[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Modified Portfolio Equity Indicator



PureBytes Links

Trading Reference Links

Gary,

I hadn't seen this version of Fred's Eq Curve. Must have had my head
in the sand as usual.

Thanks.

Phsst
--- In amibroker@xxxxxxxxxxxxxxx, "Gary A. Serkhoshian"
<serkhoshian777@xxxx> wrote:
> 
> Hi all,
> 
> Another alternative to the built-in portfolio equity curve.  Thanks
to Fred and Bruce Robinson for letting me bug them about Fred's
original PT equity indicator which served as a great learning platform.
> 
> Kind Regards,
> 
> Gary
> 
> /*
> 
> You can Plot these Equity curves using the following code:
> 
> Plot( Foreign("~~~EQUITY", "O"), "Long Equity", colorBrightGreen );
> 
> Plot( Foreign("~~~EQUITY", "H"), "Short Equity",colorYellow );
> 
> Plot( Foreign("~~~EQUITY", "L"), "Cash", colorGreen, styleArea );
> 
> Plot( Foreign("~~~EQUITY", "C"), "Portfolio Equity", colorLightBlue,
styleArea );
> 
> */
> 
> Eq = Foreign("~~~EQUITY", "C");
> 
> Cash = Foreign("~~~EQUITY", "L");
> 
> PerCash = round((Cash / Eq) * 100);
> 
> MaxCash = Highest(PerCash);
> 
> LMaxCash = LastValue(MaxCash) * (1.45);
> 
> //Drawdown calcs
> 
> CurDD = round(( (Eq - Highest(Eq)) / Highest(Eq) ) * 10000) / 100;
> 
> MaxDD = Lowest(CurDD);
> 
> LMaxDD = LastValue(MaxDD) * (1.05);
> 
> //Equity High Calcs
> 
> FlatEq = HighestBars(Eq);
> 
> MaxFlat = Highest(FlatEq);
> 
> LMaxFlat = LastValue(MaxFlat) * (1.25);
> 
> //LINEAR REG CALCS BELOW
> 
> islastbar = Status("lastbarintest");
> 
> isfirstbar = Status("firstbarintest");
> 
> bar = BarIndex();
> 
> firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
> 
> lastbar = LastValue( ValueWhen( islastbar, bar ) );
> 
> al = LastValue( ValueWhen( islastbar, LinRegSlope( eq, Lastbar -
firstbar ) ) );
> 
> bl = LastValue( ValueWhen( islastbar, LinRegIntercept( eq, Lastbar -
firstbar ) ) );
> 
> Lr = al * ( BarIndex() - firstbar ) + bl;
> 
> Lr = IIf( bar >= firstbar AND bar <= lastbar , Lr, Null );
> 
> GraphZOrder=1;
> 
> Plot(CurDD, "Current DD%", colorPink, styleArea+styleOwnScale,
LMaxDD, -LMaxDD);
> 
> Plot(MaxDD, "Max DD%", colorDarkRed,styleLine+styleOwnScale, LMaxDD,
-LMaxDD);
> 
> Plot(PerCash,"% Cash",colorBrightGreen,styleArea+styleOwnScale,
-LMaxCash, LMaxCash);
> 
> Plot(50,"50% Cash Level",colorPaleGreen,styleLine+styleOwnScale,
-LMaxCash, LMaxCash);
> 
> Plot(100,"100% Cash Level",colorPaleGreen,styleLine+styleOwnScale,
-LMaxCash, LMaxCash);
> 
> Plot(MaxFlat, "Max Flat",colorYellow, styleOwnScale+styleLine,
-LMaxFlat, LMaxFlat);
> 
> Plot(FlatEq, "Cur Flat Eq",colorLightYellow,
styleOwnScale+styleArea, -LMaxFlat, LMaxFlat);
> 
> Plot(Eq,"Portfolio Equity",colorBlack,styleLine+styleLeftAxisScale);
> 
> Plot(Lr , "Linear Reg", colorDarkBlue, styleThick+styleLeftAxisScale );
> 
> Title = EncodeColor(colorBlack) + "Portfolio Equity = " +
NumToStr(Eq,5.1) + ", " +
> 
> "% Cash = " + EncodeColor(colorBrightGreen) + NumToStr(PerCash,3.0)
+ "%, " +
> 
> EncodeColor(colorBlack) + "Current DD% = " + EncodeColor(colorPink)
+ NumToStr(CurDD,3.0) + "%, " +
> 
> EncodeColor(colorBlack) + "Max DD% = " + EncodeColor(colorDarkRed) +
NumToStr(MaxDD,3.0) + "%, " +
> 
> EncodeColor(colorBlack) + "Bars Since Last Eq High = " +
EncodeColor(colorLightYellow) + NumToStr(FlatEq,3.0) + "\n" +
> 
> EncodeColor(colorBlack) + "Max Flat Equity Period = " +
EncodeColor(colorYellow) + NumToStr(MaxFlat,3.0) + ", " +
> 
> EncodeColor(colorBlack) + "LinReg Equity = " +
EncodeColor(colorDarkBlue) + NumToStr(Lr,3.0);
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/