EndofDay Trading and order execution an 4 pm

In my experience EndOfDay – trading means that at 4pm (end of day) indicators are updated, current stock values are used to execute trade logic to determine orders and then orders are sent  to the exchange. But I cannot achieve this behavior with QuantConnect. What I can see is that when using minute data OnData() is executed every minute from 9:30 until 4pm and EndofDay() is executed at 11:58pm. I have no idea when the indicator is updated?

To use minute data helps to understand intrabar behaviour when using limit orders. How can I achieve using minute data the intended behavior? The goal: updating indicators at 4 pm, executing order logic and issuing the order.

When using daily data (var equity = AddEquity(_spy, Resolution.Daily) then OnData is excuted at 12:00 pm and OnEndOfDay() at 11:58 PM. I don‘t know when the indicator is updated. ??

My question:

What is the best way using minute data that at 4pm (or 10 minutes before)  the following activities take place:

  • indicators are updated
  • trade logic is executed
  • orders are issued
Update Backtest

there is the Time property which you can help you. you can print the time and see when something happens:

line 86:


more complicated chapter indicator updates:

if you want manually update indicators you can use the update method :

class holding info with indicator:


so you could update indicators in the consolidator method if you want or use the schedule function BeforeMarketClose:



consolidator examples:

Thank you Michael.

I found out how to update the Indicators manually (see modified code in the backtest). 

Consolidators will help for this if High, Low data are required. Otherwise the update in OnData() is sufficient. 

To reconstruct exchange open/close times in this way is not nice, but at least it works.

Regards Ulrich 


"its not nice" hehe yes that is why you maybe should use beforemarketclose which is than 10 minutes before close. doesnt matter if its at 4 or like at thanksgiving at 1?.... i dont know


But how can the data be obtained wtihin 

 Schedule.On(DateRules.EveryDay(), TimeRules.BeforeMarketClose("SPY", 10), () =>

Is there a parameter for the data ? 


like _rc or _holdings you would need to save the price somewhere and access it in schedule.on.


Good point. I have changed the programm accordingly.

It is getting nicer now. One question:

   _data = data;

Will the above statement copy the whole object or just the pointer to the object? In case of copying the whole object for multiple symbols it would be better to store only the price value and time of latest price. 


phu i am not that good in c#,

but i think if its a string or integer it does a copy.

when its an array or list its a pointer/reference

Hi Michael,

Thank you for your time and immediates responses.

I think also it is just a copy of a reference/pointer and then it is okay.

Then the system is fine like this and works according to my intention.



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