Seeking Help: Rolling window and Hiken Ashi Issue

Hi everyone,

I am trying to write a simple script with 5 minutes Heiken Ashi Candles stored in a rolling window. However i am getting this error:

untime Error: This is a forward only indicator: HA(EURUSD_min) Input: 2018-07-01 17:00:00Z Previous: 2018-07-01 17:04:00Z (Open Stacktrace)


import numpy as np
import decimal as d
from datetime import timedelta, datetime

class FirstProject(QCAlgorithm):

def Initialize(self):


self.AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol
self.HA = self.HeikinAshi("EURUSD",Resolution.Minute)

#rolling windows for actual price
self.price_window = RollingWindow[QuoteBar](10)
#rolling window for HA indicator
self.HA_open_win = RollingWindow[d.Decimal](10)
self.HA_close_win = RollingWindow[d.Decimal](10)

#Consolidate Heiken Ashi
fiveMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=5))
fiveMinuteConsolidator.DataConsolidated += self.OnDataConsolidated
self.SubscriptionManager.AddConsolidator('EURUSD', fiveMinuteConsolidator)
self.RegisterIndicator('EURUSD',self.HA, fiveMinuteConsolidator)

def OnData(self, data):
if not (self.HA.IsReady): return

def OnDataConsolidated(self, sender, data):
if not (self.HA.IsReady): return


if not (self.price_window.IsReady):return
if not (self.HA_open_win.IsReady):return
if not (self.HA_close_win.IsReady):return

Update Backtest

"self.HeikinAshi("EURUSD",Resolution.Minute)" will be updated automatically with the specified minute resolution. To update the indicator with the consolidated bar, you should use the indicator constructor "HeikinAshi("EURUSD)" and update the indicator with self.RegisterIndicator(). 

In the helper method "OnDataConsolidated(self, sender, data)", data is the quote bar of 'EURUSD'. Instead of using data["EURUSD"], you should use "data" to update the rolling window.


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed