Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order in multi timeframe strategy

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

    Limit order in multi timeframe strategy

    Hi,

    EnterLongLimit(
    int barsInProgressIndex, bool liveUntilCancelled,

    int quantity, double limitPrice, string signalName)

    ****************
    I am using this limit order in a multi-timeframe (30 min and 3 min)strategy and I thought the limit order would be expired (if not filled) only at the end of bar which I assigned(30 min bar), but it is cancelled at the end of 3 mins bar. Is it correct?

    #2
    millridge,

    How are you using this line in code? Likely I'll need to see a code sample.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      EnterLongLimit(0,false,defaultQuantity,getCurrentb id(),"LongEntry")

      where 30 min is primary bar, 3 min is secondary bar

      Comment


        #4
        millridge,

        Likely you will want to use the following reference sample :

        Adam P.NinjaTrader Customer Service

        Comment


          #5
          The sample code is not for multi time frame. Here is my simple code.

          ******************************

          protected override void Initialize()
          {
          Add(PeriodType.Minute, 1);

          }

          /// <summary>
          /// </summary>
          protected override void OnBarUpdate()
          {

          //
          if (BarsInProgress == 0)
          {
          if(CrossAbove())
          {
          EnterLongLimit(0,false,defaultQuantity,getCurrentB id(),"LongEntry");
          }
          }
          if (BarsInProgress == 1)
          {
          do something else
          }
          }
          Last edited by millridge; 10-09-2012, 06:56 AM.

          Comment


            #6
            millridge,

            Did you remove the input for this? I.e. does something exist here as input for the CrossAbove but you removed it to hide your actual condition?

            if(CrossAbove())
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              It can be any condition. for example

              CrossAbove(SMA(Fast), SMA(Slow), 1)

              Comment


                #8
                millridge,

                You may want to use : http://www.ninjatrader.com/support/f...ead.php?t=3627 in the strategies Initialize() method, and view output related to this using Tools > Output window.

                Additionally you can have more control over how long your orders are active using the following reference sample.

                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  Actually, by checking the Log file, the submitted order is cancelled immediately, not as I said early that it was cancelled at the end of 3 min bar. Any idea?

                  Comment


                    #10
                    Millridge,

                    Can you post the log entries? Likely I will need to see most of your OnBarUpdate() method as well.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      To show the issue, I modified NT sample code SimpleMACrossOver and run it. See code and Log below

                      ******************* Code **************************************

                      protected override void Initialize()
                      {
                      Add(PeriodType.Minute, 3);
                      ExitOnClose = false;
                      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 (BarsInProgress == 0)
                      {
                      if (CrossAbove(SMA(Fast), SMA(Slow), 1))
                      EnterLongLimit(0,false,DefaultQuantity,GetCurrentB id(),"LongEntry");
                      else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
                      EnterShortLimit(0,false,DefaultQuantity,GetCurrent Ask(),"ShortEntry");

                      }
                      if (BarsInProgress == 1)
                      {

                      }
                      }

                      ************************************************** ************************
                      10/11/2012 8:30 AM Order Order='4b1aee85b76d4e718b90a9f22df0ccc2/Sim101' Name='Close position' New state=Cancelled Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='73233e991f6d4166be143caa03982fc1/Sim101' Name='LongEntry' New state=Cancelled Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Position Instrument='BAC' Account='Sim101' Avg price=9.40190036900369 Quantity=1,084 Market position=Long Operation=Update Currency=Unknown
                      10/11/2012 8:30 AM Execution Execution='c1220cb78b10419d89e3a4670cd4b98e' Instrument='BAC' Account='Sim101' Exchange=Default Price=9.41 Quantity=103 Market position=Long Operation=Insert Order='f84759f295de4d5ab42e3d62eed7d126' Time='10/11/2012 8:30:01 AM'
                      10/11/2012 8:30 AM Position Instrument='BAC' Account='Sim101' Avg price=9.4010499490316 Quantity=981 Market position=Long Operation=Update Currency=Unknown
                      10/11/2012 8:30 AM Execution Execution='801b78dd3de74502ac0c104248b81c84' Instrument='BAC' Account='Sim101' Exchange=Default Price=9.4 Quantity=439 Market position=Long Operation=Insert Order='f84759f295de4d5ab42e3d62eed7d126' Time='10/11/2012 8:30:01 AM'
                      10/11/2012 8:30 AM Position Instrument='BAC' Account='Sim101' Avg price=9.40190036900369 Quantity=542 Market position=Long Operation=Update Currency=Unknown
                      10/11/2012 8:30 AM Execution Execution='ba12d8bbb37045819dd95a70085b2195' Instrument='BAC' Account='Sim101' Exchange=Default Price=9.41 Quantity=103 Market position=Long Operation=Insert Order='77572215077e4141972c8f9b31e31928' Time='10/11/2012 8:30:01 AM'
                      10/11/2012 8:30 AM Position Instrument='BAC' Account='Sim101' Avg price=9.4 Quantity=439 Market position=Long Operation=Insert Currency=Unknown
                      10/11/2012 8:30 AM Execution Execution='a7674d23479648f582ee979281758787' Instrument='BAC' Account='Sim101' Exchange=Default Price=9.4 Quantity=439 Market position=Long Operation=Insert Order='77572215077e4141972c8f9b31e31928' Time='10/11/2012 8:30:01 AM'
                      10/11/2012 8:30 AM Order Order='73233e991f6d4166be143caa03982fc1/Sim101' Name='LongEntry' New state=PendingCancel Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='4b1aee85b76d4e718b90a9f22df0ccc2/Sim101' Name='Close position' New state=PendingCancel Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='73233e991f6d4166be143caa03982fc1/Sim101' Name='LongEntry' New state=Working Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='73233e991f6d4166be143caa03982fc1/Sim101' Name='LongEntry' New state=Accepted Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='4b1aee85b76d4e718b90a9f22df0ccc2/Sim101' Name='Close position' New state=Working Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='4b1aee85b76d4e718b90a9f22df0ccc2/Sim101' Name='Close position' New state=Accepted Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='73233e991f6d4166be143caa03982fc1/Sim101' Name='LongEntry' New state=PendingSubmit Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                      10/11/2012 8:30 AM Order Order='4b1aee85b76d4e718b90a9f22df0ccc2/Sim101' Name='Close position' New state=PendingSubmit Instrument='BAC' Action=Buy Limit price=9.39 Stop price=0 Quantity=542 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''

                      Comment


                        #12
                        Hello millridge,

                        Are you setting Calculate on bar close to "False" inside the strategy parameters when you are applying the strategy?

                        If so could you try it with it set to True?

                        http://www.ninjatrader.com/support/h...onbarclose.htm
                        JCNinjaTrader Customer Service

                        Comment


                          #13
                          No, I set OnBarClose to TURE

                          Comment


                            #14
                            Any comments on this?

                            Comment


                              #15
                              Hello millridge,

                              Doing some testing on my end, the order is being canceled from an auto expiration. By default if an order is cancelled if they are not filled on the bar they are submitted on. Using the Multi-Time Series strategy can cancel on order on the next OnBarUpdate() with the different BarsInProgress.

                              http://www.ninjatrader.com/support/f...ad.php?t=48561

                              Can you confirm this or can you post a full output log so that I can look farther into it.
                              JCNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X