Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 12-26-2016, 11:35 AM   #1
FightOn2
Junior Member
 
Join Date: Sep 2015
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default coloring premarket/afterhours sessions

Is there a way to change the background color of premarket/afterhours sessions?

thanks!
FightOn2 is offline  
Reply With Quote
Old 12-26-2016, 01:39 PM   #2
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,432
Thanks: 208
Thanked 536 times in 517 posts
Default

Hello FightOn2, and thank you for your question.

I have prepared the attached indicator for educational purposes which will accomplish this. Please let us know if there are any other ways we can help.
Attached Files
File Type: cs SessionColors.cs (6.0 KB, 57 views)
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 06-06-2018, 11:08 AM   #3
risteon
Junior Member
 
Join Date: Jun 2018
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_JessicaP View Post
Hello FightOn2, and thank you for your question.

I have prepared the attached indicator for educational purposes which will accomplish this. Please let us know if there are any other ways we can help.
Sorry to dig up an old thread, but I was interested in something like this, and tried to use the script you posted. However when trying to save it, it gives the error "Unhandled exception: At least one object must implement IComparable."

I'm new to this and figured the script may work as is, which I could tweak from there if necessary. Any suggestions on resolving this error? Thanks!
risteon is offline  
Reply With Quote
Old 06-06-2018, 11:22 AM   #4
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,432
Thanks: 208
Thanked 536 times in 517 posts
Default

Thank you for your question risteon. It sounds like something is happening with your compile environment, as the SessionColors script doesn't use any IComparable overloads.



These troubleshooting steps should help us track down exactly where this message is coming from so we can remove it. Please repeat these steps and report back if you continue seeing this message about IComparable


  1. First, please remove your existing copy of SessionColors.cs from your system.
  2. Next, in NinjaTrader, please visit New -> NinjaScript Editor
  3. Next, in the NinjaScript Editor, please press the F5 button to compile. If you do not hear a chime, and you see error messages at the bottom, please use the Windows Snipping Tool to take a picture of your NinjaScript editor, and attach it to your reply.
  4. Assuming you did hear a chime, please re-download SessionColors.cs and copy / paste it to Documents\NinjaTrader 8\bin\Custom\Indicators .
  5. Finally, please select your NinjaScript editor once more, and press F5 to compile. Just like last time, if you don't hear a chime, please send us a picture of your editor window.


One of my colleagues will be happy to help if there are any more questions we may answer.
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 06-06-2018, 11:38 AM   #5
risteon
Junior Member
 
Join Date: Jun 2018
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_JessicaP View Post
Thank you for your question risteon. It sounds like something is happening with your compile environment, as the SessionColors script doesn't use any IComparable overloads.



These troubleshooting steps should help us track down exactly where this message is coming from so we can remove it. Please repeat these steps and report back if you continue seeing this message about IComparable


  1. First, please remove your existing copy of SessionColors.cs from your system.
  2. Next, in NinjaTrader, please visit New -> NinjaScript Editor
  3. Next, in the NinjaScript Editor, please press the F5 button to compile. If you do not hear a chime, and you see error messages at the bottom, please use the Windows Snipping Tool to take a picture of your NinjaScript editor, and attach it to your reply.
  4. Assuming you did hear a chime, please re-download SessionColors.cs and copy / paste it to Documents\NinjaTrader 8\bin\Custom\Indicators .
  5. Finally, please select your NinjaScript editor once more, and press F5 to compile. Just like last time, if you don't hear a chime, please send us a picture of your editor window.


One of my colleagues will be happy to help if there are any more questions we may answer.
That worked just fine. Thank you much!

I'll have to play around with it, as I would like to have a futures chart color the regular market session difference (9:30-4pm/eastern one color, everything else another color).
risteon is offline  
Reply With Quote
Old 06-06-2018, 06:32 PM   #6
risteon
Junior Member
 
Join Date: Jun 2018
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

In case anyone interested, I did a simple modification to JessicaP's script to accept input of a fixed start and end time to define the session. Defaults set to 9:30am and 4:00pm (since I'm eastern time) to represent normal market hours. I did this since I like to see this represented on futures symbols as well (just personal preference).
Attached Files
File Type: cs SessionColors2.cs (7.2 KB, 4 views)
risteon is offline  
Reply With Quote
Old 06-13-2018, 01:54 PM   #7
leon of pizza
Junior Member
 
Join Date: Mar 2017
Posts: 3
Thanks: 1
Thanked 0 times in 0 posts
Default

I don't know what to do with the CS file. In the user guide, the directions state that the import process expects a zip file. The ninja script editor is unavailable to me with the free license. Is the CS file loaded into the editor and then compiled? I don't mind doing my own reading but I couldn't find any material on the subject. Thanks.
leon of pizza is offline  
Reply With Quote
Old 06-13-2018, 01:58 PM   #8
risteon
Junior Member
 
Join Date: Jun 2018
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by leon of pizza View Post
I don't know what to do with the CS file. In the user guide, the directions state that the import process expects a zip file. The ninja script editor is unavailable to me with the free license. Is the CS file loaded into the editor and then compiled? I don't mind doing my own reading but I couldn't find any material on the subject. Thanks.
Just follow the 5 steps Jessica mentioned. That's what worked for me.
  1. First, please remove your existing copy of SessionColors.cs from your system.
  2. Next, in NinjaTrader, please visit New -> NinjaScript Editor
  3. Next, in the NinjaScript Editor, please press the F5 button to compile. If you do not hear a chime, and you see error messages at the bottom, please use the Windows Snipping Tool to take a picture of your NinjaScript editor, and attach it to your reply.
  4. Assuming you did hear a chime, please re-download SessionColors.cs and copy / paste it to Documents\NinjaTrader 8\bin\Custom\Indicators .
  5. Finally, please select your NinjaScript editor once more, and press F5 to compile. Just like last time, if you don't hear a chime, please send us a picture of your editor window.
risteon is offline  
Reply With Quote
Old 06-13-2018, 02:42 PM   #9
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,497
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello leon of pizza,

Thank you for your post.

Attached are the two files in their .zip format.
Attached Files
File Type: zip SessionColors.zip (2.0 KB, 4 views)
File Type: zip SessionColors2.zip (2.2 KB, 4 views)
NinjaTrader_PatrickH is offline  
Reply With Quote
The following user says thank you to NinjaTrader_PatrickH for this post:
Old 06-13-2018, 06:48 PM   #10
leon of pizza
Junior Member
 
Join Date: Mar 2017
Posts: 3
Thanks: 1
Thanked 0 times in 0 posts
Default

Thanks to all. I was able to load the CS file using a sim key Ryan gave me and I tried the other method with the zip files Patrick provided and it worked fine too. Thanks to risteon for making the time input a variable (not sure what the use of the first version is: all it does is shade the settlement session).

It creates over 1000 objects for a 30 day chart, and when I switch aggregation periods it takes over 20 sec to get sorted out. It seems to me that the feature could be added to whatever paints the background and it would use less resources there.

edit: 1000 objects for 30m bars. 30,000 objects for 1m bars. I tried changing the Calculate On variable - no help.
Last edited by leon of pizza; 06-13-2018 at 07:43 PM. Reason: new info
leon of pizza is offline  
Reply With Quote
Old 06-14-2018, 07:09 AM   #11
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 11,497
Thanks: 779
Thanked 1,977 times in 1,906 posts
Default

Hello leon of pizza,

Thank you for your response.

Utilizing the OnRender function to use custom rendering would improve performance of the indicator. You can find details on OnRender at the following link: https://ninjatrader.com/support/help...s/onrender.htm

Please let me know if you have any questions.
NinjaTrader_PatrickH is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for missing data (afterhours) ntfred Indicator Development 10 03-04-2013 01:55 PM
Charts not polotting in afterhours ? andy4 Platform Technical Support 6 10-14-2010 06:44 PM
How to gray out afterhours on all charts as a default? timothymhanna Platform Technical Support 6 10-07-2010 06:40 PM
Missing Chart data in afterhours sessions in NTv7 BrianL Platform Technical Support 4 09-24-2010 01:22 PM
ingore premarket and afterhours junkone Platform Technical Support 8 09-06-2009 11:53 AM


All times are GMT -6. The time now is 09:38 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.