Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Multi-instrument multi-timeframe strategy
Collapse
X
-
Multi-instrument multi-timeframe strategy
I'm looking to determine previous day close price for let say ZC and ES on the first minute bar of the current day. As trading hours are different i'm struggling to figure out that. There is IsFirstBarOfSession yet how this will not work in my situation as session for 2 instruments are different. Any suggestions or reference will be appreciated.Tags: None
-
Hello PageNotFound404,
BarsArray[1].IsFirstBarOfSession
https://ninjatrader.com/support/help.../barsarray.htm
https://ninjatrader.com/support/helpGuides/nt8/bars.htmChelsea B.NinjaTrader Customer Service
-
-
Hi,
After future try/research i still have question:
https://ninjatrader.com/support/help...adinghours.htm
Using this as example i did add
if (BarsArray[1].IsFirstBarOfSession)...
AddDataSeries("FDAX 03-23",BarsPeriodType.Minute, 1); and get result:
Calculating trading day for 11/10/2021 9:31:00 AM
The Current Trading Day 11/10/2021 starts at 11/10/2021 9:30:00 AM and ends at 11/10/2021 5:00:00 PM
Then i change the code
AddDataSeries("ES 03-23",BarsPeriodType.Minute, 1); and get result:
Calculating trading day for 11/10/2021 9:31:00 AM
The Current Trading Day 11/10/2021 starts at 11/10/2021 9:30:00 AM and ends at 11/10/2021 5:00:00 PM
Or w/e i try give me the same result. Yes, i'm using Trading hours "CME US Index Futures RTH"
As i understand, that may not be accurate, ES and FDAX do have different trading hours.
So my question is how i can create conditions, calculate time, or determine last bar of the session for the given instrument with ultimate goal trade only within trading hours and do not hold position overnight, or again, another way to pose question have in-force only intraday margin.
--PNF.
Comment
-
Hello PNF,
The hours data loads for a data series is controlled by the Trading Hours template for that specific series.
By default the TradingHours of the primary will be used for any additional series added with AddDataSeries(). It is possible to specify the TradingHours with the overload signatures that have a string tradingHoursName parameter. However, when doing so, data will only be processed in OnBarUpdate() when all series in are in session.
From the help guide:
"If your NinjaScript object is using AddDataSeries() allowing to specify a tradingHoursName, please keep in mind that: An indicator / strategy with multiple DataSeries of the same instrument will only process realtime OnBarUpdate() calls when a tick occurs in session of the trading hour template of all added series. Any ticks not processed will be queued and processed as a tick comes in for all subsequent DataSeries."
https://ninjatrader.com/support/help...dataseries.htm
As you are not specifying the tradingHoursName, you are loading the FDAX 03-23 with the 'CME US Index Futures RTH" trading hours applied.
Code:else if (State == State.DataLoaded) { if (BarsArray.Count > 1) Print(string.Format("BarsArray[0]: {1}, BarsArray[1]: {1}", BarsArray[0].TradingHours, BarsArray[1].TradingHours)); }
The FDAX is on the Eurex exchange using the 'Eurex Equity Index Futures' TradingHours template with a different set of hours.
Calculating the sessionEnd time or sessionBegin time is typically done with SessionIterator.
https://ninjatrader.com/support/help...oniterator.htm
Below is a link to an example that uses the sessionEnd time.
https://ninjatrader.com/support/foru...ples#post93881
This accounts for holidays defined in the TradingHours as well.
Outside of adding a series and using the sessionIterator you can loop through the MasterInstrument.TradingHours.Sessions. But this would not account for holidays and you would need to calculate holidays with further custom logic.
https://ninjatrader.com/support/help...s_sessions.htm
https://ninjatrader.com/support/help...8/holidays.htmChelsea B.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Net_Trader, 03-15-2023, 03:17 PM
|
16 responses
178 views
0 likes
|
Last Post
![]()
by Net_Trader
Today, 04:43 PM
|
||
Started by Vern10, Today, 10:51 AM
|
4 responses
30 views
0 likes
|
Last Post
![]()
by Vern10
Today, 03:53 PM
|
||
Started by HalTech, Today, 02:11 PM
|
2 responses
36 views
0 likes
|
Last Post
![]()
by HalTech
Today, 03:09 PM
|
||
Started by Gianpiero, Today, 01:41 PM
|
1 response
15 views
0 likes
|
Last Post
|
||
Started by josh18955, Today, 11:16 AM
|
1 response
19 views
0 likes
|
Last Post
![]() |
Comment