PureBytes Links
Trading Reference Links
|
Tomasz wrote code for adding buy, sell, short & cover signals
on an equity curve as shown at
http://www.amibroker.com/kb/2006/05/06/discretionary-equity/#more-29
I changed portions of the code to replace the equity curve with a
price chart which after buy, sell, short or cover signals are added
via "Parameters" a backtest via AA "Automatic Analysis" can be
performed.
Hope this is of help.
Art F
/*
"I am looking for and add-on [?] that would enable me to build an
equity curve from buy/sell
signals that the trader directly draws over the price graph of a
commodity; for example, using
specific active vertical lines. Such a software would be of great
help for discretionary
traders to validate their semiautomatic systems. ? PH CHAMBAULT"
The following code implements the above idea:
To use it, simply paste the code in the Formula Editor, press "Apply
Indicator", then click
with RIGHT mouse button over chart pane and select "Parameters". In
the parameters dialog
you will see several buttons that allow you to place and clear trade
signals. To place
signal for particular bar first SELECT the bar by clicking on the
chart once in desired
place and then press one of the buttons in Parameter dialog.
Filed by Tomasz Janeczko at 9:06 am under AFL, Indicators
*/
Buy = 1;
Sell = Cover = Short = 0;
bh = Equity( 0, 0 );
setbuy = ParamTrigger("Buy", "Buy" );
setsell = ParamTrigger("Sell", "Sell" );
setshort = ParamTrigger("Short", "Short" );
setcover = ParamTrigger("Cover", "Cover" );
clear = ParamTrigger("Clear", "Clear" );
clearall = ParamTrigger("Clear All", "Clear All" );
bi = BarIndex();
sbi = SelectedValue( bi );
qty = LastValue( bi );
Varname = Name() + sbi;
if( setbuy )
{
StaticVarSet( Varname, 1 );
}
if( setsell )
{
StaticVarSet( Varname, -1 );
}
if( setshort )
{
StaticVarSet( Varname, -2 );
}
if( setcover )
{
StaticVarSet( Varname, 2 );
}
if( clear )
{
StaticVarRemove( Varname );
}
if( clearall )
{
for( i = 0; i < qty; i++ ) StaticVarRemove( Name() + i );
}
Buy = Sell = Short = Cover = 0;
for( i = 0; i < qty; i++ )
{
sig = StaticVarGet( Name() + i );
if( sig == 1 ) Buy[ i ] = True;
if( sig == -1 ) Sell[ i ] = True;
if( sig == -2 ) Short[ i ] = True;
if( sig == 2 ) Cover[ i ] = True;
}
Color = IIf( Buy OR Cover, colorGreen, colorRed );
RedundantBuy = Buy;
RedundantSell = Sell;
RedundantShort = Short;
RedundantCover = Cover;
e = Equity( 1, 0 );
Plot( C, "", colorBlack,styleCandle );
//Plot( e, "Equity", colorRed );
PlotShapes( Buy * shapeUpArrow +
Sell * shapeDownArrow +
Short * shapeHollowDownArrow +
Cover * shapeHollowUpArrow,
Color);
RedundantBuy = RedundantBuy AND NOT Buy;
RedundantSell = RedundantSell AND NOT Sell;
RedundantShort = RedundantShort AND NOT Short;
RedundantCover = RedundantCover AND NOT Cover;
PlotShapes( RedundantBuy * shapeSmallUpTriangle +
RedundantSell * shapeSmallDownTriangle +
RedundantShort * shapeHollowSmallDownTriangle +
RedundantCover * shapeHollowSmallUpTriangle,
Color);
GraphXSpace = 10;
Title=Name()+" "+ Date()+" Open "+WriteVal(O,1.2)+"
High "+WriteVal(H,1.2)+" Low "+
WriteVal(L,1.2)+" Close "+WriteVal(C,1.2)+" Vol "+WriteVal
(V,1.0);
--- In amibroker@xxxxxxxxxxxxxxx, "almirfa06" <almirfa06@xxx> wrote:
>
>
> Dear Sir;
>
> Hi.
>
> I bought few shares on different dates & sold few.
>
> Please tell me how I can mark the Bought / Sold of each stock on
> individual charts, & is it possible to get gain /loss displayed on
the
> chart?
>
> Regards..
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|