Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD Crossover

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

    MACD Crossover

    I'm still getting used to this language...
    Simple question
    How do you detect a MACD crossover ? I saw the example for the simple MA crossover. But not sure what the properties are for the macd line and the signal line.

    #2
    Most if not all system indicators are well documented which can help you determine available plot values.

    MACD - http://www.ninjatrader-support.com/H...deV6/MACD.html

    To detect a cross condition you can use either:

    CrossAbove() - http://www.ninjatrader-support.com/H...rossAbove.html
    CrossBelow() - http://www.ninjatrader-support.com/H...rossBelow.html

    You can then do something like:

    if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))
    // Do something here
    RayNinjaTrader Customer Service

    Comment


      #3
      macd crossover alert for market analyzer

      hello

      is there a way to setup an alert when an macd crossover happend?

      would be nice if this could be setup in the market analyzer as currently i can only check if macd is above or below 0 but not the actuall crossover event.

      Comment


        #4
        You would need to code your own custom indicator which e.g. goes > 0 as the crossover happens and throw that on the market analyzer.

        Comment


          #5
          Originally posted by NinjaTrader_Dierk View Post
          You would need to code your own custom indicator which e.g. goes > 0 as the crossover happens and throw that on the market analyzer.

          so i would have to make a copy of the @MACD indicator and this lines?:

          protected override void OnBarUpdate()
          {
          double MACDValue=@MACD(Input,Avg,?,period).MACD.Get(Curre ntBar);
          }

          but how to define MACDValue (above and below 0)?

          would it not be more efficient if the market analyzer/(alert system)would have the possibility to cross overs instead of just above and below, this way all indicators could be used in there original state and we would have a powerful market analyzer...

          Comment


            #6
            The "@" is unwanted, and make sure you get the parameters correct...

            double MACDValue = MACD(Input,Fast,Slow,Smooth)[0];

            You can find the default values of Fast, Slow, Smooth by editing the MACD indicator to look at the sources.

            Also, the [0] is equivalent to ".Get(CurrentBar)". Note [1] would be ".Get(CurrentBar-1)", etc.

            Comment


              #7
              HMA CrossAbove

              How about the HMA CrossAbove?Any idea?

              Comment


                #8
                luxurious_04,

                To do a HMA CrossAbove you would simply use the CrossAbove() method again.

                Code:
                if (CrossAbove(HMA(10), Close, 1))
                     EnterLong();
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks

                  Thanks for the big help NinjaTrader_Josh

                  But there is error in in this code:

                  iif (CurrentBar==0)
                  return;
                  if ((CrossAbove(MACD(12,26,9),MACD(12,26,9)))&& (CrossAbove(HMA(11)[0],HMA(5)[0])))
                  {
                  Alert("MyAlert",NinjaTrader.Cbi.Priority.High,"Buy Signal","myalert1",0,Color.Black,Color.Red);
                  }
                  else
                  Alert("MyAlert",NinjaTrader.Cbi.Priority.High,"Sel l Signal","myalert2",0,Color.Black,Color.Red);

                  Error:

                  Indicator\MACDCrossIsHMACross.cs No overload for method 'CrossAbove' takes '2' arguments CS1501 - click for info 52 9

                  Indicator\MACDCrossIsHMACross.cs No overload for method 'CrossAbove' takes '2' arguments CS1501 - click for info 52 53

                  Someone help please.
                  Last edited by luxurious_04; 08-01-2010, 11:47 PM.

                  Comment


                    #10
                    CrossAbove() method takes 3 parameters. In your code you only have 2 parameters. What you are missing is that last parameter with the # 1. That is the lookback period since it takes two bars to determine a cross over.

                    if (CrossAbove(someValue, anotherValue, lookBackPeriod))

                    Also, your first MACD comparison, you are comparing MACD versus the same exact MACD again. This would never yield a cross over because they are always the same values.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks

                      Thanks for the big help

                      Is if possible to determine weather the crossAbove/Below of zeroLagMacd?
                      And also the crossAbove/Below of HMA?
                      Can you give me tips..
                      Thanks
                      Last edited by luxurious_04; 08-02-2010, 06:16 PM.

                      Comment


                        #12
                        Multiple plots

                        Anyone who give me tips in this condition:

                        if (CrossAbove(MACD(12,26,9),ZeroLagMACD(12,26,9).Avg ,1)== CrossAbove(HMA(11),HMA(5),1))
                        {
                        PlaySound(@"C:\Buy_sound.wav");

                        // Connects the rising plot segment with the other plots
                        Above.Set(1,Blank[1]);

                        // Adds the new rising plot line segment to the line
                        Above.Set(Blank(1)[0]);
                        Below.Reset();
                        Neutral.Reset();
                        }
                        this Blank in the code what should be the value for that?

                        Comment


                          #13
                          You would put the value you would want to set for this plot then into this field - http://www.ninjatrader.com/support/f...ead.php?t=3227

                          Comment


                            #14
                            How about this?

                            In the sample multi-colored plots it is only concern about the Rising,Falling,Flat of SMA.
                            How about this:

                            CrossAbove(MACD(Fast,Slow,Smooth),ZeroLagMACD(Fast ,Slow,Smooth) ,1)== CrossAbove(HMA(Period1),HMA(Period2),1)

                            What will be the basis for the plot?
                            It consist of 4 indicators? In the example it is only 1 indicator which is SMA?

                            Comment


                              #15
                              luxurious_04,

                              Unfortunately I am not exactly sure what you are asking. Comparing two CrossAbove() methods against each other just checks that the two crosses are happening at the same time, or not at all. The == comparison means that the MACD needs to cross ZeroLagMACD at the exact same time the HMA crosses a different period HMA. The comparison would also be true when there are no crosses from both conditions at the same time.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              571 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              330 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
                              549 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              549 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X