Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        6 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        216 views
        1 like
        Last Post PaulMohn  
        Working...
        X