Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Want to apply Swings to a MACD

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

    Want to apply Swings to a MACD

    I want to try to modify the Swing indicator to have it display swings on a MACD indicator.

    Before I attempt this, I want to know:

    1. Is it possible?
    2. Is it relatively simple?

    If its possible, are there any nuances that I should be aware of?

    Thanks for any help anyone can provide.

    Regards,
    taddypole...

    #2
    Hi Taddypole,

    Yes, it is possible. Unfortunately we can't comment on the simplicity. The swing source code is fairly complex so it will depend on your ability to reverse engineer existing source code and resolve any problems that may come up.

    You can see swing source code through Tools > Edit NinjaScript > Indicator > Swing.

    Save a copy through Right Click > Save As > provide a new name.

    You can see where High[0] and Low[0] are used for existing swing points, and these places would need your MACD value.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I added the code for the MACD to the Swing indicator but have a compile error. Using the Macd indicator produces a macd variable of Double. The Swing indicator uses normally a price dataseries (High[0], Low[0]).

      In the lines below, is where i've added the macd Double to the last high and low cache. With that code is where i get the compile error.

      lastHighCache.Add(macd);

      lastLowCache.Add(macd);

      Is there a way to use this double value or do i need to convert the Macd to a dataseries?

      I've attached the SwingMacd test code with the offending lines commented out.

      thanks,
      taddypole...
      Attached Files

      Comment


        #4
        Sorry, I'm not familiar with the exact code changes you would need to make this. I tried a double in this line and did not encounter compile errors:

        lastHighCache.Add(44.5);

        It is possible to chart this without custom programming. Just select MACD as input series for Swing indicator. Attached screenshot showing the result.
        Attached Files
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I think that is what I want Ryan.

          Can you show me how you select Macd as the input to the Swing indicator?

          Comment


            #6
            taddypole,

            Instead of:
            lastHighCache.Add(macd);
            lastLowCache.Add(macd);

            Try:
            lastHighCache.Add(MACD(12, 26, 9)[0]);
            lastLowCache.Add(MACD(12, 26, 9)[0));

            VT

            Comment


              #7
              Here is the configuration for this. Apply MACD first, then Swing. For Swing input series, set to MACD. For panel, assign the number that the MACD is in.
              Attached Files
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Thank you very much Ryan,

                That should get me going on this project...

                have a great weekend...

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                607 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                353 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                560 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                561 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X