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 PhillT, 04-19-2024, 02:16 PM
|
4 responses
31 views
0 likes
|
Last Post
by PhillT
Today, 04:24 PM
|
||
Started by ageeholdings, 05-01-2024, 05:22 AM
|
5 responses
36 views
0 likes
|
Last Post
by ageeholdings
Today, 03:21 PM
|
||
Started by reynoldsn, Today, 02:34 PM
|
0 responses
8 views
0 likes
|
Last Post
by reynoldsn
Today, 02:34 PM
|
||
Started by nightstalker, Today, 02:05 PM
|
0 responses
16 views
0 likes
|
Last Post
by nightstalker
Today, 02:05 PM
|
||
Started by llanqui, Yesterday, 09:59 AM
|
8 responses
30 views
0 likes
|
Last Post
by llanqui
Today, 01:57 PM
|
Comment