NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-11-2010, 11:27 AM   #1
Spartacus
Member
 
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
Default How to set a bar color intra-day

Hi,

Can anyone tell me how to change the color of the current and subsequent bars midstream via Ninja Script. What I'm trying to do is write something that would allow the price bars to change shade or color as it passes a particular time of the day. So if the price bars are originally green during regular market hours their color would change to another designated color once time has reached, let say, 4:15PM. Then the bars would change back to their original colors when it becomes 9:30AM, to show regular and non-regular market hours.

I've been fooling around writing some indicators in ninja script but can't figure out how to do this.

Regards,
Johnny
Spartacus is offline  
Reply With Quote
Old 02-11-2010, 12:51 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Spartacus,

Thank you for your post.

You can filter for time conditions. The reference samples below is used to limit trading during certain hours, but you might be able to modify the concepts to paint a bar at certain hours:
http://www.ninjatrader-support2.com/...ead.php?t=3226

You change BarColor using the barcolor property:
http://www.ninjatrader-support.com/H.../BarColor.html


You can add a check to only run on real-time data. Add this in the OnBarUpdate() section:
Code:
 
if (Historical)
   return;
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-11-2010, 05:25 PM   #3
Spartacus
Member
 
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
Default Thanks Ryan

Hi Ryan,

Thank you and it worked.

I assumed that working for bar type would also work for candle. Please see attached and can you comment on how to get it to work for candle as well as bar types. The stems seem uncolored. I mean that's good enough, but to distinquish between up & down candles, and the stems, do you have further suggestions? thanks!

Regards,
Spartacus
Attached Images
File Type: png 2-11-2010 7-14-55 PM.png (5.7 KB, 22 views)
Spartacus is offline  
Reply With Quote
Old 02-11-2010, 05:46 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Jonny,

Which version of NinjaTrader are you using? There's a change to the BarColor property in version 7.

Taken from:
http://www.ninjatrader-support2.com/...ad.php?t=21016

BarColor no longer colors the entire bar. It will color the bar body only. To color the bar outline please use CandleOutlineColor.


If you want Up/Down Colors you would have to add two extra conditions to evaluate and then paint the bars different colors. Something like:
Code:
 
 
if (Close[0] > Open[0] && yourTimeFilter)
     setYourUpColorHere;
 
if (Close[0] <= Open[0] && yourTimeFilter)
     setYourDownColorHere;
You might also consider changing the BackColor instead of the BarColor.
http://www.ninjatrader-support.com/H...BackColor.html
NinjaTrader_RyanM is offline  
Reply With Quote
Old 02-16-2010, 07:05 PM   #5
Spartacus
Member
 
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
Default

Hi Ryan,

Thanks for the information, very helpful. I am using NT7b9.

In the NT7 documentation I didn't come across anything like the member variable CandleOutlineColor that you pointed out in in the previous message, would you know what sources I can look at to find out such information?

I would like to make all the components (UP bar, DOWN bar, candle OUTLINE, "TO TIME", "FROM TIME) parameter driven. I have a good idea how to do it for integers (time components) when making the time parameters configurable, but for colors I simply don't know how to offset into the "plot" object to access the color so that I can store it into a local variable. Do I use the Ninja script wizard to plot the color? If so how would I reference that color from within the onBarUpdate method?

Your suggestion about changing the background color instead sounds just as good, however I'd like to get used to manipulating price bars as well.

Ryan, Thanks for your assistance.
Last edited by Spartacus; 02-16-2010 at 07:07 PM.
Spartacus is offline  
Reply With Quote
Old 02-17-2010, 08:10 AM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Spartacus,

Thanks for your comments. Below are a couple more links that should help.

NinjaTrader 7 Code Breaking Changes.

Creating User Definable Color Inputs.
NinjaTrader_RyanM 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
Intra-day historical charting sources? Trader61 Charting 1 08-29-2009 05:58 PM
Set bar color to black as default blarouche Indicator Development 1 08-27-2009 08:01 AM
Intra-day Average True Range in MA? Godzilla Market Analyzer 1 01-06-2009 05:55 AM
Intra bar order anapurna General Programming 5 09-22-2008 04:20 PM
Use of daily indicators during intra-day svrz Indicator Development 14 02-15-2008 12:26 PM


All times are GMT -6. The time now is 02:52 AM.