PureBytes Links
Trading Reference Links
|
Hello,
You don't need a loop for that. Try the following code.
It gives you a buy signal when the cross happened in the last 7 bars.
And in explore mode it shows you the number of bars since the cross
happened.
indicator1 = MACD();
indicator2 = Signal();
BarsSinceCross = BarsSince(Cross(indicator1,indicator2));
Buy = BarsSinceCross <=7;
Filter = BarsSinceCross <=7;
AddColumn(BarsSinceCross,"Barssince cross",1.0);
Thomas
www.patternexplorer.com <http://www.patternexplorer.com/>
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of efex77
Sent: Friday, March 16, 2007 2:11 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Is this code for CROSS search ok? Help please
Hi,
I'm trying to explore for stocks where there have been an indicator like
MACD, cross on any of the previous N days (7 in this case)
If there was a cross of that indicator in the past N periods, then I need my
C2 variable to have a 1 so I can filter.
Can you please help on this and let me know if my code is ok or how can I do
it?
Here is the code to look for the cross:
for (i=BarCount-7; i<BarCount; i++)
{
Cond2 = Cross(indicador1,indicador2);
if(Cond2[i] > 0)
{
C2 =1;
}
}
------------------------ Yahoo! Groups Sponsor --------------------~-->
Transfer from your equities account.
Receive up to $1,000 from GFT. Click here to learn more.
http://us.click.yahoo.com/aZttyC/X_xQAA/cosFAA/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 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/
<<attachment: winmail.dat>>
|