Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
DrawRegion question
Collapse
X
-
Originally posted by eDanny View PostMan I totally overlooked that because I was thinking Overlay = false did that. Thanks for the reminder.
Quick question:
Do you have a code snippet for shading the areas that are not in your trading session. I want to see the part I am trading in white, and the non-tradeable hours in gray or whatever.
I am sure someone has done this, and I was hoping someone could save me the pain!
Example:
normal between 9:30am and 4pm
gray outside of those frames.
My guess is I need to get the bar for the time, etc. and drop those in the DrawRegion, etc., but being it's my first time attempting this, I see pain ahead for a mere mortal attempting to program said.
Anyone?
Thanks,
Comment
-
Oh! I'm a new man and should get more life out of my eyes.
Thanks Josh, worked fine.
Spoke too soon :-(
I need the inverse. I would like the trading hours normal (from to) and the area outside that range to be grayed.
I tried to inverse what you gave me, but it is giving nothing. My guess is that it is happening sequentially and i can't go backwards.
Do I need to use the GetBars in my case with DrawRegion?
UPDATE:
my first guess is to set default background to the color I want, and then use your snippet to set the trading hours to normal??
Thanks,Last edited by r2kTrader; 06-09-2009, 02:25 PM.
Comment
-
MultiTimeFrame - Strange Coloring
It might be a good idea to put this snippet under your primary test code:
if (BarsInProgress() == 0)
BackColor = Color.Gray;
if (ToTime(Time[0]) > 80000 && ToTime(Time[0]) < 160000)
BackColor = Color.White;
I was getting strange color placement and was about to post a question. But then I realized it might have to do with the fact that I had this at the top of my OnBarUpdate() and not in my bip test. I threw it under than and I am right as rain.
I hope this helps someone.
Thanks!
PS, eDanny, pick up the pace bud! The reply from you was well over 30 seconds! lol, thanks for pitching in so promptly.
Comment
-
Just wanted to update this thread for anyone who might want to know how to do the same thing.
I changed my code so that my grayed out area would be through all the panels and not just the chart. Helps me line up the indicators with the session I am watching.
If in a multi-instrument/time strategy, make sure you put this under bars in progress that tests for 0, or primary or your charts will be whacked out color wise.
Instead of using "white" I went with empty, felt "cleaner".
Also, I tried to put the default color under Initialize() but it broke the whole strategy. So if you want your shade to go through the chart and the panels below, then use what I have below.
Hope this helps someone.
// Set default background for the chart to gray.
BackColorAll = Color.LightGray;
if (ToTime(Time[0]) > 80000 && ToTime(Time[0]) < 160000)
BackColorAll = Color.Empty;
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,611 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
22 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment