Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated strategy - bars ago if MACD was greater than or less than the AVG?

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

    Automated strategy - bars ago if MACD was greater than or less than the AVG?

    Is there a way to see if 2 or 3 bars ago in strategy builder the blue line was under the red line on the MACD indicator?
    I'm just curious in the context of the strategy builder -- I am not a programmer.

    #2
    Hello MatthewLesko,

    In the condition builder select MACD on the left. Set Bars ago to 2 (or 3 depending which actually want) for the Plot select the MACD plot. In the center select Less than. On the right select the MACD, set Bars ago to 2 (or 3), for the Plot select the Avg plot.

    If you have not already, be sure to watch the Strategy Builder 301 training video which demonstrates selecting a plot from the MACD indicator.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello MatthewLesko,

      In the condition builder select MACD on the left. Set Bars ago to 2 (or 3 depending which actually want) for the Plot select the MACD plot. In the center select Less than. On the right select the MACD, set Bars ago to 2 (or 3), for the Plot select the Avg plot.

      If you have not already, be sure to watch the Strategy Builder 301 training video which demonstrates selecting a plot from the MACD indicator.
      https://ninjatrader.com/support/foru...040#post786040
      Thanks so if I have 3 bars, and I'm at the start of a 4th bar, is the 4th bar where the "bars ago" is starting from?
      So if I have "1 bars ago" on the left side, it's referring to the state of MACD for bar #3?
      And if I have "1 bars ago" on the right side, it's referring to the state of MACD for bar #2?

      Comment


        #4
        Hello MatthewLesko,

        Where you mention: "and I'm at the start of a 4th bar", does this mean this is real-time data with Calculate set to OnEachTick or historical with TickReplay?
        https://ninjatrader.com/support/foru...377#post773377

        Below is a link to the help guide on how bars are referenced.
        https://ninjatrader.com/support/help...taIsReferenced

        When Calculate is OnEachTick, the most recently updated bar (Bars Ago 0) is the currently building bar. When Calculate is OnBarClose, the most recently updated bar is the most recent fully closed bar.

        So.. if you are at the start of the 4th bar, this would imply Calculate.OnEachTick, IsFirstTickOfBar is true, and BarsAgo 0 refers to the first tick of the new bar. BarsAgo 1 is the previous fully closed bar.

        Or are you using Calculate OnBarClose, and you are referring what happens to an order after it is submitted when a bar has fully closed (and fills at the open of the next bar)?


        Where you have mentioned:
        So if I have "1 bars ago" on the left side, it's referring to the state of MACD for bar #3?
        Using Bars ago gives you a value from a series as many bars ago from the current bar as you would like. It would not be State (as script state like State.SetDefaults, or State.DataLoaded, or State.Historical) of that indicator, but would instead give you the plot value for that bar.

        Using Bars Ago 1 with the MACD indicator when Calculate is OnEachTick would return the plot value for the selected plot (MACD plot by default) of the most recently fully closed bar. So the most recent MACD value of the most recent fully closed bar.

        Where you have mentioned:
        And if I have "1 bars ago" on the right side, it's referring to the state of MACD for bar #2?
        Using Bars Ago 1 on the right side would still be the same. The plot value for the bars ago does not change because it is on the right hand side of the condition builder. This would still return the plot value for the selected plot (MACD plot by default) of the most recently fully closed bar. So the most recent MACD value of the most recent fully closed bar.


        Your original inquiry was:
        Is there a way to see if 2 or 3 bars ago in strategy builder the blue line was under the red line on the MACD indicator?
        The MACD has 3 plots. By default the MACD plot is DarkCyan. The Avg plot is Crimson. The Diff plot is DodgerBlue. So when you say blue plot I image you are asking about the Diff plot being less than the red plot which is the Avg.

        Yes, compare the value of the plot from 2 (or 3) bars ago of the Diff plot on the left, select less than in the center, and the value of the plot from 2 (or 3) bars ago of the with the Avg plot line on the right.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello, i have a quick question regarding the MACD as well. I am trying to build a strategy using the zombie 21 MACD and i am trying to put a numerical value for the second bar is there a way to do that.
          as you can see in the picture, for example for the first green bar in the MACD i know how to out a numerical number for it but i am trying to put a numerical number for the second, how can i do that. I need help please. Thank you.
          Attached Files

          Comment


            #6
            Hello Mahmad1323,

            Thank you for your post.

            Can you explain what you mean by "put a numerical value for the second bar"? Are you trying to access that value, or assign a value?

            Comment


              #7
              Hello gaby, i am trying to assign a value to it

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              67 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              41 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              24 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              27 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              53 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X