PeriodMA = Param("MA Period", 20, 5, 200, 1); RSIPeriod = Param("RSI Period", 14, 5, 50, 1); RSIOverbought = Param("RSI Overbought", 70, 50, 90, 1); RSIOversold = Param("RSI Oversold", 30, 10, 50, 1);
// Trend Zone Background if(ShowZones)
// 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); amibroker afl collection
// ----------------------------------------------------------- // 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();
// ----------------------------------------------------------- // 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);
// ----------------------------------------------------------- // 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; PeriodMA = Param("MA Period", 20, 5, 200, 1);
// ----------------------------------------------------------- // 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;
// RSI in separate window rsiColor = IIf(LTF_RSI > RSIOverbought, colorRed, IIf(LTF_RSI < RSIOversold, colorGreen, colorLightGrey)); Plot(LTF_RSI, "RSI (" + RSIPeriod + ")", rsiColor, styleLine | styleThick); Plot(RSIOverbought, "OB", colorRed, styleDashed); Plot(RSIOversold, "OS", colorGreen, styleDashed);
// 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); PeriodMA = Param("MA Period"
// ----------------------------------------------------------- // COMMENT BLOCK (for documentation) /* == MULTI-TIMEFRAME TREND & MOMENTUM SCANNER ==
// Optional: Exit signals Buy = ExRem(BuySignal, SellSignal); Sell = ExRem(SellSignal, BuySignal);
Short = SellSignal; // Example short logic Cover = BuySignal;