Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I have been learning ninja script, what I'm trying to do is program my indicator so that at market open (9:30am) it will start to plot a line of the market open price until the market closes (5:00pm) where it then stops plotting the market open price line until the next market day.
The Current Price line indicator that comes loaded with NT8 doesn't start at 9:30am through to market close at 5pm.
I have been reading and studying the NinjaScript Reference like crazy trying to workout the DateTime / TimeSpan section to the point of getting a headache lol
So any help or advice would be appreciated.
Thanks
Gra.
Can you help answer these questions from other members on NexusFi?
Thanks for your quick response and the code, It works but with a slight problem, what I'm seeing is it's not taking the open[0] price right at 9:30am, if you look at today, there were 2 bars with the 9:30 time stamp and it drew the line from the second one that had a half point difference. I tried adding so that it counted for the second as well but if you don't tell it to look for the exact second that the current bar prints at, it wont plot the line.
What instrument are you testing? ES?
If that is the case then the open can be read at 9:31 ET with Ninjatrader on a 1 minute chart. There is only one bar at 9:31 ET.
Sorry I forgot to say that I'm trading the ES, using a 2000 tick chart, today there is 2 bars at 9:30 am, looking back in my history sometimes there is 3 bars at 9:30am.
As a tick data series is non time dependent it means a bar of this type can traverse the market open without closing. I.E. it doesn't care about time.
Try this. It should be good for any bar type / data series.
--------------------------------------------------------
- Trade what you see. Invest in what you believe -
--------------------------------------------------------
You'll need to create a new indicator which Calculate.OnEachTick and you will also need to add a 1 minute dataseries and use the BarsArray[1] instruction to refer to this dataseries. I named this indicator "PlotOpenLevel".
The changes are:
in the State == State.Configure condition add this line...
AddDataSeries(Data.BarsPeriodType.Minute, 1);
In the OnBarUpdate method you need to read the time this way:
BarsArray[1] refers to the minute interval
barTime = BarsArray[1].GetTime(CurrentBar);
Then at 9:31 we read the open of the bar on the minute interval
openLevel = BarsArray[1].GetOpen(CurrentBar);
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
You need to use the SessionIterator. What you're trying to do is exactly its use case. SessionIterator combined with IsFirstTickOfBar will get you exactly the functionality you want.