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

Create a simple volatility indicator

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

    Create a simple volatility indicator

    Hello,

    Could anyone tell me how to do the following indicator:

    V0 = SMA(abs(Close[0]- Close[1]), 10)
    V1 = SMA(abs(Close[0] - Close[1]), 30)
    Val = V0 / V1

    Thanks very much for your help

    Best

    #2
    Hello guilhem,

    Thank you for your post.

    You could create an indicator for the code snippet you are referring to by first instantiating 'V0' and 'V1' as an SMA and instantiate 'abs' and 'Val' as a Series<double>. We set up our variables in State.DataLoaded. In OnBarUpdate we use a CurrentBar check to ensure there are bars being processed for out indicator to calculate. We then assign our abs variable a value, check to make sure that V1 does not return 0, assign Val the value V0 / V1 and finally assign Val to our plot.

    Please see the attached example demonstrating how this could be accomplished.

    Additionally, please see these help guide links for more information.

    Make sure you have enough bars in the data series you are accessing - https://ninjatrader.com/support/help...sub=CurrentBar

    AddPlot - https://ninjatrader.com/support/help...hlightsub=Plot

    Let us know if we may assist further.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much :-)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by traderqz, Yesterday, 09:06 AM
      3 responses
      21 views
      0 likes
      Last Post NinjaTrader_ThomasC  
      Started by f.saeidi, Today, 10:19 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by kujista, Today, 06:23 AM
      5 responses
      15 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by traderqz, Today, 12:06 AM
      3 responses
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by RideMe, 04-07-2024, 04:54 PM
      5 responses
      28 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X