![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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;
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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;
http://www.ninjatrader-support.com/H...BackColor.html
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jan 2010
Location: New York, NY
Posts: 74
Thanks: 2
Thanked 1 time in 1 post
|
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.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |