• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting arrows when Fast MACD moving average turns up or down

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

    Plotting arrows when Fast MACD moving average turns up or down

    Hi, I'm trying to create an indicator that plots up or down arrows simply when the fast macd moving average turns up or down. I have a macd that changes from red to green when it turns up and green to red when it turns down, but I would also like an arrow to plot on the chart when this happens. I've tried using the rising/falling under misc to create this but it is not working correctly at all. Any help would be greatly appreciated.

    Thanks,
    Ian

    #2
    Hello Ian,

    You have Rising selected?

    Do you have the input series set to the MACD indicator with the MACD plot selected?

    In the actions have you added an action to draw an up arrow?

    Is this being drawn at the close price?

    A screenshot of what you have would be helpful in this situation where you are asking about a condition you have setup.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I have pasted what I have in the script so far... it could be way off. "Mom" is the name I have for the fast macd average, and "top dog momentum" is the macd indicator, in case that's confusing.


      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion

      //This namespace holds Indicators in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class momarrows : Indicator
      {
      private int Red;
      private int Green;

      private NinjaTrader.NinjaScript.Indicators.TopDogTrading.T opDogMomentum TopDogMomentum1;

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "momarrows";
      Calculate = Calculate.OnPriceChange;
      IsOverlay = true;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      }
      else if (State == State.DataLoaded)
      {
      TopDogMomentum1 = TopDogMomentum(Close, 20, 5, 30, 10);
      }
      }

      protected override void OnBarUpdate()
      {
      if (BarsInProgress != 0)
      return;

      if (CurrentBars[0] < 1)
      return;

      // Set 1
      if ((TopDogMomentum1.Mom[0] == Green)
      && (IsRising(TopDogMomentum1.Mom) == IsRising(TopDogMomentum1.Mom)))
      {
      Draw.ArrowUp(this, @"momentumarrows1 Arrow up_1", false, 0, (Low[0] + (-4 * TickSize)) , Brushes.Lime);
      }

      // Set 2
      if ((TopDogMomentum1.Mom[0] == Red)
      && (IsFalling(TopDogMomentum1.Mom) == IsFalling(TopDogMomentum1.Mom)))
      {
      Draw.ArrowDown(this, @"momentumarrows1 Arrow down_1", false, 0, (High[0] + (4 * TickSize)) , Brushes.Red);
      }
      }
      }
      }

      Comment


        #4
        Just to give you an idea of what I'm looking for, I would like arrows to be plotted on the chart when the indicator turns up or down / red or green. Where the yellow arrows that I have drawn in are where the indicator turns up/down and red/green. I have provided a picture of my screen to give you an idea of what I'm talking about.
        Attached Files

        Comment


          #5
          Hello Ian,

          I think you are wanting to have IsRising() be equal to true (or false) and not equal to itself, as its always equal to itself.

          The Green and Red integer variables need to be set to something or will default to 0.
          Also the value of the indicator needs to match whatever Green and Red are being set to.

          Print these values to see why they are or are not matching
          Print(string.Format("{0} | TopDogMomentum1.Mom[0]: {1} == Green: {2}", Time[0], TopDogMomentum1.Mom[0], Green));
          https://ninjatrader.com/support/foru...121#post791121

          Use unique tag names to draw multiple objects.
          https://ninjatrader.com/support/foru...630#post838630

          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks,

            I set it to "IsRising" but it just posts a ton of arrows on the screen instead of just one arrow when it goes from falling to rising. It seems to plot an arrow on every candlestick where the macd "is rising." Since the macd indicator that i'm using is someone's proprietary indicator, I'm not sure what to set the red and the green to... do you suggest I try to create an indicator that mimics the proprietary macd and then try to work off of that to only show one arrow when it turns from red to green? I'm not sure what to do here lol.

            Comment


              #7
              Hello Ian,

              The Green and Red integers are variables that are part of your script and are not part of the TopDogMomentum1 indicator.

              You are comparing these to the indicator's Mom value TopDogMomentum1.Mom[0].

              Do you want this code? You can choose to remove it..


              Yes, IsRising() will be true on every bar that the series is rising.

              If you would like the previous bars value to be falling you would need to track this and code this in your condition.

              Create a bool variable and set this to the value of IsFalling() at the bottom of OnBarUpdate() below the condition.

              In the condition require the bool variable to be false. This would check that the series was falling on the previous bar and on the current bar is rising.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                I have deleted the green and red integers. I am also trying to create a bool variable in the strategy builder, but I'm not sure how to do this... are there any resources for creating that condition in strategy builder?

                Thanks again, you've been a lot of help so far.

                Comment


                  #9
                  Or, even better, would you be able to provide screen shots of how to create this Boolean variable? Thanks

                  Comment


                    #10
                    Hello Tradwell385,

                    If you have not already, be sure to watch the Strategy Builder 301 training video.
                    https://youtu.be/HCyt90GAs9k

                    Also, below is a link to a forum post with helpful information about getting started with NinjaScript.
                    https://ninjatrader.com/support/foru...040#post786040

                    Attached is an export of a strategy created with the strategy builder that demonstrates this concept.
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chelsea, thanks for the reply. The example looks like it is based on a MACD cross. Instead of the macd crossing each other, I would like the arrows to come on the screen only when the fast macd turns up or down, no crossing involved. Is that a possibility? I'm really confused on what variables to use in this instance.

                      Comment


                        #12
                        Hello Tradwell385,

                        I don't have your indicator, and this example is demonstrating an idea and is not meant for you to actually trade.

                        When you mention:
                        "Instead of the macd crossing each other, I would like the arrows to come on the screen only when the fast macd turns up or down, no crossing involved. Is that a possibility? "
                        Yes, this is a possibly and what I am demonstrating in this example I have provided you. Drawing an object when a series is rising on the current bar and falling on the previous bar.

                        The bool MyBool is what is used to track if a series is rising or falling on a previous bar.

                        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bertochi, Today, 07:25 AM
                        1 response
                        2 views
                        0 likes
                        Last Post bertochi  
                        Started by Kentoes, Today, 07:06 AM
                        0 responses
                        0 views
                        0 likes
                        Last Post Kentoes
                        by Kentoes
                         
                        Started by third monkey, Today, 06:33 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post third monkey  
                        Started by xfbrq, Today, 05:41 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post xfbrq
                        by xfbrq
                         
                        Started by alcmvd, Today, 03:02 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post alcmvd
                        by alcmvd
                         
                        Working...
                        X