Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use MACD in strategy

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

    Use MACD in strategy

    Hi ,
    I noticed the following lines in an existing strategy. Does this mean that the MACD indicator can be called as a method when writing Ninja script ?

    // Plots MACD color when rising or falling
    if (IsRising(MACD(Fast, Slow, Smooth)))
    {
    PlotBrushes[0][0] = Uptick;
    }
    else if (IsFalling(MACD(Fast, Slow, Smooth)))
    {
    PlotBrushes[0][0] = Downtick;
    }

    #2
    Hello judysamnt7,

    That is correct, indicators are a special type in NinjaScript so you can just call them by name like a normal C# method. The parameters they take vary but the syntax is always going to be IndicatorName(paramters)[barsago]

    The syntax you have shown is using a method called IsRising which takes a Series<double> as an input so in that case you drop the bars ago at the end and supply just the indicators plot which is the MACD(Fast, Slow, Smooth)

    Comment


      #3
      good to know that ! Similarly, can i just call avg or diff to get value for macd average and histogram , respectively?

      Comment


        #4
        Hello judysamnt7,

        Yes you can do that, you can use the plot names for indicators as well.

        Comment


          #5
          hi
          your link is not working. page not found error.
          can you give me an example how i call AVG or Diff for MACD ?

          Comment


            #6
            Hello judysamnt7,

            You can find examples of how to use the macd here:

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Comment


              #7
              thanks! but it’s just example of calling MACD , instead of calling diff or avg .

              Comment


                #8
                Hello judysamnt7,

                The page I linked shows how to get both the avg and diff in the sample on that page.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Mindset, 04-21-2026, 06:46 AM
                0 responses
                91 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by M4ndoo, 04-20-2026, 05:21 PM
                0 responses
                137 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Started by M4ndoo, 04-19-2026, 05:54 PM
                0 responses
                68 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Started by cmoran13, 04-16-2026, 01:02 PM
                0 responses
                121 views
                0 likes
                Last Post cmoran13  
                Started by PaulMohn, 04-10-2026, 11:11 AM
                0 responses
                72 views
                0 likes
                Last Post PaulMohn  
                Working...
                X