NexusFi: Find Your Edge


Home Menu

 





ninjascript chart session template switch


Discussion in Traders Hideout

Updated
    1. trending_up 1,233 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?
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
MegaETH Proves the Crowd Right: Prediction Markets Calle …
Prediction Markets & Event Contracts
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
The Feds Stagflation Trap -- Negative Payrolls, $91 Oil, …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 hedgeplay 
Austin Texas / US
 
Experience: Intermediate
Frequency: Several times daily
Duration: Seconds
Posts: 216 since Dec 2019
Thanks Given: 159
Thanks Received: 241


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