Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD crossover alert

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

    #16
    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(""); } }
    Your code reads: if (MACD(8, 13, 5) crosses over MACD(8, 13, 5) within the last 1 bar) do Something. As far as I can see, that condition can never be true, as nothing can cross over itself. You must specify which DataSeries/Plot, you want to be crossing which other Plot in this case.

    I am going to assume that you want the MACD line itself crossing over the average, in which case, your line will read:

    Code:
    if (CrossAbove(MACD(8, 13, 5), MACD(8, 13, 5).Avg, 1)) ...
    Yes, you can code this in the wizard. Just look in the bottom half of the window, and specify which Plot (bottom left pane ) is to cross which (bottom right pane).
    Attached Files
    Last edited by koganam; 10-19-2012, 09:51 AM.

    Comment


      #17
      Originally posted by NinjaTrader_Matthew View Post
      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.
      Yes, I have been using the output window, which is not printing, except enable/disable.

      Comment


        #18
        Originally posted by koganam View Post
        Your code reads: if (MACD(8, 13, 5) crosses over MACD(8, 13, 5) within the last 1 bar) do Something. As far as I can see, that condition can never be true, as nothing can cross over itself. You must specify which DataSeries/Plot, you want to be crossing which other Plot in this case.

        I am going to assume that you want the MACD line itself crossing over the average, in which case, your line will read:

        Code:
        if (CrossAbove(MACD(8, 13, 5), MACD(8, 13, 5).Avg, 1)) ...
        Yes, you can code this in the wizard. Just look in the bottom half of the window, and specify which Plot (bottom left pane ) is to cross which (bottom right pane).
        TY, koganam. That seems to be the clue. I realize that part of my difficulty is learning what each term means and then does. The MACD strat has now fired both audible and confirmed in the output window. Many Thanks!

        Comment


          #19
          Matthew is there a post that details how to set days to look back i.e. in which drop down windows?
          Thanks

          Comment


            #20
            For which setting are you looking to set the days back? Is this an indicator? Or are you looking for this setting in the market analyzer?
            MatthewNinjaTrader Product Management

            Comment


              #21
              Originally posted by NinjaTrader_Matthew View Post
              For which setting are you looking to set the days back? Is this an indicator? Or are you looking for this setting in the market analyzer?
              Matthew, I am currently testing it on the 1min chart, using a 1 day look back, or 20 bars min, and considering what MACD settings to use.
              My original problem of getting the audio alert strategy to fire along w/ output box confirmation seems to be resolved, thanks to sledge and konganam comments.
              I now need to better understand what the plot comparisons are, but am using MACD vs Avg.
              As used in the plot, the definitions are not clear to me, as the sound does not exactly correlate to the graph lines crossing, along w/ multiple sounds firing at congestion points. But at least it is doing the desired job of alerting my attention to early changes in chart direction. In summary I like it!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by SantoshXX, Today, 03:09 AM
              0 responses
              6 views
              0 likes
              Last Post SantoshXX  
              Started by DanielTynera, Today, 01:14 AM
              0 responses
              2 views
              0 likes
              Last Post DanielTynera  
              Started by yertle, 04-18-2024, 08:38 AM
              9 responses
              41 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by techgetgame, Yesterday, 11:42 PM
              0 responses
              12 views
              0 likes
              Last Post techgetgame  
              Started by sephichapdson, Yesterday, 11:36 PM
              0 responses
              2 views
              0 likes
              Last Post sephichapdson  
              Working...
              X