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

RE: [amibroker] Re: How can I trigger ApplyStop?



PureBytes Links

Trading Reference Links

I assume you are telling us that your IIf statement is not working.
ApplyStop is "built-in" to the backtester. I don't think you can put it
inside a conditional statement. It "triggers" when the internal back
test procedure runs due to having Buy = Condition, Sell = Condition,
etc. //I am ready to be corrected on the above :-)

BuyPrice does not remember anything. It is merely a way to tell
Amibroker if you are buying at the Close or the Open (or some other
value) which changes on every bar. To tell AB to use the open price of
the NEXT bar, you must use these two lines of code:
BuyPrice = Open;
SetTradeDelays(1,1,1,1); //Sets Buy,Sell,Short,Cover delays

Of course, you will also want to set SellPrice, ShortPrice and
CoverPrice and set the TradeDelays appropriately.

If you want to remember the BuyPrice you must either keep a tracking
array using a loop or use ValueWhen(Buy,BuyPrice,1); which will give you
the BuyPrice of the most recent Buy signal...without regard to any
subsequent Sell, Short, Cover signals. If you have duplicate Buy
signals, then this gives only the most recent one, which may not be the
one you actually bought on.
--
Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of rockergab
Sent: Wednesday, May 10, 2006 12:07
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: How can I trigger ApplyStop?

--- In amibroker@xxxxxxxxxxxxxxx, Keith McCombs <kmccombs@xxx> wrote:
>
> I don't know about the rest of your code, but "C > BuyPrice*1.2" is 
20%, 
> not 2%.
> 
> rockergab wrote:
> 

Sorry. I mistyped my code! The correct code is this:

TradeStart = 1060505 
Buy = DateNum()==TradeStart; 
Sell = 0; 
ApplyStop(stopTypeLoss,stopModePercent,3,1,0,1); 
IIf(C > BuyPrice*1.02,ApplyStop
(stopTypeTrailing,stopModePercent,0.5,1,1,1),0); 

I'm a very beginner and the above code is only an attempt to write a 
micro trading system that help me to comprehend how AFL works. All 
the code is written above.
Buyprice variable seems not to save the value of my enter the trade 
in the date specified by TradeStart (5 May 2006). I don't know which 
value Buyprice represents.
Thanks in advance for every suggestion.






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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links



 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Everything you need is one click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/