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

[amibroker] Re: code for trailing stop



PureBytes Links

Trading Reference Links

How to remove excessive buy signals?
After buy, it is possible the price never reach 1.1 * priceatbuy. 
Then another buy signal comes up. How to handle this senario?

--- In amibroker@xxxxxxxxxxxxxxx, "Phsst" <phsst@xxxx> wrote:
> 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 Remanufactured Ink Cartridges & Refill Kits at MyInks.com for: HP $8-20. Epson $3-9, Canon $5-15, Lexmark $4-17. Free s/h over $50 (US & Canada).
http://www.c1tracking.com/l.asp?cid=6351
http://us.click.yahoo.com/0zJuRD/6CvGAA/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/