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

Development of moving average

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

    Development of moving average

    Hello,

    Would it be possible to develop an Moving Average in NinjaTrader 7 that can change its period depending on the time interval of the chart?
    E.g. When i choose the 60 minute interval a period of 33, when i choose the 30 minute interval a period of 65 and on the 10 minute interval a period of 195? I want to build a procedure that can check the time interval and then adjust the period of the moving average.

    If so could you give me some clue where to start? I read through the Ninjascript section in the help menu, but im new to C#.

    Greetings.
    Last edited by ModularMix; 01-22-2010, 11:24 AM.

    #2
    Hello ModularMix,

    Thank you for your post.

    You should be able to do this with NinjaTrader 6.5 and 7.

    Code:
     
    if ((Bars.Period.Id == PeriodType.Minute) && (Bars.Period.Value == 60) )
    Value.Set(SMA(33)[0]);

    The snippet above will plot the 33 period simple moving average if the chart is a 60 minute chart.

    Using the Bars.Period property.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks, the code snippet you suggested worked for me.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X