could someone help me how to find out todays firstbarofsession time and then subtract 24 hours from it
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
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.htmBertrandNinjaTrader Customer Service
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.
BertrandNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ninza33, Today, 09:10 AM
|
1 response
10 views
0 likes
|
Last Post Today, 09:46 AM | ||
Started by goodknight777, Today, 08:43 AM
|
1 response
5 views
0 likes
|
Last Post Today, 09:25 AM | ||
Started by kramnor2001, Yesterday, 02:30 PM
|
3 responses
21 views
0 likes
|
Last Post
by kramnor2001
Today, 09:20 AM
|
||
Started by Padan, Today, 02:02 AM
|
3 responses
11 views
0 likes
|
Last Post Today, 08:54 AM | ||
Started by Tim-c, Today, 08:36 AM
|
1 response
3 views
0 likes
|
Last Post Today, 08:45 AM |
Comment