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

[amibroker] Re: Plotting ones own equity



PureBytes Links

Trading Reference Links




Dingo,
 
There were two parts in my message and I'll start with the 
equity idea and do the individual stock
later.
 
You need to have a way to determine your portfolio equity on 
an EOD basis.  There are any number
of ways to do this, I happen to use MSN Money Portfolio.  
It works for me. (as an aside, I do my own
taxes, so I also use Quicken.  It makes year end  
tax work a snap.) I also bring my cash position 
into
 AB on a daily basis so that I can see, at a glance, how 
much I have to invest.
  
To start, set up a symbol in AB, such as ~PORT, and give it a 
full name, Portfolio Data.  I always give it
an index attribute so I can filter it out easily from any AA 
or IB work .
 
Once I have the data, I enter it into a spreadsheet as 
follows:( done in vertical format as 
the Yahoo site does not do well with keeping columnar format 
aligned. The actual 
spreadsheet is done horizontally.)
 
Data 
Field                         
Data Item
<FONT 
size=2>Ticker                                 
~PORT
<FONT 
size=2>Date                                   
Y/M/D
<FONT 
size=2>Open                                  
Portfolio Equity in whole dollars
<FONT 
size=2>High                                   
Portfolio Equity in whole dollars
<FONT 
size=2>Low                                    
Portfolio Equity in whole dollars
<FONT 
size=2>Close                                 
Portfolio Equity in whole dollars
<FONT 
size=2>Volume                              
Account Cash Balance in whole dollars
O 
Interest                          1 
(not needed but I do it for continuity reasons with other data)
 
I fill each of the OHLC fields; however, it is not for 
any particular reason.
 
When done with spreadsheet entry, save the file as 
a .csv.
Go to AB and, using Import Wizard, import the data. (A single 
line daily)
Be careful to check the No Quotation and Allow Negative tick 
boxes as AB does some data checking and
you can run afoul of the checker easily.
 
Here are several ways I use this data.
 
In the default price pane, I set up three separate, snapped to 
price, lines.
     One runs from the beginning to 
the end of the current period.
     One runs from the beginning to the 
Max peak of the equity curve.
     One runs from the Max peak of the 
equity to the last price.
 
By hovering the tool tip over these lines, I get a direct read 
of the % change of the
points noted.  The lines are reset daily if needed.  
BTW, the price chart can look pretty wacko due 
to the aspect ratio, but, you get used to it.   If 
that offends your eye, you can do a  Plot(Close,..........)
and set up your own aspect ratio in a new indicator 
pane.  If you are inclined, it would be fairly easy 
for one skilled in AB to slap a Linear Regression line on the 
custom chart to better indicate the trend.
 
Here is some code I use.

AccountEquity = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~PORT"<FONT 
face=Arial color=#800080>,<FONT face=Arial 
color=#ff6820>"HIGH",<FONT 
face=Arial color=#ff00ff>1<FONT face=Arial 
color=#800080>);
AccountCash = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~PORT"<FONT 
face=Arial color=#800080>,<FONT face=Arial 
color=#ff6820>"Volume",<FONT 
face=Arial color=#ff00ff>1<FONT face=Arial 
color=#800080>);
The above 
accesses the data set for other uses.
Keep in mind that the third parameter in Foreign allows the 
last posted value to be 
carried forward if the parameter is set to 1.  In this 
way, if you go through a longish period
of no trading, your data will carry forward when called with 
this function.  (on the other hand,
your default price chart will have truncated values.  You 
choose the trade-off when you decide
to post daily or not) 
<FONT face=Arial color=#ff6820 
size=1>
" Portfolio Cash = "<FONT 
size=2>+ <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(AccountCash,<FONT face=Arial 
color=#ff00ff>6.0<FONT 
size=2>)+
"\nPortfolio % 
Gain/Loss = "+<FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(((AccountEquity/<FONT face=Arial 
color=#ff00ff>25000)-<FONT 
face=Arial color=#ff00ff>1)*<FONT 
face=Arial color=#ff00ff>100,<FONT 
face=Arial color=#ff00ff>1.2<FONT face=Arial 
color=#800080>)+
" Current DD % = 
"+ <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(((AccountEquity/<FONT face=Arial 
color=#0000ff>Highest<FONT face=Arial 
color=#800080>(AccountEquity))-<FONT face=Arial 
color=#ff00ff>1)*<FONT face=Arial 
color=#ff00ff>100,<FONT face=Arial 
color=#ff00ff>1.2)+<FONT face=Arial 
color=#ff6820>"\n"<FONT face=Arial 
color=#800080>+
The above are elements of a 
Title statement that places information I want to see in an 
indicator
pane directly 
below a chart.
<FONT color=#000000 
size=2> 

DDRatio = AccountEquity/<FONT 
face=Arial color=#0000ff size=2>Highest<FONT face=Arial 
color=#800080>(AccountEquity);
DDAdjust = <FONT 
size=2>IIf<FONT face=Arial 
color=#800080>(DDRatio >= <FONT face=Arial 
color=#ff00ff>1.0,<FONT face=Arial 
color=#ff00ff>1.0<FONT 
size=2>,DDRatio);
SharesToBuy = <FONT 
size=2>round<FONT face=Arial 
color=#800080>((0.015<FONT 
face=Arial color=#800080>*AccountEquity)/TrailStop*DDAdjust/<FONT 
face=Arial color=#ff00ff>10)*<FONT 
face=Arial color=#ff00ff>10; 

This is my position sizing 
code.  (read drawdown for DD)
TrailStop is based on the ATR 
function.  As you can see, my position is set by a limit based 
on
portfolio equity, the TrailStop amount and the 
amount of the current DD.
 
Keep in mind that this is in an indicator window 
and you will access different data when you select
different dates.
 
The above is about the limit of what I use the 
data for, but I find the time getting the info into AB
each day to be well spent.  And, once you 
have the data in AB, I'm sure you will find other uses
for it.
 
Regards,
 
Tony
 
 
 






Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.