Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

New to NJ Script question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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é

    #2
    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, 09:43 AM.

    Comment


      #3
      Thanks a lot for helping me! I have tried out your answer and got an error. I have probably messed something up

      Comment


        #4
        You're missing the semi-colon

        Code:
        ((Close[0] - SMA(period)[0]) / SMA(period)[0]) * 100[B][COLOR="Red"];[/COLOR][/B]
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          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!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          213 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          544 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          12 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          7 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X