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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
651 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
577 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment