NinjaTrader Support Forum New to NJ Script question

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

 11-08-2009, 01:30 AM #1 rkhanen Junior Member   Join Date: Sep 2007 Posts: 17 Thanks: 0 Thanked 1 time in 1 post New to NJ Script question Hi, I´m trying to make a simple % deviation from af moving average calculation. In plain language something like this: ((price.close-SMA(period))/SMA(period))*100 But although I have read the instructions in the help file I can´t seem to get it right in NJ Script - and I have no programming experience. Can anyone provide me with the correct code for this indicator? And maybe a small explanation in plain english of how it is constructed? King Regards René
 11-08-2009, 08:21 AM #2 VTtrader Senior Member   Join Date: Feb 2008 Location: www.integratedtradingtech.com Posts: 270 Thanks: 1 Thanked 79 times in 64 posts Rene, Try it like this. ((Close[0] - SMA(period)[0]) / SMA(period)[0]) * 100 VT Edit: Didn't see the english explanation part. Close[0] = Current bar's close. SMA(period) = the moving average but as a series, you need the [0] afterwards to reference the current bar's value of the SMA. Hope that helps. Last edited by VTtrader; 11-08-2009 at 08:43 AM.
 11-08-2009, 11:51 AM #3 rkhanen Junior Member   Join Date: Sep 2007 Posts: 17 Thanks: 0 Thanked 1 time in 1 post Thanks a lot for helping me! I have tried out your answer and got an error. I have probably messed something up
 11-08-2009, 11:58 AM #4 mrlogik Certified NinjaScript Consultant     Join Date: Sep 2006 Location: New York, USA Posts: 774 Thanks: 1 Thanked 7 times in 5 posts You're missing the semi-colon Code: `((Close[0] - SMA(period)[0]) / SMA(period)[0]) * 100;` "You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later" PureLogikTrading Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 11-09-2009, 12:17 AM #5 rkhanen Junior Member   Join Date: Sep 2007 Posts: 17 Thanks: 0 Thanked 1 time in 1 post Thanks for looking into it and helping out I am still getting an error code, but i think I can get ahead from here by putting more effort into it - thx again guys!

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News and Announcements     News and Announcements Application Technical Support     ATM Strategies (Discretionary Trading)     Automated Trading     Charting     Connecting     Installation and Licensing     Market Analyzer     Miscellaneous Support         Historical Version 7 Beta Threads             Critical Information - Please review             Version 7 Beta General Questions & Bug Reports         Historical NinjaTrader 6.5 Archive             Historical NinjaTrader 6.5 Beta Threads     Strategy Analyzer     SuperDOM and other Order Entry Windows NinjaScript Development Support     General Programming     Indicator Development     Strategy Development NinjaScript Educational Resources     Reference Samples     Tips NinjaScript File Sharing     NinjaScript File Sharing Discussion     Version 7 Indicators     Version 7 Strategies     Version 7 Miscellaneous Suggestions and Feedback     Suggestions And Feedback

All times are GMT -6. The time now is 02:03 PM.

 -- Fixed Width ---- Fluid Width NinjaTrader Support Forum - Archive - Top