PrPrice = BarsArray[0].GetDayBar(1).Close; IndicatorValue.Set(PrPrice);
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetDayBar not working on Seconds timeframe
Collapse
X
-
GetDayBar not working on Seconds timeframe
this code works fine on 1 minute chart, but shows nothing on 1 second chart. What's the difference?Code:Tags: None
-
-
Also can I use this:Code:#region Variables // Wizard generated variables // User defined variables (add any user defined variables below) double PrPrice; #endregion protected override void Initialize() { Add("SPY", PeriodType.Minute, 1); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "IndicatorValue")); Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "UpLine")); Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DownLine")); Overlay = false; } protected override void OnBarUpdate() { if(BarsInProgress == 0) { if (Bars.GetDayBar(1) == null) { return; } PrPrice = BarsArray[0].GetDayBar(1).Close; IndicatorValue.Set(PrPrice); UpLine.Set(PrPrice*1.02); DownLine.Set(PrPrice*0.98); } else { return; } }
instead of this:Code:Add("SPY", BarsPeriod.BasePeriodType, BarsPeriod.BasePeriodValue);
in Initialize section?Code:Add("SPY", PeriodType.Minute, 1);
Actually the formula for PrPrice is more complicated, but the problem is in GetDayBar function.
Comment
-
nyse,
It looks like its working ok on my end. You may need to ensure you have the historical data availability for the 1 minute series.
You can also use PriorDayOHLC instead of the method you are using to get the open/high/low/close of the previous day.
Here is a way to use the BarsPeriod.BasePeriodType and BarsPeriod.BasePeriodValue. Its not specifically supported but it works most of the time.
Code:try { Add(Symbol2, BarsPeriod.Id, BarsPeriod.Value); } catch(Exception e) { Print("Warning : BarsPeriod.Id didn't work"); }Adam P.NinjaTrader Customer Service
Comment
-
The same with PriorDayOHLC. Works fine on 1Minute Data, shows nothing on 1Second data.
It works fine on Tick data too.Last edited by nysetrader; 05-15-2012, 10:52 AM.
Comment
-
If you mean symbol I'm using AAPL now. but it happens on all symbols I've tried. On Tick data it works fine too.
Comment
-
I'm not changing the code. I just switch in chart window timeframes from keyboard from 1M to 1T to 1S. and on 1S it shows no lines.
Comment
-
Seems to work fine now. Thank you. By the way, which function works faster, PriorDayOHLC or GetDayBar, for taking previous daily OHLC?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
161 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
308 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
245 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
349 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
179 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment