// ----------------------------------------------------------- // LOWER TIMEFRAME MOMENTUM (e.g., Daily) // ----------------------------------------------------------- LTF_MA = MA(C, PeriodMA); LTF_RSI = RSI(RSIPeriod); LTF_MomentumUp = C > LTF_MA AND LTF_RSI > 50; LTF_MomentumDown = C < LTF_MA AND LTF_RSI < 50;
You can save it as MTF_Trend_Momentum.afl .
// Trend Zone Background if(ShowZones) styleNoLabel, 0, 1); amibroker afl collection
// Lower Timeframe MA Plot(LTF_MA, "LTF MA", colorYellow, styleLine | styleDots);
//---------------------------------------------------------- // Multi-Timeframe Trend & Momentum Scanner // For Amibroker AFL Collection //---------------------------------------------------------- SetChartOptions(0, chartShowDates | chartWrapTitle, 0, 0); SetChartBkColor(ColorRGB(10,10,20)); SetChartBkGradientFill( ColorRGB(5,5,15), ColorRGB(20,20,40)); SetTradeDelays(1,1,1,1); LTF_RSI = RSI(RSIPeriod)
// Higher Timeframe MA Plot(HTF_MA_Exp, "HTF MA (" + Name() + ")", colorOrange, styleLine | styleThick);
// ----------------------------------------------------------- // SCAN / EXPLORATION OUTPUT (for AA Window) // ----------------------------------------------------------- Filter = Buy OR Sell; AddColumn(C, "Close", 1.2); AddColumn(LTF_RSI, "RSI", 1.2); AddColumn(HTF_RSI_Exp, "HTF RSI", 1.2); AddColumn(IIf(Buy, "BUY", IIf(Sell, "SELL", "")), "Signal", 1.0); LTF_MomentumUp = C >
// ----------------------------------------------------------- // HIGHER TIMEFRAME TREND (e.g., Weekly) // ----------------------------------------------------------- TimeFrameSet(TF1); HTF_Close = C; HTF_MA = MA(C, PeriodMA); HTF_RSI = RSI(RSIPeriod); HTF_TrendUp = HTF_Close > HTF_MA; HTF_TrendDown = HTF_Close < HTF_MA; TimeFrameRestore();
// Expand HTF values to current timeframe HTF_MA_Exp = TimeFrameExpand(HTF_MA, TF1, expandFirst); HTF_TrendUp_Exp = TimeFrameExpand(HTF_TrendUp, TF1, expandFirst); HTF_TrendDown_Exp = TimeFrameExpand(HTF_TrendDown, TF1, expandFirst); HTF_RSI_Exp = TimeFrameExpand(HTF_RSI, TF1, expandFirst);
// ----------------------------------------------------------- // SIGNAL GENERATION (Confluence) // ----------------------------------------------------------- // Buy: HTF trend up + LTF momentum up + RSI not overbought BuySignal = HTF_TrendUp_Exp AND LTF_MomentumUp AND LTF_RSI < RSIOverbought; // Sell: HTF trend down + LTF momentum down + RSI not oversold SellSignal = HTF_TrendDown_Exp AND LTF_MomentumDown AND LTF_RSI > RSIOversold;