Back

Forex Multi Timeframe - All Data Note Being Processed

Hi,

When backtesting using a single Forex instrument with both daily and hourly timeframes, the daily data seems to be only processed in OnData weekly.  When removing the hourly timeframe the daily data is then processed daily as expected.

In the attached backtest you can see the console output printing the dates and time period.  If you remove the hour timeframe from the algo you'll also see it print the results correctly.  I've tested this locally on Lean too and the results are the same (to double check it wasn't the console output being limited).

Any thoughts?

Thanks

Update Backtest








0

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.


Hello Matthew,
Since the data in the Slice object is keyed by Symbol, we don't have more than one bar per Symbol. In this case, it is only available to use either an hourly time frame or a daily time frame. For the daily resolution, consolidators should be used. The reason why when putting both time frames generates weekly data is that there is no hourly bar on Friday midnight, so at that point, the daily bar can be registered.
Best,
Yuxin Guan (edited) 

0

Thanks for getting back to me Yuxin.

In that case, would using

public void OnData(TradeBars data)

alllow all data to flow through? (although I'm sure I tried this and had the same problem).

Thanks for the suggestion of using consolidators, I'm familiar with them and use elsewhere, and for creating daily Forex bars I don't see it being an issue.  However, for equities the official closing price is often not the last tick before the market close, so are there any alternate solutions for equities?

Thanks


 
0

Hi Matthew,

To have both hours and day bars, I would suggest using a Consolidator to consolidate the hour bars into day bars, which has the following form: Consolidate(Symbol/Security Name, resolution, MyConsolidatedBarHandler). So in this case, put the following line in the Initialize: Consolidate("EURUSD", Resolution.Daily, DayBarHandler); And define a DayBarHandler that accepts QuoteBars (for users using equities, use TradeBars instead). To see this in action, check out the attached backtest.

For closing prices, we use the official closing price in the last bar of the regular market hours.

The following line:

public void OnData(TradeBars data)

would have the same problem as before because Forex uses QuoteBars, not TradeBars, so the function wouldn't be triggered.

Best,
Shile Wen

0

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.


Thanks Shile.

If the official closing price is used in the last bar I assume this is a data transformation ran by the QuantConnect backend?  However for a live equity algo, how would I get the official closing price as the last bar may have completed before the official closing price is published?

0

Hi Matthew,

We will have this information once our L1 live data support comes out, which we hope to deploy over the weekend.

For backtesting however, you are right in that the official closing price is used for the last bar, which we handle automatically in the back end.

Best,
Shile Wen

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed