NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-29-2012, 06:17 PM   #1
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default Close Price Indicator - SMA

Hi All,


Does anyone have a Last Close Price - SMA indicator they would recomend. I am new to NT.

Thank you in advance for any suggestions or thoughts.


Regards,

Art
Hockey_Mike is offline  
Reply With Quote
Old 07-29-2012, 06:22 PM   #2
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Hello,

The default SMA will give you the value based off the Close price. Does this indicator not offer what you are looking for?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 07-29-2012, 06:39 PM   #3
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Matt,

I am looking for the difference between the Close and SMA.

ie.

Close = 100
SMA = 95
I am looking for the value +5

Similarly

Close = 85
SMA = 95
I would be looking for the value -10

As far as I can tell there isn't a parameter in the built-in SMA to do this calculation.

Thanks
Hockey_Mike is offline  
Reply With Quote
Old 07-29-2012, 06:48 PM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Thanks for the clarification.

Believe the attached will do what you're looking for.
Attached Images
File Type: png closemsma.PNG (87.3 KB, 11 views)
Attached Files
File Type: zip ClosePriceSMA.zip (3.6 KB, 8 views)
NinjaTrader_Matthew is offline  
Reply With Quote
Old 07-29-2012, 11:04 PM   #5
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Matt,

This was exactly what I was looking for. Thank you.

I tried to load this as a column in the Market Analyzer, however the analyzer is leaving that row blank for all stocks I tried.

Is there another setting or flag I need to check/select? Is there something about this custom indicator that won't let me use it in the Market Analyzer?


Thanks
Hockey_Mike is offline  
Reply With Quote
Old 07-29-2012, 11:09 PM   #6
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Hello,

This should work int he market analyzer. Are you sure you have the Plot set to Plot0?

What data series do you have the indicator applied to? Is it a minute, tick or daily interval? Who is your data provider?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 07-29-2012, 11:29 PM   #7
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Matt,

You got it. It was the Plot0 on the Close indicator.

A final question I hope. Am I calculating different things?

Doing the math I see that for AAPL, the Last Price Column (585.16) minus the 10 period SMA (597.88) should equal -12.72. Shouldn't this be the same thing that the ClosePriceSMA(10) custom indicator is calculating? Instead the ClosePriceSMA(10) column is showing -12.43. What am I missing?

I have attached a word doc with screen shots of my column and indicator setups.

Thank you as always. You've been terrific.
Attached Files
File Type: doc Screenshot_SMA 10_ClosePriceSMA.doc (191.0 KB, 3 views)
Hockey_Mike is offline  
Reply With Quote
Old 07-29-2012, 11:44 PM   #8
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Hello,

You're doing the math right and those are for sure not the correct values. This indicator simply takes the Close of the current bar and subtracts the Sma period.

I'm curious about the last price column you have - can you please clarify who you use as your data provider?

If you add in another column using a 1 period SMA with calculate on bar close = false, does the 1 Period SMA match the LastPrice column?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 08-01-2012, 09:16 PM   #9
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Matt,


My data provider currently is setup as Yahoo!.

I added the SMA(1) colum you suggested and it matched the value of my Last Price column. Ironically, the SMA(10) value - Last Price value = the ClosePrice indicator value, as it should have. I did have to recreate the Market Analyzer layout as I didn't save it previously.

Bottom line, it looks as if it is working, any idea what I was doing incorrectly? Do you think that the last price or SMA(10) was setup incorrectly?

Thanks again for your help. I've attaced a screenshot of the Market Analyzer.

Art
Attached Files
File Type: doc Screenshot_SMA 10_ClosePriceSMA.doc (295.5 KB, 3 views)
Hockey_Mike is offline  
Reply With Quote
Old 08-01-2012, 09:29 PM   #10
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,794
Thanks: 160
Thanked 568 times in 559 posts
Default

Art,

I'm not totally sure why that wasn't work for you earlier, but I'm glad to see they are working now.

I'd suggest keeping an eye on the 1 period SMA to see if you ever run into a case where that does not match your last price.

You can always right click on the market analyzer and select reload historical data to update the values.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 08-01-2012, 11:08 PM   #11
Hockey_Mike
Junior Member
 
Join Date: Jul 2012
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Matt,

Thank you sir. You've been great. Very helpful and timely in your responses.

Best,

Art
Hockey_Mike is offline  
Reply With Quote
Reply

Tags
indicator, sma

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
SMA Greater than Close Hockey_Mike Market Analyzer 5 07-27-2012 10:36 AM
Discrepancy between plotted SMA and Indicator SMA? Bogomir28 Indicator Development 2 03-24-2012 03:49 PM
indicator to plot the 50 period sma of the 5 sma brdnickel NinjaScript File Sharing Discussion 6 01-26-2011 01:03 PM
Close price not ZivalueCharts close price plot in the market analyzer randomwalker Market Analyzer 1 05-22-2010 06:39 PM
Comparing Close to SMA value failing - why? Iggy22 General Programming 2 04-19-2008 12:47 AM


All times are GMT -6. The time now is 02:04 AM.