Skip to content
All library documents

Higher-Timeframe Moving Average Cross Strategy with Risk-Reward Exits

Article Strategy library · Author: Shivam_Mandrai

Summary

This Pine strategy uses two configurable moving averages calculated on a selected higher timeframe. Its defaults are 20- and 50-period exponential averages on hourly data, though users can choose other supported average types, sources, lengths, and timeframes. A confirmed crossover opens a long position, while a confirmed crossunder opens a short position; entries are limited to times when no position is open.

For risk management, the script records the prior bar’s low for a long stop and prior bar’s high for a short stop, then sets profit targets using a configurable risk-to-reward multiple. The excerpt ends partway through the take-profit calculation, so it does not show the full order-exit implementation or establish how the strategy performed. It includes assumed slippage and commission settings, but provides no backtest results, market-specific evidence, or discussion of failure modes. Higher-timeframe data handling and smoothing options are configurable, and their effect on signal timing should be assessed before use.

Key ideas

  • The strategy compares two moving averages calculated from configurable higher-timeframe data.
  • A confirmed upward cross opens a long position, while a confirmed downward cross opens a short position.
  • Entries are only allowed when the strategy is flat.
  • Stops use the prior bar’s low or high, with profit targets based on a configurable risk-to-reward multiple.
  • The excerpt is incomplete and supplies no performance evidence.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.