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

[amibroker] Re: trailing stop question from new user



PureBytes Links

Trading Reference Links

I seem to have a workaround, after finding that I could 
vary the trailing stop percentage with a variable:
(comments please !!)
=====================================================================
=====================================================================
SellSTOP=(ValueWhen(Buy,Ref(High,-1),N=1));
/* LOCK IN A FIXED STOP PRICE ON DAY OF ENTRY */

BuyPrice=Max(BuySTOP,Low);
SellPrice=Min(SellSTOP,High);

profit_percent=((100 * (High - BuyPrice)/BuyPrice) >= 10);

trail_stop_percent=IIf(profit_percent,3,100);

ApplyStop(2,1,trail_stop_percent,True,False);
/* IF PROFIT IS AT LEAST 10%, USE 3% TRAILING STOP, ELSE 100% */

Sell=Close < SellSTOP;
/* OTHERWISE USE ABSOLUTE STOP LOSS OF Inside Day High ON SETUP */

=====================================================================
=====================================================================

--- In amibroker@xxxxxxxxxxxxxxx, "jwilsonp2a" <j1wilson@xxxx> wrote:
> 
> 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


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/Tq9otC/XP.FAA/3jkFAA/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/