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

[amibroker] MACD Histogram



PureBytes Links

Trading Reference Links

Hi,

I am having a little difficulty with an AFL formula. I want to 
compare one weeks MACD Histogram value to the previous weeks MACD 
Histogram value. My code is as follows

TimeFrameSet(inWeekly);
function TrendUpDirection()//Buy
{
		local trendUpDirection; 	
		local thisWeeksMACDHist;
		local lastWeeksMACDHist;	
		thisWeeksMACDHist = MACD(12,26)-Signal(12, 26,9);
		lastWeeksMACDHist = Ref(MACD(12,26),-1)-Ref(Signal
(12,26,9),-1);

		trendUpDirection = IIf (thisWeeksMACDHist < 0 AND 
lastWeeksMACDHist < thisWeeksMACDHist, 1,0);
		TimeFrameRestore();	
		return trendUpDirection;
}

Buy = TrendUpDirection() == 1;


A majority of the time this code produces tickers that satisfy my 
scan but sometimes scan results do not coincide with the AFL function 
above e.g.(1) ticker CAG is a result for scan on 12/7/2007 when in 
actual fact its MACD Hist is above 0 and e.g.(2) on the 12/7/2007 
LMR.l (London) this weeks MACD Hist is less than 0 but the previous 
MACD Hist is greater than this weeks. I am concluding there is 
something a miss with the code? 


As a second query, ideally I would like to subsitute TimeFrameSet
(inWeekly) with TimeFrameSet(5*inDaily) above for extra backtesting. 
But I am correct is saying I am not able to view 5*inDaily bars in a 
chart?


Many thanks for your help



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/