• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Newbie MACD Strategy Builder question

  • Filter
  • Time
  • Show
Clear All
new posts

    Newbie MACD Strategy Builder question

    I'm new to NinjaTrader and I'm trying to use the Strategy Builder to create simple buy and sell signals based off of MACD crossovers.

    What I want is:

    Buy signal = MACD Line: (12-day EMA - 26-day EMA) CROSSES ABOVE the Signal Line: 9-day EMA

    Sell signal = Signal Line: 9-day EMA CROSSES ABOVE the MACD Line: (12-day EMA - 26-day EMA)

    Would extensive coding be required in building this? I have done some very minor code editing before, but not too much. I'm in the conditions category and I think that "crosses above" and "crosses below" will be selected int he middle there. But I'm a bit confused about what to do with the parameters. Also not sure what to do with inputs and variables. I'm a newbie to this platform, so any help would be greatly appreciated. Thanks!

    Newbie MACD

    Your on the right path. The conditions go in the upper portion of the Set 1 and the buy goes in the lower portion

    In Set 1 select add then indicator then MACD and select the correct parameters in the left panel and under plot select the AVG or MACD then the crossover you want and then in the panel on the right select the perimeters for the other MACD you are using. When that is as you want it go to the lower section and select add then order management then enter l;ong position or the type of entry you want.

    For the sell do the same thing but in a new set.
    you can stops and targets to select those items.

    Hope this helps.



      Thanks so much for the help! I used your guidance to figure out how to make the MACD strategy execute the way I wanted.

      I had another question. Is there a way to program a buy signal only when the crossover I mentioned occurs above the zero line?
      Last edited by JayKeepsTrading; 02-18-2018, 01:21 PM.


        Hello JayKeepsTrading,

        You can compare the lower of the two indicator values to be greater than a Numeric value in the Misc section of the condition builder and have this set to 0.

        I also wanted to provide a link to a forum post with helpful information about getting started with NinjaScript that includes a link to a video on the Strategy Builder.
        Chelsea B.NinjaTrader Customer Service


          Yes, you can what you are asking. Once you have the MACD cross set the way you want you add an additional statement.
          In Strategy Builder, on the Inputs and Variables screen click “Add” under Inputs. Name = MACDfast, Type = Double, Default = 0.5, Min = 0.1 Click OK
          Under Conditions & Actions screen set conditions to “If All” Click Add. In left box select MACD, change Value Plot to “Diff”.
          Set center box to “Greater” or “Greater Equal”.
          In right box select User Input MACDfast. Click OK and Compile.

          To do the opposite use Name = MACDslow, Type = Double, Default = -0.5, Min = -200 (remember -200 is less than -.5)
          Set center box to “Less” or “Less Equal”.
          In right box select User Input MACDslow. Click OK and Compile.

          Frankly I don’t think you will get much in the way of results w/ this strategy. It would be better to use a different Indicator for the first statement (a simple EMA cross for example) and have it confirmed by the second MACD statement.


            It happens because MACD is based on two moving average indicators applied directly on the chart (they are not displayed in the MACD chart, only their readings are used).

            MACD itself is displayed in a separate window under the chart. It looks like a histogram with an auxiliary line. The histogram shows that divergence of two moving averages tutuapp software.
            Last edited by Andrew425; 01-18-2019, 11:00 PM.


            Latest Posts


            Topics Statistics Last Post
            Started by chrismcdermut, Yesterday, 01:46 PM
            3 responses
            Last Post MojoJojo  
            Started by Bricolico, Yesterday, 09:28 PM
            0 responses
            Last Post Bricolico  
            Started by Tradwell385, Yesterday, 08:51 PM
            0 responses
            Last Post Tradwell385  
            Started by dvcpro4, Yesterday, 07:08 PM
            0 responses
            Last Post dvcpro4
            by dvcpro4
            Started by pennywise, Yesterday, 06:40 PM
            0 responses
            Last Post pennywise