PureBytes Links
Trading Reference Links
|
Your problem may be trade delays, or it may be just that once the
close is above 200, every single bar will have a buy condition as long
as it stays above 200. This means every one of those bars except the
first one at the crossover point will also have a sell condition. That
will give nearly all those bars a buy and sell condition on the same bar.
If you only want one buy signal when the price first goes above 200,
use the Cross function:
Buy = Cross(Close, 200);
That will only generate a buy signal when the close line crosses above
the 200 line, not on every bar after that as well.
To write that same sell condition without using a loop, you could use:
Sell = Ref(Buy, -1);
That makes the sell array equivalent to the buy array but shifted one
day forward (ie. each bar's sell is the same as the previous bar's buy).
For other documentation, there are a couple of documents I've put in
the files area on looping and the custom backtester interface.
However, the former is really aimed at people whose knowledge is the
other way around, familiar with using arrays but not loops. You may
find it useful though. The files are called "Looping in AmiBroker
AFL.pdf" and "AmiBroker Custom Backtester Interface.pdf".
Regards,
GP
--- In amibroker@xxxxxxxxxxxxxxx, "jl2012_30" <jl2012_30@xxx> wrote:
>
> I'm totally new to Amibroker and am trying to figure out how its
> array works. I have quite extensive experience with C programming and
> understand that AFL works pretty much like C. However, when I try
> programming with arrays, I get very unpredictable results...
>
> For instance, with the code below, I would expect the system to buy
> when the close is greater than 200 (it does this as expected). I
> thought it should sell the next day, since I wrote Sell [i+1] = 1.
> However, the system sells on the same day instead.
>
> I know I'm missing something here. Any help will be very much
> appreciated.
>
> Btw, just wondering if there's any other books/reference guides out
> there on AFL, besides the user guide. Thanks.
>
> --------------------------------
> Buy = C > 200;
> Sell = 0;
>
> for (i=0; i< BarCount; ++i)
> {
> if (Buy [i] AND i+1<BarCount)
> Sell [i+1] = 1;
> }
>
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|