NexusFi: Find Your Edge


Home Menu

 





ninjascript chart session template switch


Discussion in Traders Hideout

Updated
    1. trending_up 1,345 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 hachot 
Ljubljana Slovenija
 
Experience: Master
Platform: NinjaTrader
Broker: NTB
Trading: ES
Posts: 36 since Oct 2014
Thanks Given: 26
Thanks Received: 5

Hi, can anyone help me with some ninjascript code:
I would like to programatically change the chart session template from cme us index futures eth to cme us index futures rth. I have and indicator in which i will place the code, just need ninjascript code to do it. Is there anyone kind enough to give me a little bit of hand?

Thank you and best regards


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Al Arabiya: US-Iran Draft Deal Within Hours Contains Hor …
Prediction Markets & Event Contracts
Would a node-based workflow for automated trading be useful?
Traders Hideout
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
April CPI Preview: +3.7% YoY Expected at 8:30 AM ET -- C …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
2 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 hedgeplay 
Austin Texas / US
 
Experience: Intermediate
Frequency: Several times daily
Duration: Seconds
Posts: 219 since Dec 2019
Thanks Given: 160
Thanks Received: 243


hachot View Post
Hi, can anyone help me with some ninjascript code:
I would like to programatically change the chart session template from cme us index futures eth to cme us index futures rth. I have and indicator in which i will place the code, just need ninjascript code to do it. Is there anyone kind enough to give me a little bit of hand?

Thank you and best regards

Hard to do that.. switch templates after loading the dataseries.

Much easier just to:

1) Use ToTime() to control trading hours. This is the most popular approach.
https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?totime.htm
2) However, test for your needs to see if it simpler to just initially two dataseries in the place of one.. Load one dataseries for each trading template you want to use. So add two of these to OnStateChange.Configure
AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)

https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?adddataseries.htm
and then reference them in your OnBarData() code first using BarsArray[1] and then BarsArray[2] when you want to switch between the two trading hours templates.
If you are using time to make that switch then you gotta ask yourself would just using ToTime() for trading hour control keep it simpler.

The NT support forum is actually a great place to ask this question and get good help all the way through your development process.
https://forum.ninjatrader.com/forum

Hedge


Reply With Quote
Thanked by:




Last Updated on May 2, 2023


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts