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

Re: [amibroker] Fwd: Delay first BUY signal by x bars



PureBytes Links

Trading Reference Links

Thanks very much Graham. Please let me know if my understanding is correct:

My testing period for an EMA cross over system is from 01Jan00 to  31Dec03, and I want to delay the first BUY signal by atleast 150 bars/ days from 01Jan00. So I use option 1 given by you in addition to whatever other BUY conditions that I have set.

The statement means (in English)

Check Status of the AFL action that it is running a Scan(3), or Exploration(4) or a backtest or optimisation (5)
iff true
Check the cumulated values of status("barsinrange") . Status("barsinrange") returns '1' for every bar that is within the test period, starting from the first bar. If the cumulated value of status("barsinrange") is > 150, then BUY.
iff false (ie if (Status("action")>2 is not true)
then return 1, and dont take the BUY signal.

Thus if on bar 150 in the optimisation mode, I get a valid EMA cross over, I dont get a BUY signal. The value cumulated so far is 149, and now increments by 1 to return 150.

On Bar151 I dont have a valid EMA cross signal, but the cumulated value increments to 151 and the system is now ready to take the next BUY signal.

But from Bar151 onwards the cumulation stops - the value remains at 151, resting after having done its job of delaying the first BUY signal by 151 bars.

Is this understanding correct? Thanks for the help.

best
kazaan

On 07/04/2008, Graham <kavemanperth@xxxxxxxxx> wrote:


If you want to delay based on bars in the actual test period you have selected, then maybe something like this might work
Buy = OtherBuyConditions and IIf(Status("action")>2,Cum(Status("barinrange"))>150,1);

If you just want to make sure there are 150 bars at the start of the symbol history then
Buy =  OtherBuyConditions and BarIndex()>150;

--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com



On 07/04/2008, furinkazaan <furinkazaan@xxxxxxxxx> wrote:
Hi,
I resend this mail since i dont see it on the forum. Pl excuse the duplication, if any. I appreciate any help. thanks.
best,
kazaan


---------- Forwarded message ----------
From: furinkazaan <furinkazaan@xxxxxxxxx>
Date: 2 Apr 2008 21:41
Subject: Delay first BUY signal by x bars
To: amibroker@xxxxxxxxxxxxxxx

Hi,
if Buy= cross(ema(c, 15), ema(c,50))
then it is recommended that no signals be taken till (as a thumb rule)  - Largest EMA * 3 periods
In this case how do instruct to postpone taking the first BUY signal till 50*3 =150 bars from the befining of test period?

Do I do something like  - iff(barindex() <=300, buy=0, buy) ??

Sorry if the code looks clunky - I am an absolute rookie and I have just written my first system AFL today. Still figuring if it works the way i intended it to! B-). But Amibroker rocks!
TIA
--
regards,
kazaan




__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___