could someone help me how to find out todays firstbarofsession time and then subtract 24 hours from it
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
finding calculating time difference
Collapse
X
-
basically what i am trying to plot is if its an upday ,the complete session colour should be green and if its down day it shoud be red.following is my code but it only drawss the last bar of session...pls advise
Code:if ( Bars.BarsSinceSession >=0) { if ((CurrentDayOHL().CurrentOpen[0] < Close[0]) && (ToTime(Time[0]) > 215900)) { BackColor = Color.FromArgb(100, Color.LightGreen); } if ((CurrentDayOHL().CurrentOpen[0] > Close[0]) && (ToTime(Time[0]) > 215900)) { BackColor = Color.FromArgb(100, Color.LightPink); } }
Comment
-
easyfying, that's because you chose to do the coloring only from a certain time on for the bars where the condition holds true, you're not coloring the past bars at this point.
You can do that however with the BackColorSeries by providing how many bars back to color via the index - https://www.ninjatrader.com/support/...olorseries.htm
Comment
-
thanks.
i wanted to plot background colour depending upon if the session was up or down.below code is working for me.but problem is the indicator shows rectangle only for previous day and not for all days.
Code:if (Bars.FirstBarOfSession) { if(PriorDayOHLC().PriorOpen[0] < PriorDayOHLC().PriorClose[0]) { DrawRectangle("Colorupdown", true, Time[1], PriorDayOHLC().PriorLow[0], Time[1].AddHours(-24), PriorDayOHLC().PriorHigh[0], Color.Transparent, Color.Green,2); } else if(PriorDayOHLC().PriorOpen[0] > PriorDayOHLC().PriorClose[0]) { DrawRectangle("Colorupdown", true, Time[1], PriorDayOHLC().PriorLow[0], Time[1].AddHours(-24), PriorDayOHLC().PriorHigh[0], Color.Transparent, Color.Pink,2); } }
Comment
-
The issue here is that you're really only drawing / modifying one object all the time by using the same tag id - namely the Colorupdown
When you are settings things for the new day / session you want to use a new tag id as well so a new draw object would get created and you would be able to see the history as desired.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
607 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
353 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment