Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Time Frame Issue with 60 min MACD

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

    Multiple Time Frame Issue with 60 min MACD

    Hi,

    I created an indicator that uses multiple time frame data. The indicator is applied to a 5 min chart and the higher time frame is 60 minutes.

    In the Initialize() section I have: Add(PeriodType.Minute,60);

    Also, CalculateOnBarClose=true.

    I need my code to return...

    "Green" when the 60 min MACD bar values increase (based on 2 consecutive bars).
    "Red" when the 60 min MACD bar values decrease.

    My understanding is that I should use something like this:

    Bar_0=MACD(BarsArray[1],12,26,30).Diff[0];
    Bar_1=MACD(BarsArray[1],12,26,30).Diff[1];


    if (Bar_0 > Bar_1) etc...

    But I noticed something wrong and I decided to Print (Bar_0) to do some troubleshooting. The printed values are way off and do not correspond to the values observed on the 60 min MACD indicator section.

    Looks like I am doing something wrong. What is the proper function to use?

    Thanks.

    - mp

    #2
    Turns out I had to close & restart NT7. I don't like that...

    Comment


      #3
      Hello marcusplexus,

      Thank you for your post.

      You should not need to have to shutdown and restart NinjaTrader for changes to take effect. In worst case scenario, removing the indicator from the chart and re-adding it might be required for some changes to plots.

      Right clicking in the chart -> Reload NinjaScript or pressing F5 should be sufficient.

      Also, you can make your code more straightforward with Rising() and Falling(), they look 1 bar back for you:
      Code:
      if ( Rising(MACD(BarsArray[1],12,26,30).Diff ) 
          // green color stuff
      else if (Falling(MACD(BarsArray[1],12,26,30).Diff ) 
          // red color stuff
      else 
          // sideways market color stuff
      Please let me know if I can assist any further.
      DexterNinjaTrader Customer Service

      Comment


        #4
        I will try your solution. Thank you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X