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 NullPointStrategies, Today, 05:17 AM
                0 responses
                52 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                70 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                48 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X