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

[amibroker] Re: code for trailing stop



PureBytes Links

Trading Reference Links

I had same general issue a few weeks ago.

Tomasz responded with code snippet sample from "What's new in Amibroker":


/* a sample low-level implementation of Profit-target stop in AFL: */
Buy = Cross( MACD(), Signal() );
priceatbuy=0;
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 && Buy[ i ] ) 
priceatbuy = BuyPrice[ i ];
if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
{
Sell[ i ] = 1;
SellPrice[ i ] = 1.1 * priceatbuy;
priceatbuy = 0;
}
else
Sell[ i ] = 0;
}

Change logic from 'Profit Target' to trailing stop of your preference. 

Phsst

--- In amibroker@xxxxxxxxxxxxxxx, "Adrian Zaremba" <headcutter@xxxx>
wrote:
> Can I find somewhere a code for a trailing stop? I am not talking 
> about applystop function but a manually written code, like in 
> Tradestation.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/