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

[amibroker] Re: Plotting ones own equity



PureBytes Links

Trading Reference Links




Dingo,
 
Following up with stock data entry.
 
To start, set up a symbol in AB, such as ~SGMS, and give it a 
full name, Trade Data.  I always give it
an index attribute so I can filter it out easily from any AA 
or IB work .
 
I enter the data into the same spreadsheet I use for 
Portfolio data. 
 
Data 
Field                         
Data Item
<FONT 
size=2>Ticker                                 
~SGMS
<FONT 
size=2>Date                                   
Y/M/D
<FONT 
size=2>Open                                  
Average Entry Share Price (average in the event of a pyramid)
<FONT 
size=2>High                                   
Not Used
<FONT 
size=2>Low                                    
Stop Loss
<FONT 
size=2>Close                                 
Average Exit Share Price
<FONT 
size=2>Volume                              
# Shares
O 
Interest                          A 
code #, explained below.
 
In data items where there is no entry, such as High, I enter 
.0001 which helps me control
displayed values in an indicator.  I do not account for 
commissions, but could easily do so
by using the High field or entering the Entry Price net of 
commissions
 
Codes
1        Bought this 
date
2        Sold this 
date
10      Enter this on the day after a 
Buy (controls certain plots)
20      Enter this on the day after a 
Sell (controls certain plots)
 
 
Here is some code I use with the above.
 

AvgEntry = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Open"<FONT face=Arial 
color=#800080>);<FONT face=Arial 
color=#800080>
StopLoss = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Low"<FONT face=Arial 
color=#800080>);
AvgExit = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Close"<FONT face=Arial 
color=#800080>);
Shares = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Volume"<FONT face=Arial 
color=#800080>);
Code = <FONT 
face=Arial color=#0000ff>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Interest"<FONT face=Arial 
color=#800080>);
StopLoss = <FONT 
size=2>IIf<FONT face=Arial 
color=#800080>(Code == 20<FONT 
face=Arial color=#800080>,<FONT 
face=Arial>Null<FONT face=Arial 
color=#800080>, Stoploss); 
TrailStop = <FONT 
size=2>ATR<FONT face=Arial 
color=#800080>(40<FONT face=Arial 
color=#800080>) * <FONT face=Arial 
color=#ff00ff>4<FONT face=Arial 
color=#800080>; <FONT face=Arial 
color=#800080>
GraphXSpace<FONT 
face=Arial color=#800080> =<FONT face=Arial 
color=#ff00ff>5<FONT face=Arial 
color=#800080>; 
Plot<FONT 
face=Arial color=#800080>(Close<FONT face=Arial 
color=#800080>,Name<FONT face=Arial 
color=#800080>(),colorGreen<FONT face=Arial 
color=#800080>,<FONT face=Arial 
color=#ff00ff>64<FONT face=Arial 
color=#800080>);  //Plots a chart 
of the current symbol<FONT face=Arial 
color=#800080>
Plot<FONT 
face=Arial color=#800080>(StopLoss,"Stop 
Loss",<FONT 
face=Arial>colorRed,<FONT 
face=Arial color=#ff00ff>1<FONT face=Arial 
color=#800080>);  //Plots the 
stoploss
<FONT face=Arial 
color=#0000ff>PlotShapes(<FONT 
face=Arial color=#0000ff>IIf(Code == 
1<FONT face=Arial 
color=#800080>,shapeUpArrow<FONT face=Arial 
color=#800080>,shapeNone<FONT face=Arial 
color=#800080>),colorDarkGreen<FONT face=Arial 
color=#800080>,0<FONT face=Arial 
color=#800080>,Low<FONT 
face=Arial color=#800080>);  <FONT 
color=#008000>//Plots arrow on buy date
<FONT face=Arial 
color=#0000ff>PlotShapes(<FONT 
face=Arial color=#0000ff>IIf(Code == 
2<FONT face=Arial 
color=#800080>,shapeDownArrow<FONT face=Arial 
color=#800080>,shapeNone<FONT face=Arial 
color=#800080>),colorRed<FONT face=Arial 
color=#800080>,0<FONT face=Arial 
color=#800080>,High<FONT 
face=Arial color=#800080>);  <FONT 
color=#008000>//Plots arrow on sell date 
<FONT face=Arial 
color=#0000ff>PlotShapes(<FONT 
face=Arial color=#0000ff>IIf(Code == 
1<FONT face=Arial 
color=#800080>,shapeSmallCircle<FONT face=Arial 
color=#800080>,shapeNone<FONT face=Arial 
color=#800080>),colorBlack<FONT face=Arial 
color=#800080>,0<FONT face=Arial 
color=#800080>,AvgEntry,<FONT face=Arial 
color=#ff00ff>0<FONT face=Arial 
color=#800080>);  //Plots actual 
buy price
<FONT face=Arial 
color=#0000ff>PlotShapes(<FONT 
face=Arial color=#0000ff>IIf(Code == 
2<FONT face=Arial 
color=#800080>,shapeSmallCircle<FONT face=Arial 
color=#800080>,shapeNone<FONT face=Arial 
color=#800080>),colorBlack<FONT face=Arial 
color=#800080>,0<FONT face=Arial 
color=#800080>,AvgExit,<FONT face=Arial 
color=#ff00ff>0<FONT face=Arial 
color=#800080>);  //Plots actual 
sell price
I use this chart to track progress of my 
trades.  It will also serve as a historical record of the trade 
events.
I use this in conjuction with an indicator pane (code 
below).
 

AvgEntry = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Open"<FONT face=Arial 
color=#800080>);<FONT face=Arial 
color=#800080>
StopLoss = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Low"<FONT face=Arial 
color=#800080>);
AvgExit = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Close"<FONT face=Arial 
color=#800080>);
Shares = <FONT 
size=2>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Volume"<FONT face=Arial 
color=#800080>);
Code = <FONT 
face=Arial color=#0000ff>Foreign<FONT face=Arial 
color=#800080>("~"<FONT face=Arial 
color=#800080>+Name<FONT face=Arial 
color=#800080>(),<FONT face=Arial 
color=#ff6820>"Interest"<FONT face=Arial 
color=#800080>); 
TrailStop = <FONT 
size=2>ATR<FONT face=Arial 
color=#800080>(40<FONT face=Arial 
color=#800080>) * <FONT face=Arial 
color=#ff00ff>4<FONT face=Arial 
color=#800080>; 
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>);
StopPoint = <FONT 
size=2>HighestSince<FONT face=Arial 
color=#800080>(Code ==1<FONT 
face=Arial color=#800080>,High<FONT face=Arial 
color=#800080>,<FONT face=Arial 
color=#ff00ff>1<FONT face=Arial 
color=#800080>);<FONT face=Arial 
color=#800080>
PyramidShares =(<FONT 
size=2>round<FONT face=Arial 
color=#800080>(Shares*1.5<FONT 
face=Arial color=#800080>/10<FONT 
face=Arial color=#800080>)*<FONT face=Arial 
color=#ff00ff>10<FONT face=Arial 
color=#800080>) - Shares; 
GraphXSpace<FONT 
face=Arial color=#800080> = <FONT face=Arial 
color=#ff00ff>10<FONT face=Arial 
color=#800080>;
Title<FONT face=Arial 
color=#800080> = Name<FONT 
face=Arial color=#800080>() +" 
" + <FONT face=Arial 
color=#0000ff>FullName() +<FONT 
face=Arial color=#ff6820>" LONG TRADE MANAGEMENT DATA PANE Date "<FONT 
face=Arial color=#800080> + <FONT face=Arial 
color=#0000ff>Date()+<FONT 
face=Arial color=#ff6820>"\n"<FONT face=Arial 
color=#800080>+ 
"Open = 
"+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>Open,<FONT face=Arial 
color=#ff00ff>1.2<FONT face=Arial 
color=#800080>)+
" High = 
"+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>High,<FONT face=Arial 
color=#ff00ff>1.2<FONT face=Arial 
color=#800080>)+
" Low = 
"+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>Low,<FONT face=Arial 
color=#ff00ff>1.2<FONT face=Arial 
color=#800080>)+
" Close 
="+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>Close,<FONT face=Arial 
color=#ff00ff>1.2<FONT face=Arial 
color=#800080>) + 
" Change 
="+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>Close-<FONT face=Arial 
color=#0000ff>Ref(<FONT 
face=Arial>Close,-<FONT face=Arial 
color=#ff00ff>1),<FONT face=Arial 
color=#ff00ff>6.2<FONT face=Arial 
color=#800080>)+
" Volume = 
"+<FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial>Volume,<FONT face=Arial 
color=#ff00ff>6.0)+ <FONT 
face=Arial color=#ff6820>"\n"<FONT face=Arial 
color=#800080> +
"Entry Price = 
" + <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(AvgEntry,<FONT face=Arial 
color=#ff00ff>6.2<FONT face=Arial 
color=#800080>) + 
" Exit Price = 
" + <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(AvgExit,<FONT face=Arial 
color=#ff00ff>6.2<FONT face=Arial 
color=#800080>) + 
" Shares Pur. = 
" +<FONT face=Arial 
color=#0000ff>WriteVal(Shares,<FONT 
face=Arial color=#ff00ff>6.0<FONT face=Arial 
color=#800080>)+
" Stop Loss 
=" + <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(StopLoss,<FONT face=Arial 
color=#ff00ff>6.2<FONT face=Arial 
color=#800080>) + 
" ATR(40) 
=" + <FONT face=Arial 
color=#0000ff>WriteVal(<FONT 
face=Arial color=#0000ff>ATR(<FONT 
face=Arial color=#ff00ff>40),<FONT 
face=Arial color=#ff00ff>6.2<FONT face=Arial 
color=#800080>) + 
" Proj. Stop Loss 
="+ <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(StopPoint-TrailStop,<FONT face=Arial 
color=#ff00ff>6.2)+<FONT face=Arial 
color=#ff6820>"\n"<FONT face=Arial 
color=#800080>+
"\\c32Projected 
Position % Gain/Loss if stopped = \\c-1"+ 
WriteVal<FONT face=Arial 
color=#800080>(((StopLoss/AvgEntry)-<FONT face=Arial 
color=#ff00ff>1)*<FONT face=Arial 
color=#ff00ff>100,<FONT face=Arial 
color=#ff00ff>6.2<FONT face=Arial 
color=#800080>)+
" Portfolio Equity 
= "+ <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(AccountEquity,<FONT face=Arial 
color=#ff00ff>6.0)+ <FONT 
face=Arial color=#ff6820>"\n"<FONT face=Arial 
color=#800080>+
"Current Position 
% Gain/Loss = " + <FONT face=Arial 
color=#0000ff>WriteVal(((<FONT 
face=Arial>Close/AvgEntry)-<FONT 
face=Arial color=#ff00ff>1)*<FONT 
face=Arial color=#ff00ff>100,<FONT 
face=Arial color=#ff00ff>6.2<FONT face=Arial 
color=#800080>)+
" Portfolio Cash = 
"+ <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(AccountCash,<FONT face=Arial 
color=#ff00ff>6.0<FONT face=Arial 
color=#800080>)+
"\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>+
"Pyramid Shares 
Allowed = " + <FONT face=Arial 
color=#0000ff>WriteVal<FONT face=Arial 
color=#800080>(PyramidShares,<FONT face=Arial 
color=#ff00ff>1.0)+<FONT face=Arial 
color=#ff6820>" "<FONT face=Arial 
color=#800080>+
"Pyramid 
Conditions Met = "+<FONT face=Arial 
color=#0000ff>WriteIf<FONT face=Arial 
color=#800080>((Shares*AvgEntry+PyramidShares*LongBasePrice)-
    
                
                
        ((Shares+PyramidShares)*(StopPoint- 
TrailStop)) <= (AccountEquity *<FONT face=Arial 
color=#ff00ff>0.015),<FONT 
face=Arial color=#ff6820>"\\c32YES\\c-1"<FONT face=Arial 
color=#800080>,"NO"<FONT face=Arial 
color=#800080>);
This indicator is just a 
single, long Title statement.  It provides me with daily information I use 
to manage
open trades.
 
Hope this helps
 
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.