PrPrice = BarsArray[0].GetDayBar(1).Close; IndicatorValue.Set(PrPrice);
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
GetDayBar not working on Seconds timeframe
Collapse
X
-
GetDayBar not working on Seconds timeframe
Code:Tags: None
-
-
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; } }
Code:Add("SPY", BarsPeriod.BasePeriodType, BarsPeriod.BasePeriodValue);
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 algospoke, 04-17-2024, 06:40 PM
|
5 responses
46 views
0 likes
|
Last Post Today, 02:36 PM | ||
Started by arvidvanstaey, Today, 02:19 PM
|
1 response
4 views
0 likes
|
Last Post Today, 02:33 PM | ||
Started by mmckinnm, Today, 01:34 PM
|
3 responses
5 views
0 likes
|
Last Post Today, 02:12 PM | ||
Started by f.saeidi, Today, 01:32 PM
|
2 responses
8 views
0 likes
|
Last Post
by f.saeidi
Today, 02:10 PM
|
||
Started by alifarahani, 04-19-2024, 09:40 AM
|
9 responses
55 views
0 likes
|
Last Post Today, 02:02 PM |
Comment