// 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);
// ----------------------------------------------------------- // 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;
// ----------------------------------------------------------- // USER INPUTS // ----------------------------------------------------------- TF1 = ParamTimeFrame("Higher Timeframe", "Weekly"); TF2 = ParamTimeFrame("Lower Timeframe", "Daily");
// ----------------------------------------------------------- // PLOTTING // ----------------------------------------------------------- Plot(C, "Price", colorWhite, styleCandle); amibroker afl collection
// Trend Zone Background if(ShowZones) styleNoLabel, 0, 1);
// Signals if(ShowSignals)
// ----------------------------------------------------------- // 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); // RSI in separate window rsiColor = IIf(LTF_RSI
You can save it as MTF_Trend_Momentum.afl .
//---------------------------------------------------------- // 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);
// ----------------------------------------------------------- // 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 (" + RSIPeriod + ")"
ShowSignals = ParamToggle("Show Buy/Sell Signals", "No|Yes", 1); ShowZones = ParamToggle("Show Trend Zones", "No|Yes", 1);
// Higher Timeframe MA Plot(HTF_MA_Exp, "HTF MA (" + Name() + ")", colorOrange, styleLine | styleThick);
// ----------------------------------------------------------- // 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();
// ----------------------------------------------------------- // COMMENT BLOCK (for documentation) /* == MULTI-TIMEFRAME TREND & MOMENTUM SCANNER ==