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

Reply via email to