PureBytes Links
Trading Reference Links
|
Hello,
ApplyStops can be either enabled or disabled.
You can not change this bar-by-bar.
Instead write a code that uses a loop as shown in the User's Guide for profit target.
/* 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;
}
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "jwilsonp2a" <j1wilson@xxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, October 23, 2003 9:04 AM
Subject: [amibroker] trailing stop question from new user
>
> Hi,
>
> I am trying to implement a two tiered stop loss, one part being a
> trailing stop, the other a fixed stop. I want a 3% trailing stop if
> I am at least 10% profitable, else I want a fixed stop loss price.
>
> I thought I had it, but can't quite figure out how to utilize a
> variable in the ApplyStop(2,x,3,true,false) command. It is the "x" I
> just showed that needs to be a 1 to enable, or a 0 to disable.
>
> Here is a portion of my code:
>
> ==================================================
> .
> .
> .
> BuyPrice = Max(BuySTOP,Low);
> SellPrice = Min(SellSTOP,High);
>
> profit_ten_percent = (((High - BuyPrice)/BuyPrice) >= 0.10);
> enable_stop = IIf(profit_ten_percent,1,0);
>
> ApplyStop(2,enable_stop,3,True,False);
> Sell = Cross(SellPrice,Low);
> ==================================================
>
> It's the "enable_stop" variable that fouls this up. Is this strategy
> even possible? I would greatly appreciate any help on this.
>
> Thank you, Jim
>
>
>
>
> 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/
>
>
>
------------------------ 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/mOAaAA/3exGAA/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/
|