Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleMACrossOver not working

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

    SampleMACrossOver not working

    Hi,

    The SampleMACrossOver Strategy is not working
    on my NT7.18 Beta as you can see in the attachment.
    The code is below.
    What can I do?

    Code:
    #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.Strategy;
    #endregion
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// Simple moving average cross over strategy.
        /// </summary>
        [Description("Simple moving average cross over strategy.")]
        public class SampleMACrossOver : Strategy
        {
            #region Variables
            private int        fast    = 10;
            private int        slow    = 25;
            #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()
            {
                SMA(Fast).Plots[0].Pen.Color = Color.Orange;
                SMA(Slow).Plots[0].Pen.Color = Color.Green;
    
                Add(SMA(Fast));
                Add(SMA(Slow));
    
                CalculateOnBarClose    = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick).
            /// </summary>
            protected override void OnBarUpdate()
            {
                if (CrossAbove(SMA(Fast), SMA(Slow), 1))
                    EnterLong();
                else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
                    EnterShort();
            }
    
            #region Properties
            /// <summary>
            /// </summary>
            [Description("Period for fast MA")]
            [GridCategory("Parameters")]
            public int Fast
            {
                get { return fast; }
                set { fast = Math.Max(1, value); }
            }
    
            /// <summary>
            /// </summary>
            [Description("Period for slow MA")]
            [GridCategory("Parameters")]
            public int Slow
            {
                get { return slow; }
                set { slow = Math.Max(1, value); }
            }
            #endregion
        }
    }
    Attached Files

    #2
    Hello cbaer,

    You will need to set 'Enabled' to True for the strategy to start working. The screenshot displays this is not the case on your end, since it reflects a (D). You can set 'Enabled' in the strategy parameters window that appears when you inititate a strategy.

    Let me know if this will not work for you.
    JasonNinjaTrader Customer Service

    Comment


      #3
      Hello Jason,

      This problem is resolved. Thanks!

      cbaer

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by OllieFeraher, 05-09-2024, 11:14 AM
      6 responses
      18 views
      0 likes
      Last Post OllieFeraher  
      Started by PaulMohn, 05-02-2024, 06:59 PM
      2 responses
      41 views
      0 likes
      Last Post PaulMohn  
      Started by ETFVoyageur, Today, 02:10 AM
      0 responses
      9 views
      0 likes
      Last Post ETFVoyageur  
      Started by rayyyu12, Today, 12:47 AM
      0 responses
      8 views
      0 likes
      Last Post rayyyu12  
      Started by ETFVoyageur, 05-07-2024, 07:05 PM
      17 responses
      137 views
      0 likes
      Last Post ETFVoyageur  
      Working...
      X