Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can a strategy access the SMA indicator

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

    Can a strategy access the SMA indicator

    OK, a newbie question...I would like to have a strategy access the SMA indicator and make decisions based on the direction (long, short, flat) and angle (steepness) of the direction.

    Is this possible?

    And, can you point me to the correct documentation and functions?

    Thanks

    #2
    Hello Turtle Trader,

    This is possible but you will have to define direction and angle mathematically. An SMA will return just a numerical value so you have to tell NinjaTrader how to interpret this value. The reference sample below can help with using Rising and Falling conditions in the strategy wizard. Rising and Falling will simply compare an indicator with its previous value.


    For measuring angle, you can use NinjaScripts Slope() method. This will return the slope of a line measured in radians.
    http://www.ninjatrader-support.com/HelpGuideV6/Slope.html

    You also have access to all the C# math functions when using NinjaScript. Can find them at the link below:
    Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Plot the radians in an indicator

      I would like to plot the radians in an indicator...but being a code newbie...not sure how to do this...this is my effort so far but it doesn't work...can someone show me what it should be?


      protected override void OnBarUpdate()
      {
      double xslope = Slope(SMA(4), 3, 0);
      Value.Set(xslope);
      }

      Comment


        #4
        This is just the rise over run output, taking the inverse tangent of it would then get you the the degrees. To go then to radian just multiply by 180 / Pi (Math.Pi).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        638 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X