Problem with timeframe setting in formula

Hi guys

I have been using AmiBroker for quiet some time but I know almost nothing about AFL. However I am familiar with programming in general and so I decided to modify an Ichimoku formula for my own use, to scan for flat kijun-sen instances in charts.

The formula works as much as I can see, but there is a problem. I use a local database for my quotes, and I have data for different time frames in separate ascii files (EURUSD1D, EURUSD4H and so on) from monthly to 5 min TF.

I want this formula to be able to tell me if there is a flat kijun in any of the time frames of all forex pairs. But apparently it treats them all as daily charts. I have even used TimeFrameSet and was ready to use multiple formulas to scan (one for each time frame) but to no avail. Can anyone help me? I am attaching the formula ( and screenshot of the files if possible):

//ICHIMOKU FLAT Scan

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}

TL = ( HHV( H, 9 ) + LLV( L, 9 ) )/2;
SL = ( HHV( H, 26 ) + LLV( L, 26) )/2;

Plot(TL,"TL",colorPink,styleDashed); // turning, conversion, or tenkan-sen line
Plot(SL,"SL",colorLightBlue,styleDashed); // standard, base, or kijun-sen line

//Buy & Sell = Flat Kijun (6 candles, 30 pip), Low or High for 6 candles more than 30 pip distance with SL (Kijun)

Sell = SL==Ref(SL,-1)AND Ref(SL,-1)==Ref(SL,-2)AND Ref(SL,-2)==Ref(SL,-3)AND Ref(SL,-3)==Ref(SL,-4)AND Ref(SL,-4)==Ref(SL,-5)AND Ref(SL,-5)==Ref(SL,-6)AND SL 0.00300 AND Close<TL AND LLV(L,6)- SL>(ATR(21)/4);
Buy = SL==Ref(SL,-1)AND Ref(SL,-1)==Ref(SL,-2)AND Ref(SL,-2)==Ref(SL,-3)AND Ref(SL,-3)==Ref(SL,-4)AND Ref(SL,-4)==Ref(SL,-5)AND Ref(SL,-5)==Ref(SL,-6)AND SL>TL AND SL-Close> 0.00300 AND Close>TL AND SL-HHV(H,6)>(ATR(21)/4);

PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),colorGreen,0,Low,Offset=-15);
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed,0,High,Offset=-15);

45

Thanks
Mehdi

Did you read “How to use this site”? Really pasting code without proper code tags makes it ill-formatted.

Sorry about that. No I did not actually.

I did manage to resolve the issue however to a degree. Changed the backtest settings to lower timeframe