Back

4 hour timeframe (Resolution)

Hello everyone,

 

I'm wondering how is it possible to use (4 hour) timeframe resolution, because resolution in lean only has daily hourly, minute and tick.

 

P.S I'm using custom forex data.

 

Thanks

Update Backtest








check the help for consolidators and the sample algso provided by the quantconnect team.

you have to use hour data with consolidator to scale it to 4 hour bars. check the examples!! and bootcamp

0

Michael Manus thanks for your reply,

I tried the example but it is still doing trades on hours like 3/17..etc and it is supposed to make trades only on 0/4/8/12/16/20

1

share some code maybe.

take the very basic spy consolidation example:

https://github.com/QuantConnect/Lean/blob/master/Algorithm.CSharp/DataConsolidationAlgorithm.cs

1) change the resolution to hour.

without providing resolution infos Minute is default ( AddSecurity(SecurityType.Equity, "SPY", Resolution.Hour); )

2) Use the  thirtyMinuteConsolidator  and change it to 4 hours ( TimeSpan.FromMinutes(30) -> TimeSpan.FromHours(4) )! so that the  ThirtyMinuteBarHandler-method gets called every 4th hour with a 4 hour candle

 

 

YOUR CODE IS STILL IN THE ONDATA METHOD? .......

0

Michael Manus Yes i still have my code inside ONDATA, and i'm not using TradeBars, i'm using custom data (i read my data from CSV or dropbox).

 

What am i supposed to use instead of TradeBarConsolidator since i'm using custom data not tradebars?

0

Michael Manus I fixed the issue but when i close a trade using SL or TP, it closes them on hourly basis not 4, for example it used to close trades on 3/15..etc which is wrong

0

maybe you have to consolidate it from minute resolution to hourly and than to 4 hours....so you can access it every minute if you need it....i dont know what your plans are.

example of this

https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/DataConsolidationAlgorithm.py
0

The point is that i don't use AddForex, AddEquity..etc because i use custom data and OnData looks like this

OnData(MyCustomDataClass data)

{

}

so it's giving me an error when i use TradeBarConsolidator or QuoteBarConsolidator

0

That's the exception i'm getting when i use QuoteBarConsolidator (since i'm using custom Forex data):

System.ArgumentException: Type mismatch found between consolidator and symbol. Symbol: AUDUSD does not support input type: QuoteBar. Supported types: MyCustomDataClass.

0

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