Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD crossover alert

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

    MACD crossover alert

    Hello,
    Has anyone programmed an alert for the MACD crossover? It is not availble through the market analyzer so it needs to be programmed. I haven't done any programming so looking for a little help.
    Thanks!

    #2
    Hello,

    If you are not familiar with programming, you might want to try using the Strategy Wizard to create a Cross Over strategy. This is a point and client interface that can help you get started.

    Instead of buying/selling when these crossover, you can simply tell the strategy to 'Alert'.

    Please see the Strategy Wizard Help Guide section on ' How to create a cross over condition':

    MatthewNinjaTrader Product Management

    Comment


      #3
      X2

      Michael

      Comment


        #4
        MACD crossover alert

        I used the wizard to program the strategy for MACD, which initially worked for a couple of days, but then spont quit for the ensuing 2 mos. The support people simply say to simplify the commands into component pieces, then debug.
        How much simpler can it be to say IF [condition] K crosses D, or vice versa, THEN [action] play selected alert. I followed Matthew's suggestion from below using the wizard, but still no joy.
        O/w they say to hire one of their consultants. Contacted 4 of those consultants, but only one responded from UK, who offered to take over my computer to see what is wrong, @ about $60-70/hr.
        I am quite surprised this has not been perfected by NT or someone and generally available.
        Last edited by snakeoil; 10-18-2012, 04:12 PM. Reason: add

        Comment


          #5
          Originally posted by snakeoil View Post
          I used the wizard to program the strategy for MACD, which initially worked for a couple of days, but then spont quit for the ensuing 2 mos. The support people simply say to simplify the commands into component pieces, then debug.
          How much simpler can it be to say IF [condition] K crosses D, or vice versa, THEN [action] play selected alert. I followed Matthew's suggestion from below using the wizard, but still no joy.
          O/w they say to hire one of their consultants. Contacted 4 of those consultants, but only one responded from UK, who offered to take over my computer to see what is wrong, @ about $60-70/hr.
          I am quite surprised this has not been perfected by NT or someone and generally available.

          Can you post your code? I and more than a few others could probably pin point the problem pretty easily.

          Comment


            #6
            I appreciate your offer of assistance, sledge
            Having used the wizard, I don't have the code expressed. I do have the screenshot of the formative page, but don't see how to attach it into this thread. Also, I suppose I could unlock the code and copy/paste that whole thing into the thread, if that is allowed.
            If I had an email address I could send the series of screen shots used in the wizard setup. My address is: [email protected]
            What might you suggest?

            Comment


              #7
              Originally posted by snakeoil View Post
              I appreciate your offer of assistance, sledge
              Having used the wizard, I don't have the code expressed. I do have the screenshot of the formative page, but don't see how to attach it into this thread. Also, I suppose I could unlock the code and copy/paste that whole thing into the thread, if that is allowed.
              If I had an email address I could send the series of screen shots used in the wizard setup. My address is: [email protected]
              What might you suggest?
              On WinXP it would be located:

              C:\Documents and Settings\YOURUSERNAME\My Documents\NinjaTrader 7\bin\Custom\Strategy

              and attach the .CS file.

              I assume it will be there, even it is unlocked.

              Comment


                #8
                Found it: macd.cs. Will paste here:
                #region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class macd : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert2.wav"); PrintWithTimeStamp(""); } // Condition set 2 if (CrossBelow(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav"); PrintWithTimeStamp(""); } }

                Comment


                  #9
                  Originally posted by snakeoil View Post
                  Found it: macd.cs. Will paste here:
                  #region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class macd : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert2.wav"); PrintWithTimeStamp(""); } // Condition set 2 if (CrossBelow(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav"); PrintWithTimeStamp(""); } }
                  Umm, can you reply and use "manage attachments" and upload it there?

                  the carriage returns got lost in your post

                  Comment


                    #10
                    Being brand new to this, not seeing "manage attachments" anywhere

                    Comment


                      #11
                      Originally posted by snakeoil View Post
                      Being brand new to this, not seeing "manage attachments" anywhere
                      Use "QUOTE" to reply

                      OR

                      if you use "REPLY", then choose "GO ADVANCED".
                      Attached Files

                      Comment


                        #12
                        Originally posted by sledge View Post
                        Use "QUOTE" to reply

                        OR

                        if you use "REPLY", then choose "GO ADVANCED".
                        #region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class macd : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert2.wav"); PrintWithTimeStamp(""); } // Condition set 2 if (CrossBelow(MACD(8, 13, 5), MACD(8, 13, 5), 1)) { PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav"); PrintWithTimeStamp(""); } }

                        Comment


                          #13
                          Is there an accuracy problem when using the plot &quot;Diff&quot; for Macd Crossover

                          I'm sure you guys all well pass this but I was just wondering.
                          I just started trying to use the plat "Diff" in the MACD in the Market Analyzer.
                          but I alread see some number accuracy problems that Support has not been able to help me rectify.
                          Now I'm wondering about the accuracy of all indicators, # of look back bars, etc.
                          I'll be checkin' back and try to catch up with your advance methods of MACD crossover using script and strategy builder.

                          Gino

                          Comment


                            #14
                            snakeoil,

                            I see you have used PrintWithTimeStamp, however there is no text being written.

                            You should edit your strategy to print a message when the condition is true. After you have done this, open the output window under Tools--> Output window and when you enable your strategy, check this window to see if it has found any conditions on historical data.

                            If the output window remains empty, this would mean your condition is never true. If you do see these messages printed, the condition should be valid.
                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              Originally posted by Gino Magic View Post
                              I'm sure you guys all well pass this but I was just wondering.
                              I just started trying to use the plat "Diff" in the MACD in the Market Analyzer.
                              but I alread see some number accuracy problems that Support has not been able to help me rectify.
                              Now I'm wondering about the accuracy of all indicators, # of look back bars, etc.
                              I'll be checkin' back and try to catch up with your advance methods of MACD crossover using script and strategy builder.

                              Gino
                              You need to ensure that your chart and the market analyzer are looking at the same exact data set to calculate these values. This would be the # of bars to look back, the session template as well as the input series. Since you're using the same formulas, you should be able to get these values to match as long as the data set is the same.
                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by kujista, Today, 06:23 AM
                              4 responses
                              12 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by traderqz, Yesterday, 09:06 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post traderqz  
                              Started by traderqz, Today, 12:06 AM
                              3 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by RideMe, 04-07-2024, 04:54 PM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by f.saeidi, Today, 08:13 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X