Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

noob trying to make first MA & MACD strat

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

    noob trying to make first MA & MACD strat

    I am simply trying to setup an EMA cross entry (no prob there-video library)

    and a MACD osc value 0 exit.


    i am using the wizard and am willing to read and learn but I am so excited by this program I just want my first strat to "work" so i can fiddle with it from there and learn as I tinker

    thanks

    #2
    Welcome to the NinjaTrader Support Forums.

    In the Condition Builder, select MACD on the left from indicators. In the parameters, choose the correct Plot you want to use. On the right, select Misc > Numeric value and type in 0.

    Hope that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      right i had that setup like that .... i think perhaps i have added or changed some stuff along the way which is causing the problem - is there a way to see an example of what im trying to do (or similar) which i can emulate?

      Comment


        #4
        Sorry we do not have samples created for this. Please show us what you have so far and we can tell you what could be causing issues. Thank you.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Yeah im not much of a scriptor but here is a paste of the script


          #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 MyCustomStrategy1 : Strategy
          {
          #region Variables
          // Wizard generated variables
          private int fast = 21; // Default setting for Fast
          private int slow = 52; // Default setting for Slow
          // 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()
          {
          Add(EMA(21));
          Add(EMA(52));
          Add(MACD(12, 26, 9));

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (CrossAbove(EMA(21), EMA(52), 1))
          {
          EnterLong(DefaultQuantity, "");
          }

          // Condition set 2
          if (CrossBelow(EMA(21), EMA(52), 1))
          {
          EnterShort(DefaultQuantity, "");
          }

          // Condition set 3
          if (MACD(12, 26, 9).Diff[0] == 0)
          {
          ExitLong("", "");
          ExitShort("", "");
          }
          }

          #region Properties
          [Description("Fast MA Period")]
          [Category("Parameters")]
          public int Fast
          {
          get { return fast; }
          set { fast = Math.Max(20, value); }
          }

          [Description("Slow MA Period")]
          [Category("Parameters")]
          public int Slow
          {
          get { return slow; }
          set { slow = Math.Max(20, value); }
          }
          #endregion

          Comment


            #6
            You are likely using the wrong MACD plot. You are using the Difference plot instead of the actual MACD plot. Also your condition requires the plot to be exactly 0. This likely does not happen often. It usually crosses zero but never lands at exactly 0.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              0 - my aim is when the MACD histo or diff is zero i want it to flatten if i understand you and what i am seeing in the advanced charting window the app is accurate to 7 (or more) places right of the decimal, so i need to look for a condition like <0 to close a long and >0 to close a short - right?

              Comment


                #8
                You would want to open up a range of acceptable values since the value actually being exactly 0 is slim. What you decide the ultimate logic to be is up to you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Absolutly! ok i got it to close out the trades now i have to figure out how to get it to use 20 min bars instead of 1 min bars...

                  Comment


                    #10
                    Open a 20min chart and add the strategy onto that chart. That will run it on 20 mins. If you open a 1 min chart, it runs on 1min, etc.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by GLFX005, Today, 03:23 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post GLFX005
                    by GLFX005
                     
                    Started by XXtrader, Yesterday, 11:30 PM
                    2 responses
                    11 views
                    0 likes
                    Last Post XXtrader  
                    Started by Waxavi, Today, 02:10 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by TradeForge, Today, 02:09 AM
                    0 responses
                    14 views
                    0 likes
                    Last Post TradeForge  
                    Started by Waxavi, Today, 02:00 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Working...
                    X