Skip to content
All library documents

Comparing Five-Period EMAs Across Timeframes in Pine Script

Article Strategy library · Author: QCoder

Summary

This brief example demonstrates requesting a five-period exponential moving average from another timeframe in Pine Script and comparing it with the chart’s own five-period EMA. It plots both series and enters long when the requested hourly EMA is above the chart-timeframe EMA, otherwise entering short.

The published backtest configuration specifies BTC/USD on Bitfinex, with daily bars and a one-hour base period over roughly one year. No performance results, trade statistics, or comparison against alternatives are provided. The example is therefore useful as a compact illustration of multi-timeframe data access and a simple directional rule, but it does not establish that the rule is profitable. The intended comparison also depends on the chart timeframe and how the platform aligns hourly values with chart bars.

Key ideas

  • A requested hourly EMA can be compared with an EMA calculated on the chart timeframe.
  • The example plots both averages to show their relationship.
  • It takes a long position when the hourly average is higher and a short position otherwise.
  • The published settings describe a BTC/USD backtest, but no performance evidence is included.

Tags

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