Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto order Entry with certain conditions

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

    #16
    Hello Eric,

    Yes, that makes sense. The answer is still the same in that you have to look at the EntriesPerDirection and EntryHandling properties.

    You can create separate rules for the different price levels you want to enter at. If EntryHandling is set to Unique entries and EntriesPerDirection is set to 1, it will accept 1 unique entry for each rule.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Still working at this...

      here is what i have programmed...

      #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>
      /// Automatically enters orders based on price Movement.
      /// </summary>
      [Description("Automatically enters orders based on price Movement.")]
      public class ESoverniteStratAutoOrder22 : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int contractSize = 1; // Default setting for ContractSize
      private double startPrice = 1100.000; // Default setting for StartPrice
      // 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;

      EntriesPerDirection = 1;
      EntryHandling = EntryHandling.UniqueEntries;

      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (Close[0] == StartPrice + TickSize * 3)
      {
      EnterShort(ContractSize, "");
      }

      // Condition set 2
      if (Close[0] == StartPrice + TickSize * -3)
      {
      EnterLong(ContractSize, "");
      }

      // Condition set 3
      if (Close[0] == StartPrice + TickSize * 6)
      {
      EnterShort(ContractSize, "");
      }

      // Condition set 4
      if (Close[0] == StartPrice + TickSize * -6)
      {
      EnterLong(ContractSize, "");
      }


      }

      #region Properties
      [Description("# of contracts")]
      [Category("Parameters")]
      public int ContractSize
      {
      get { return contractSize; }
      set { contractSize = Math.Max(1, value); }
      }

      [Description("Starting price")]
      [Category("Parameters")]
      public double StartPrice
      {
      get { return startPrice; }
      set { startPrice = Math.Max(1, value); }
      }
      #endregion
      }
      }

      when i run this and the price goes down, i will get filled long and then when the price goes up i will get filled short two contracts at the same price. it should only be one short to close the position, not a short to cover and then another short. then after this no matter how high or low the price goes the orders that should be entered at 6 tics from the start price are not entered for some reason.

      so i am not sure why it is doing this. can you get this to replicate on your end?

      thanks for your help on this. will keep working at it...

      EG

      Comment


        #18
        Hello Eric,

        We were working with Entry Handling and Entries Per Direction. All your signals have the same name- an empty string.

        You'll have to set a unique name for each entry rule.
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          Thanks. helped a little. now the orders are being entered and filled. But, they get entered twice in the same direction many times at the exact same time. when i look at the execution tab (see attached pic) it has the name close position and then the same order of -3. why does it do that? i am not trying to close the position and the enter the opp way at the same price.

          the other thing is that after a few minutes, when the price that triggered the order entry originally is hit again, it again triggers the order entry. i don't want that to happen.

          any thoughts...

          [IMG]file:///C:/DOCUME%7E1/Eric/LOCALS%7E1/Temp/moz-screenshot-1.png[/IMG][IMG]file:///C:/DOCUME%7E1/Eric/LOCALS%7E1/Temp/moz-screenshot-2.png[/IMG]here is what i now have programmed.

          #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>
          /// Automatically enters orders based on price Movement.
          /// </summary>
          [Description("Automatically enters orders based on price Movement.")]
          public class ESoverniteStratAutoOrder22 : Strategy
          {
          #region Variables
          // Wizard generated variables
          private int contractSize = 1; // Default setting for ContractSize
          private double startPrice = 1100.000; // Default setting for StartPrice
          // 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;

          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.UniqueEntries;

          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (Close[0] == StartPrice + TickSize * 3)
          {
          EnterShort(ContractSize, "+3");
          }

          // Condition set 2
          if (Close[0] == StartPrice + TickSize * -3)
          {
          EnterLong(ContractSize, "-3");
          }

          // Condition set 3
          if (Close[0] == StartPrice + TickSize * 6)
          {
          EnterShort(ContractSize, "+6");
          }

          // Condition set 4
          if (Close[0] == StartPrice + TickSize * -6)
          {
          EnterLong(ContractSize, "-6");
          }


          }

          #region Properties
          [Description("# of contracts")]
          [Category("Parameters")]
          public int ContractSize
          {
          get { return contractSize; }
          set { contractSize = Math.Max(1, value); }
          }

          [Description("Starting price")]
          [Category("Parameters")]
          public double StartPrice
          {
          get { return startPrice; }
          set { startPrice = Math.Max(1, value); }
          }
          #endregion
          }
          }
          Attached Files

          Comment


            #20
            Hi Eric,

            Add this line to your initialize section:
            TraceOrders = true;

            This will provide you some order logging that you can view in the output window.

            There are no explicit exits so what is probably going on is your long and short entries are reversing each other.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            656 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            371 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            579 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X