Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Summary of Holdings for Amibroker (AFL)

Rating:
2 / 5 (Votes 5)
Tags:
amibroker, backtest

The module will display a list of your holdings and associated statistics.
It uses string manipulations and gfx formulas to display the data in a graphics title statement.
Total value of the holdings may be plotted.
Not mine. Found on the web somewhere.

Similar Indicators / Formulas

Z Score for backtesting
Submitted by EliStern about 14 years ago
Accurate results of system (backtest)
Submitted by lmd2286 over 14 years ago
Visual BackTest V2
Submitted by sethmo over 11 years ago
bad tick clean
Submitted by pious243 about 12 years ago
Williams Alligator System
Submitted by durgesh1712 over 13 years ago
*Level Breakout system*
Submitted by Tinych over 13 years ago

Indicator / Formula

Copy & Paste Friendly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//  BEANS.afl   KSC   09/20/2008
 
// =============== Use Notes ====================
// To use, Apply Indicator as this is a plotted result using the
// Gfx graphics routines.
// If you put the pole anywhere earlier than the BuyDate for a holding,
// the BuyPrice will be a large and incorrect number.
// ==============================================
 
// =============== Holdings=======================
// Add as many holdings as you want, formatted as:
// Hx = "Symbol,Shares,DateofPurchase,BuyPrice";
// Example: H1 = "SPY,500,06/04/2008,148.50 ";
// Omit share price to automatically use EOD price.
// Avoid spaces after and before commas.
// Enter TotalSymbolCount to match the number of Holdings
H1 = "SPY,100,06/04/2007,148.50";
H2 = "GLD,100,06/05/2008,86.00";
H3 = "OAKBX,100,11/05/2007";
H4 = "PSPFX,100,03/10/2008";
H5  = "BEARX,100,05/21/2008";
TotalSymbolCount = 5;
// =============== End of Holdings==================
 
// ============== Initialize =======================
Title = "";
CellHeight  = Param( "CellHeight", 20, 10, 30, 1 );
CellWidth   = Param( "CellWidth",  90, 70, 110, 1 );
PlotSpace   =   Param( "PlotSpace", 50, 20, 80, 1 );
// Toggle ShowPlot to plot the Total value of the holdings
ShowPlot        =   ParamToggle( "ShowPlot", "No|Yes" );
SymList = "";
ShrList = "";
DatList = "";
BuyList = "";
// ============== Prepare Strings =================
 
for ( i = 1; i < totalSymbolCount + 1; i++ )
{
    list = VarGetText( "H" + NumToStr( i, 1.0, 0 ) );
 
    if ( i == 1 )
    {
        comma = "";
    }
    else
    {
        comma = ",";
    }
 
    SymList +=  comma + StrExtract( list , 0 );
 
    ShrList +=  comma + StrExtract( list, 1 );
    DatList +=  comma +  StrExtract( list, 2 );
    BuyList +=  comma +  StrExtract( list, 3 );
}
 
// Uncomment next line to see the strings
//Title = "\n\n\n\n\n\n\n\n\n\n\n\n\n" + SymList + "\n" + ShrList + "\n" +
DatList + "\n" + BuyList;
 
// ============== Functions for display ===========
function PrintInCell( string, row, Col, TxtColor )
{
    GfxSetTextColor( TxtColor );
    GfxDrawText( string, Col * CellWidth, row * CellHeight, ( Col + 1 ) *
                 CellWidth, ( row + 1 ) * CellHeight, 0 );
}
 
//  Converts a date to DateNum. dat is the date in mm/dd/yyyy format (enclose in quotes)
function DateToDateNum( dat )
{
    firstbreak  = StrFind( dat, "/" );
    mont            = StrToNum( StrLeft( StrLeft( dat, firstbreak )   , firstbreak - 1 ) );
    fragment        = StrRight( dat, StrLen( dat ) - firstbreak );
    secbreak        = StrFind( fragment, "/" );
    daa         = StrToNum( StrLeft( StrLeft( fragment, secbreak )   , secbreak - 1 ) );
    yeer            = StrToNum( StrRight( fragment, StrLen( fragment ) - secbreak ) );
    yerr            = IIf( yeer <= 99 AND yeer > 25, yeer + 1900, IIf( yeer <= 25, yeer +
                  2000, yeer ) );
    DatNum      = ( yerr - 1900 ) * 10000 + mont * 100 + daa;
    return DatNum;
}
 
function DateToBar( dn )
 
{
    return LastValue( ValueWhen( DateNum() == dn, BarIndex() ) );
}
 
// ===================== Gfx Printing of Title ==============================
GfxSelectFont( "Courior New", CellHeight / 2 );
GfxSetBkMode( 1 );
 
// ===================== Headers for columns ================================
CellWidth = 400;
DateSelect = NumToStr( SelectedValue( DateTime() ), formatDateTime );
TopHL = "BEANS Module for " + StrFormat( DateSelect );
Colorx = colorBlack;
PrintInCell( TopHL,         0, 0, colorx );
CellWidth = 90;
PrintInCell( "Fund",        1, 0, colorx );
PrintInCell( "BuyDate",     1, 1, colorx );
PrintInCell( "BuyPrice",    1, 2, colorx );
PrintInCell( "Shares",      1, 3, colorx );
PrintInCell( "BuyVal",      1, 4, colorx );
PrintInCell( "CurPrice",    1, 5, colorx );
PrintInCell( "CurValue",    1, 6, colorx );
PrintInCell( "1d%",         1, 7, colorx );
PrintInCell( "1d$Gain",     1, 8, colorx );
PrintInCell( "Tot%Chg",     1, 9, colorx );
PrintInCell( "21dROC",      1, 10, colorx );
PrintInCell( "63dROC",      1, 11, colorx );
 
 
// ================== Core section to print and calculate Title information=============
// Note: if you rearrange columns, change headers to match
// -------------- Extract Symbols, Dates, and Shares from string lists------------------
kk  =   2;
FTot = 0;
GainDol1dTot = 0;
ValatBuyTot = 0;
 
for ( i = 0; ( sym = StrExtract( SymList, i ) ) != ""; i++ )
{
    // Loop
    // Set Ticker/Trade Environment.
    SetForeign( sym );
 
    Dat         =   StrExtract( DatList, i );
    Dat1            =   StrToDateTime( Dat );
    BuyDate     =   DateToDateNum( Dat );
    BuyBar      =   DatetoBar( BuyDate );
    BuyPr           =   StrExtract( BuyList, i );
 
    if ( BuyPr != "" )
    {
        BuyPr2  =   StrToNum( BuyPr );
    }
    else
    {
        BuyPr2  =   ValueWhen( DateTime() == Dat1, C, 1 );
    }
 
    Shr         =   StrExtract( ShrList, i );
 
    ValatBuy        =   BuyPr2 * StrToNum( Shr );
    ValToday    = C * StrToNum( Shr );
    GainPC      =   100 * ( C - BuyPr2 ) / BuyPr2;
    GainDol1d   =   StrToNum( Shr ) * ( C - Ref( C, -1 ) );
    Ftot            = Ftot + ValToday;
    GainDol1dTot = GainDol1dTot + GainDol1d;
    ValatBuyTot = ValatBuyTot + ValatBuy;
    Color1      =   colorBlack;
 
    if ( LastValue( ROC( C, 1 ) >= 0 ) )
    {
        Color2 = colorGreen;
    }
    else
    {
        Color2 = colorRed;
    }
 
    if ( LastValue( ROC( C, 21 ) >= 0 ) )
    {
        Color3 = colorGreen;
    }
    else
    {
        Color3 = colorRed;
    }
 
    if ( LastValue( ROC( C, 63 ) >= 0 ) )
    {
        Color4 = colorGreen;
    }
    else
    {
        Color4 = colorRed;
    }
 
 
    Colorx  =   colorBlack;
 
    PrintInCell( StrFormat( sym ),                              i + kk, 0, color1 );//Col1:Sym
    PrintInCell( StrFormat( Dat ),                              i + kk, 1, color1 );//Col2:BuyDate
    PrintInCell( StrFormat( "$" + "%01.2f", BuyPr2 ),   i + kk, 2, color1 );//Col3:BuyPrice
    PrintInCell( StrFormat( "%01.0f", StrToNum( Shr ) ),        i + kk, 3, color1 );//Col4:Shares
    PrintInCell( StrFormat( "$" + "%01.0f", ValatBuy ),         i + kk, 4, color1 );//Col5:ValatBuy
    PrintInCell( StrFormat( "$" + "%01.2f", C  ),               i + kk, 5, color1 );//Col5:PriceToday
    PrintInCell( StrFormat( "$" + "%01.0f", ValToday ),         i + kk, 6, color1 );//Col6:ValueToday
    PrintInCell( StrFormat( "%01.2f", ROC( C, 1 ) ) + "%",  i + kk, 7, color2 );//Col6:1dROC
    PrintInCell( StrFormat( "$" + "%01.0f", GainDol1d ),    i + kk, 8, color2 );//Col8:1dGain$
    PrintInCell( StrFormat( "%01.1f", GainPC ) + "%",       i + kk, 9, color2 );//Col7:Tot%Change
    PrintInCell( StrFormat( "%01.2f", ROC( C, 21 ) ) + "%",     i + kk, 10, color3 );//Col9:21dROC
    PrintInCell( StrFormat( "%01.2f", ROC( C, 63 ) ) + "%",     i + kk, 11, color4 );//Col9:63dROC
 
 
    RestorePriceArrays();
}// End Loop
 
FTot1dROC   =   ROC( Ftot, 1 );
 
TotChg      =   100 * ( FTot - ValatBuyTot ) / ValatBuyTot;
 
FTot21      =   ROC( Ftot, 21 );
 
Ftot63      =   ROC( Ftot, 63 );
 
if ( LastValue( Ftot1dROC >= 0 ) )
{
    Color5 = colorGreen;
}
else
{
    Color5 = colorRed;
}
 
if ( LastValue( GainDol1dTot >= 0 ) )
{
    Color6 = colorGreen;
}
else
{
    Color6 =
        colorRed;
}
 
if ( LastValue( TotChg >= 0 ) )
{
    Color7 = colorGreen;
}
else
{
    Color7 = colorRed;
}
 
if ( LastValue( Ftot21 >= 0 ) )
{
    Color8 = colorGreen;
}
else
{
    Color8 = colorRed;
}
 
if ( LastValue( Ftot63 >= 0 ) )
{
    Color9 = colorGreen;
}
else
{
    Color9 = colorRed;
}
 
 
PrintInCell( StrFormat( "$" + "%01.0f", ValatBuytot ),  i + kk + 1, 4, color1 );
 
PrintInCell( StrFormat( "%01.0f", Ftot ),                   i + kk + 1, 6, color1 );
PrintInCell( StrFormat( "%01.1f", FTot1dROC ) + "%",        i + kk + 1, 7, color5 );
PrintInCell( StrFormat( "$" + "%01.0f", GainDol1dTot ), i + kk + 1, 8, color6 );
PrintInCell( StrFormat( "%01.1f", TotChg ) + "%",           i + kk + 1, 9, color7 );
PrintInCell( StrFormat( "%01.1f", Ftot21 ) + "%",           i + kk + 1, 10, color8 );
PrintInCell( StrFormat( "%01.1f", Ftot63 ) + "%",           i + kk + 1, 11, color9 );
 
 
if ( ShowPlot != 0 )
{
    Plot( Ftot, "", 1, 1 );
}
 
GraphXSpace = PlotSpace;

1 comments

1. bodisaudi

error

Leave Comment

Please login here to leave a comment.

Back