MacD (Future Known or Unknown) Strategy
Jan 23, 2020

The MacD (Future Known or Unknown) Strategy indicator is a backtesting tool designed to baseline the maximum potential of a MACD-based strategy by utilizing multi-timeframe analysis and optional lookahead functionality.
Usage
This tool is primarily used as a comparative benchmark to evaluate how a standard strategy performs against a "perfect" scenario. By visualizing 4-hour MACD states on lower timeframes (ideally the 30-minute chart), users can identify ideal entry and exit points.
The strategy utilizes color-coded histograms to represent the state of the 4-hour MACD:
- Solid Green: MACD histogram is above zero and rising.
- Faded Green: MACD histogram is above zero but falling.
- Solid Red: MACD histogram is below zero and falling.
- Faded Red: MACD histogram is below zero but rising.
When the "Use The Future?" setting is enabled, the strategy uses barmerge.lookahead_on to enter positions at the earliest possible moment of a trend shift. This is intended for educational and research purposes to study pattern recognition at pivot points.
Details
The script calculates the MACD histogram (12, 26, 9) and requests its value from a higher timeframe (240 minutes / 4 hours) using the request.security function. The core logic hinges on the toggle between barmerge.lookahead_on and barmerge.lookahead_off.
- Future Known: Uses lookahead to see the value of the 4-hour candle before it has closed on the lower timeframe chart. This produces idealized results that cannot be replicated in live trading but serve as a "ceiling" for strategy potential.
- Future Unknown: Uses standard data processing without lookahead, showing how the same logic performs when forced to wait for confirmed candle closes.
Settings
Strategy Configuration
- Allow position ONLY in LONG: Limits the strategy to only executing buy/long orders.
- Allow position ONLY in SHORT: Limits the strategy to only executing sell/short orders.
MACD Parameters
- MacD Fast Length: The period for the fast exponential moving average.
- MacD Slow Length: The period for the slow exponential moving average.
- MacD Signal Length: The period for the signal line smoothing.
Logic & Backtesting
- Use The Future?: Toggles the lookahead feature. When enabled, results reflect "perfect" timing; when disabled, results reflect standard execution.
- Backtesting Range: A set of inputs (Year, Month, Day) to define the specific start and end period for the strategy calculations.
FAQ
How do I use the MacD (Future Known or Unknown) Strategy?
You can use it to compare your manual trading or other automated scripts against a theoretical maximum performance to see where your entries could be improved.
Why are the results so good when "Use The Future" is on?
This is due to the lookahead parameter, which allows the script to see higher timeframe data before it is technically finalized on your current chart. This is for analysis only and is not tradable in real-time.
Where can I access this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.