Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with running Replay or my Strategy?

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

    Problem with running Replay or my Strategy?

    I created several strategies using the wizard, I have been trying to test them using the Market Replay. While I'm testing it I have the an order quantity that i'm using of 30,000. The strategy will start buying and selling the whole quantity as it is supposed to. Then all of the sudden, it will break up the order. It begins to make orders by splitting the transaction between 29,999 and 1. Then for some reason, when the strategy hits its profit target, it will just keep closing out 1 quantity over and over.

    Any help would be greatly appreciated.

    #2
    Hello,

    Thank ou for our post and welcome to our forums!

    I assume this is forex, correct?

    Did you download this data from our servers? Or was it recorded from a live connection?

    If recorded, what broker technology was used?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Yes Forex, the data was downloaded from your server.

      Comment


        #4
        Hello,

        In the case of downloaded replay data, this is recorded from a GAIN connection which works a little differently.

        Instead of specifing the number of lots in terms of units (30,000), you will need to simply use a value of 3 to represent 3 lots.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Sorry, I am pretty new to this and I don't follow what you are saying. I tried to use the replay connection with a quantity of three and that didn't help. It still splits up the position.

          Here is a copy of the code Im using, if that helps. It was made with the Wizard.

          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.Strategy
          {
          /// <summary>
          /// SMA -first
          /// </summary>
          [Description("SMA -first")]
          public class SMA33 : Strategy
          {
          #region Variables
          // Wizard generated variables
          private int fast = 7; // Default setting for Fast
          private int slow = 21; // Default setting for Slow
          private int profitTarget = 24; // Default setting for ProfitTarget
          private int stopLoss = 13; // Default setting for StopLoss
          private int medium = 14; // Default setting for Medium
          private int qTY = 30000; // Default setting for QTY
          // 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(SMA(Fast));
          Add(SMA(Slow));
          Add(SMA(Fast));
          Add(SMA(Medium));
          Add(SMA(Fast));
          Add(SMA(Medium));
          SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
          SetStopLoss("", CalculationMode.Ticks, StopLoss, true);

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (CrossAbove(SMA(Fast), SMA(Slow), 1)
          && CrossAbove(SMA(Fast), SMA(Medium), 1))
          {
          EnterLong(QTY, "");
          }

          // Condition set 2
          if (CrossBelow(SMA(Fast), SMA(Slow), 1)
          && CrossBelow(SMA(Fast), SMA(Medium), 1))
          {
          EnterShort(QTY, "");
          }
          }

          #region Properties
          [Description("fast period moving average")]
          [GridCategory("Parameters")]
          public int Fast
          {
          get { return fast; }
          set { fast = Math.Max(1, value); }
          }

          [Description("slow period moving average")]
          [GridCategory("Parameters")]
          public int Slow
          {
          get { return slow; }
          set { slow = Math.Max(1, value); }
          }

          [Description("profit target ticks")]
          [GridCategory("Parameters")]
          public int ProfitTarget
          {
          get { return profitTarget; }
          set { profitTarget = Math.Max(1, value); }
          }

          [Description("stop loss ticks")]
          [GridCategory("Parameters")]
          public int StopLoss
          {
          get { return stopLoss; }
          set { stopLoss = Math.Max(1, value); }
          }

          [Description("Medium Moving average")]
          [GridCategory("Parameters")]
          public int Medium
          {
          get { return medium; }
          set { medium = Math.Max(1, value); }
          }

          [Description("")]
          [GridCategory("Parameters")]
          public int QTY
          {
          get { return qTY; }
          set { qTY = Math.Max(1, value); }
          }
          #endregion
          }
          }

          Comment


            #6
            I don't believe this has anything do with your code. The Forex Replay has a few quirks to it.

            What exactly do you mean by it splits up the position?
            MatthewNinjaTrader Product Management

            Comment


              #7
              If I have the strategy set to buy 30K when x happens, it will actually buy 1 and then buy 29,999. Then when a profit target is hit it will start selling my position, 1 by 1 instead of closing out the whole position.

              Comment


                #8
                Originally posted by Kspot View Post
                If I have the strategy set to buy 30K when x happens, it will actually buy 1 and then buy 29,999. Then when a profit target is hit it will start selling my position, 1 by 1 instead of closing out the whole position.

                Is your 1 and 29,999 at the same price or different?

                You have "Enforce Immediate Fills" enabled? If so, yeah, sounds like a issue....



                12-04-2012, 07:46 AM #8
                NinjaTrader_Jason
                NinjaTrader Customer Service


                Hello sledge,

                You can enable 'Enforce immediate fills' at Control Center-->Tools-->Options-->Simulator-tab. This will cause orders to fill right away.
                Jason

                Comment


                  #9
                  Thank you sledge! I think that did it.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,610 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  19 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  22 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X