PureBytes Links
Trading Reference Links
|
This code does what you want. Install it, open the Parameters window and
click Buy or Short to begin a trade. You can also click Sell/Cover to end
the trade. Equity curve is calculated on-screen. It will remember different
symbols so you can switch symbols and make different trades.
PROBLEM: When you close Amibroker, all trades are lost as they are stored in
StaticVariables. You could probably write a routine to store the trades to a
file and retrieve them on re-opening.
This code is somewhere in the help files and was written by Tomasz.
_SECTION_BEGIN("Discretionary Trade Equity");
/*Manual trade placement:
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.*/
SetChartOptions(1,chartShowDates);
ie = Param("Initial Equity",20000,5000,100000,5000);
SetOption("InitialEquity",ie);
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, colorBlack, colorWhite );
RedundantBuy = Buy;
RedundantSell = Sell;
RedundantShort = Short;
RedundantCover = Cover;
e = Equity( 1, 0 );
Plot( e, "Equity", colorWhite, styleDashed|styleThick );
if (ParamToggle("Plot Buy & Hold equity line?","No|Yes",0)) Plot( bh,
"Buy-AND-Hold", colorWhite, styleOwnScale | styleDashed );
Plot( C, Name(), colorBlack, styleCandle | styleOwnScale );
PlotShapes( Buy * shapeUpArrow +
Sell * shapeDownArrow +
Short * shapeHollowDownArrow +
Cover * shapeHollowUpArrow,
Color, 0, e, -12 );
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, 0, e, -30 );
GraphXSpace = 10;
_SECTION_END();
--
Terry
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of imresident2001
Sent: Sunday, January 21, 2007 14:11
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Little help Flagging date a stock is purchased on
the chart
--- In amibroker@xxxxxxxxxxxxxxx, "Rik Rasmussen" <hrasmussen@xxx> wrote:
>
Thanks for the quick reply. I was playing around and found another
way. You can double click on the xaxis and small arrow appears. and if
you click on another day another arrow appears and it also calculates
the stock performance between the two dates. Only problem is if you
buy and sell the stock on 2 different dates it doesnt work.
I think the best way to do it is using the plot function in afl. but i
dont know how to code i wonder if someone who is an afl expert can
help us with that
> I do it by using the drawing tool and add an arrow to the chart and
a text
> box with notes about my purchase.
>
> I also add a blue horizontal line at the price I buy at, and a green
> horizontal line at my target price. Helps me see at a glance where I
stand.
>
>
> Rik Rasmussen
>
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
http://groups.yahoo.com/group/amibroker/
Individual Email | Traditional
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
amibroker-unsubscribe@xxxxxxxxxxxxxxx
http://docs.yahoo.com/info/terms/
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007 10:31 PM
|