NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 09-07-2010, 03:37 PM   #1
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default Opening and Last Close

How do I access the data in Market Analyzer's columns Opening and Last Close in code?
occam is offline  
Reply With Quote
Old 09-07-2010, 03:55 PM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thank you for your forum post.

The best way to do this is to use the indicator CurrentDayOHL() to get the open/high/low values.

http://www.ninjatrader.com/support/h...nt_day_ohl.htm

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 09-08-2010, 06:07 AM   #3
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

Thank you.

What about yesterday's close?
occam is offline  
Reply With Quote
Old 09-08-2010, 06:52 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

For this, PriorDayOHLC() would be the way to go - http://www.ninjatrader-support.com/H...orDayOHLC.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 09-08-2010, 08:28 AM   #5
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

Thanks,

Would Close(0) also work, assuming it was loaded?
occam is offline  
Reply With Quote
Old 09-08-2010, 08:33 AM   #6
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Yes this would get yo the latest close price.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 09-09-2010, 08:17 AM   #7
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

How do I get a static daily close SMA? When I use SMA(Close, periods)[0] I seem to get a constanly changing value thru the day.
occam is offline  
Reply With Quote
Old 09-09-2010, 08:32 AM   #8
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

Wow I am starting to think NinjaTrader is not for me.

I am trying to do something very simple.

Get yesterday's close.
Get a moving average of daily closes.
Get today's open.

These are static values thru the day, yet I seem to be getting dynamic values. I have tried Open[0], CurrentDayOHL.Open[0] & CurrentDayOHL.CurrentOpen[0] to get a static Open and nothing seems to work.

I have tried Close[0], PreviousOHLC.Close[0] & PreviousOHLC.PreviousClose[0] for a simple yesterday close but these don't work either.

What is the deal?
occam is offline  
Reply With Quote
Old 09-09-2010, 08:58 AM   #9
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

When you run the indicator/strategy or apply the indicator to your chart in the parameters insure that Calculate On Bar Close = True. I suspect you have changed this to False.

When this is set to false the indicator will calculate on every tick recieved. If you set this to True it will calculate only at the end of the bar therefor giving you your static SMA value.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 09-09-2010, 09:11 AM   #10
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

I set CalculateOnBarClose = true;

Data should only update at the Close of day.

Data still changes.
occam is offline  
Reply With Quote
Old 09-09-2010, 09:44 AM   #11
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

What time frame chart do you have this attached too? It will only update on each bar close, if you have this applied to a 1 minute chart it will update every 1 minute for example?

If you want this to only update per day please run this on a daily chart.

If you need daily SMA value on a 1 minute chart please let me know and I can follow up with more detailed instructions on MultiSeries NinjaScript programming which would be required to do this. This is supported for indicators in NinjaTrader 7 only and only supported for strategies in NinjaTrader 6.5.

I look forward to assisting you further.
NinjaTrader_Brett is offline  
Reply With Quote
Old 09-09-2010, 09:51 AM   #12
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

The indicator is a column in the Market Analyzer
Indicator/Data Series/Type = Day
occam is offline  
Reply With Quote
Old 09-09-2010, 09:59 AM   #13
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

It would be best at this point if you would post the code your using so that I may assist you with this.

Please send this code to support at ninjatrader dot com attn: Brett or post to this forum.

To post it please export it by going to File->Utilities->Export NinjaScript.

I look forward to assisting you further.
NinjaTrader_Brett is offline  
Reply With Quote
Old 09-09-2010, 10:21 AM   #14
occam
Member
 
Join Date: Aug 2010
Posts: 89
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to occam
Default

protected override void Initialize()
{
Overlay = false;
CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
Print(Instrument.FullName.ToString());
Print(CurrentDayOHL().CurrentOpen[0].ToString());
Print(PriorDayOHLC().PriorClose[0].ToString());
Print(SMA(Close, Periods)[0].ToString());
}
occam is offline  
Reply With Quote
Old 09-09-2010, 11:30 AM   #15
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Thanks, Occam. Can you let us know which data provider you're using as well as if you're evaluating this on 6.5 or 7?
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to program stop on close at close price foxido Strategy Development 1 04-02-2010 09:33 AM
Exit-on-close handling initiated after market close tooearly Automated Trading 3 08-05-2009 08:07 AM
CrossAbove Close & Close[0] different results un$ane Strategy Development 6 06-05-2009 09:59 AM
Enter at Close, Exit next day Close tjendra Strategy Development 3 04-08-2009 11:33 AM
Charting high/low/close and open/close widths gluebunny Charting 11 09-29-2008 10:47 AM


All times are GMT -6. The time now is 03:55 AM.