Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders Cancelling

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

    Orders Cancelling

    I have a simple stategy that waits for the price to fall below a certain figure before then entering a buy stop order at a higher level. If I apply this to a 1 minute chart, if the order is not filled in the same bar that the order was placed then it appears that the order is cancelled (at least in simulation mode this is the case). Is there a way I can stop the order from being cancelled?

    #2
    use the overload
    Code:
    EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity,  double  limitPrice, string signalName)
    set liveUntilCancelled to true.

    Comment


      #3
      Thanks for the quick reply. Looks like I might have to start learning about coding then. I was hoping that I could do everything using the strategy wizard but maybe that's not possible.

      Comment


        #4
        Shanghai, this option is unfortunately not available in the Strategy Wizard.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Originally posted by bukkan View Post
          use the overload
          Code:
          EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity,  double  limitPrice, string signalName)
          set liveUntilCancelled to true.
          Back to bukkan's very helpful post if the order does not cancel what is to stop another order from being placed at each subsequent bar? The strategy specifies one entry only but will that be one per bar or one in total if I am specifying 1 minute bars for example?

          Comment


            #6
            Shanghai,
            just create the strategy with the wizard and when you are done unlock the same and just replace the EnterLongLimit and EnterShortLimit with the overload as i mentioned.

            the -ive is that you wont be able to edit the strategy later but you could always create a new strategy (with similar conditions) anytime later.

            Comment


              #7
              Thanks bukkan, much appreciated. However I've tried your suggestion but it gives me a number of coding errors when I try to paste it in. This should work for NT7?
              Attached Files
              Last edited by Shanghai; 04-17-2011, 10:55 PM.

              Comment


                #8
                Shanghai, can you please attach the script so we can have a look why it would not compile for you? Also: ensure the error are not found in another script - as NT compiles all scripts into one DLL for runtime use all scripts currently installed have to 'error free' and in so called compilable state.

                Thanks,
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Bertrand, the code as it standsbefore I make bukkan's replacement is shown below. From his instructions it seems that I should simply replace the entire highlighted blue text with his overload. He included a long limit order rather than a long stop but that is simple to change.

                  Apologies for the dumb nature of my posts. I thought this would be an easy strategy to produce and I have never even had to unlock the NinjaTrader code until this week.

                  Code:
                   
                  // This namespace holds all strategies and is required. Do not change it.
                  namespace NinjaTrader.Strategy
                  {
                  /// <summary>
                  /// Daily trend trading trigger
                  /// </summary>
                  [Description("Daily trend trading trigger")]
                  public class Trigger : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  private double trigger = 1; // Default setting for Trigger
                  private double entry = 1; // Default setting for Entry
                  private int shares = 1; // Default setting for Shares
                  private double scratch = 1; // Default setting for Scratch
                  // 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;
                  }
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (GetCurrentBid() <= Trigger
                  && ToTime(DateTime.Now) >= ToTime(13, 45, 0))
                  {
                  [COLOR=blue]EnterLongStop(Shares, Entry, "");[/COLOR]
                  }
                  // Condition set 2
                  if (GetCurrentBid() <= Scratch)
                  {
                  ExitLong("", "");
                  }
                  // Condition set 3
                  if (GetCurrentBid() < Entry
                  && ToTime(DateTime.Now) > ToTime(20, 55, 0))
                  {
                  ExitLong("", "");
                  }
                  }
                  #region Properties
                  [Description("Level at which entry order will trigger")]
                  [GridCategory("Parameters")]
                  public double Trigger
                  {
                  get { return trigger; }
                  set { trigger = Math.Max(1, value); }
                  }
                  [Description("Level at which trade should be entered")]
                  [GridCategory("Parameters")]
                  public double Entry
                  {
                  get { return entry; }
                  set { entry = Math.Max(1, value); }
                  }
                  [Description("Number of shares")]
                  [GridCategory("Parameters")]
                  public int Shares
                  {
                  get { return shares; }
                  set { shares = Math.Max(1, value); }
                  }
                  [Description("Intraday scratch level ")]
                  [GridCategory("Parameters")]
                  public double Scratch
                  {
                  get { return scratch; }
                  set { scratch = Math.Max(1, value); }
                  }
                  #endregion
                  }
                  }

                  Comment


                    #10
                    Shanghai, try replacing the blue snippet with this below -

                    EnterLongStop(0, true, Shares, Entry, "");

                    The overload bukkan posted was the one to use correct, as it would offer setting the liveUntilCancelled bool so the expiring order does not have to be resubmitted on each bar, however the parameters it has still all need to be filled in accordingly like in my snippet above.

                    Thanks,
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Understood. Thanks to both of you.

                      Comment


                        #12
                        Backtest Strategy on a continious futures contract

                        Hello,

                        I want to backtest a strategy on the Crude Oil futures continious contract
                        from Jan 17 2011 to Apr 17 2011.

                        How do I do that?

                        Thx

                        Comment


                          #13
                          rzeemeijer, if you're using NinjaTrader 7, all you have to do is select those dates for the crude oil backtest and NT will automatically download all of the older contract data and merge it and run the tests over the merged data.
                          AustinNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by mjairg, 07-20-2023, 11:57 PM
                          3 responses
                          213 views
                          1 like
                          Last Post PaulMohn  
                          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                          4 responses
                          544 views
                          0 likes
                          Last Post PaulMohn  
                          Started by GLFX005, Today, 03:23 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post GLFX005
                          by GLFX005
                           
                          Started by XXtrader, Yesterday, 11:30 PM
                          2 responses
                          12 views
                          0 likes
                          Last Post XXtrader  
                          Started by Waxavi, Today, 02:10 AM
                          0 responses
                          7 views
                          0 likes
                          Last Post Waxavi
                          by Waxavi
                           
                          Working...
                          X