NexusFi: Find Your Edge


Home Menu

 





ninjascript chart session template switch


Discussion in Traders Hideout

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




 
Search this Thread

ninjascript chart session template switch

  #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?
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
 hedgeplay 
Austin Texas / US
 
Experience: Intermediate
Frequency: Several times daily
Duration: Seconds
Posts: 176 since Dec 2019
Thanks Given: 145
Thanks Received: 211


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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts