![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Sep 2007
Posts: 17
Thanks: 0
Thanked 1 time in 1 post
|
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é |
|
|
|
|
|
#2 |
|
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.
|
|
|
|
|
|
#3 |
|
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
|
|
|
|
|
|
#4 |
|
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 |
|
|
|
|
|
#5 |
|
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 | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Took the NT auto script on-line class and have question? | rehtrade | Automated Trading | 1 | 05-18-2009 02:20 AM |
| Newby Script question | rehtrade | Automated Trading | 1 | 03-26-2009 10:15 AM |
| Question about Time and Ninja Script | rehtrade | Automated Trading | 1 | 03-26-2009 10:14 AM |
| First Ninja Script Question | Sidhartha | Indicator Development | 4 | 04-03-2008 07:35 AM |
| code script question | abikambic | General Programming | 8 | 06-19-2007 07:23 AM |