Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Max Down Day

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

    #46
    Unfortunately Set methods can only be applied to the primary time data series. It does not matter what BIP you are in when you set this. If the entry order is not in BIP == 0 then the set will not necessarily be applied with the entry.

    Notes:
    1. Should you have multiple Bars objects of the same instrument and are using Set() methods in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly.
    LanceNinjaTrader Customer Service

    Comment


      #47
      So you are saying when I have the BIP == 1 for the Set then it's just ignoring that whole line of code or in other words ignoring the conditions and the Set?

      But when I comment out that whole section the Net changes, so it must be doing something.

      Comment


        #48
        It's not going to ignore the set, but the set may not be applied or amended properly.

        Typically with multi series scripts users find it beneficial to avoid using the Set() methods and instead using advance order management. Otherwise you will want to ensure you place the set method in the first bars context of that instrument.

        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()
        LanceNinjaTrader Customer Service

        Comment


          #49
          That's why I was trying to replicate whatever the Set is doing with ExitLongStop because that seems to be working for multi-instruments. Is there anyway to replicate the Set script in the form of the ExitLongStop? Whatever the Set script is doing it is working well over a whole index so was looking to stick with that.

          It looks like you are trying to guide me toward IOrder method.

          Comment


            #50
            IOrders with OnExecution are going to be the most common way to create the same automatic stop/target placement that Set() provides.

            if you use ExitLongStop() within OnBarUpdate you can get your stop placed at the same location as you could with SetStopLoss()
            The difference is that SetStopLoss order gets applied as soon as the etnry is filled where as ExitLongStop would have to wait for a condition to be met
            LanceNinjaTrader Customer Service

            Comment


              #51
              So seeing ExitLongStop() has to wait for the condition to be met before its activated it will not react as quick as SetStopLoss() even though the stop is at the same location. That's what I'm seeing on the charts, for instance the Set will exit at the open of a candle and the ExitLongStop will be delayed and exit at the low of the candle or nearer to the close of the candle.

              Let me ask this, I'm basically looking for the exit to be the reverse of the entry, like a stop and reverse strategy but with seperate scripts for the short and the long. So what is the best way to setup an exit for when the reverse condition happens, should I possibly be using a trail stop instead of the iorders onexecution?

              Comment


                #52
                There isn't a "best solution" as it will depend on your exact conditions and goals.
                If I were coding a reverse on stop strategy I would either use advanced order handling and/or the unmanaged approach.

                Advanced order handling (OnExecution()) would allow me to place the reverse order as soon as I was stopped out while the unmanaged approach would allow me to have the reversal order live on the exchange before I was stopped out.
                LanceNinjaTrader Customer Service

                Comment


                  #53
                  I have attached the cs file for the new file using IOrder/IExecution which seems to match the previous file using just the simple SetStopLoss as far as Net Profit goes.

                  I have also attached the IOrder/IExecution file for Multi-Instrument where I have the additional series in Initialize() and the for loop in the OnBarUpdate and IExecution sections to iterate through the different series for each instrument. There is a primary of 5min and secondary of 1min for each instrument.

                  I have a screenshot of the Strategy Analyzer settings attached.

                  The Net profit for the multi-instrument is almost half of the single script with half the trades. Do I have the for loops misplaced or somehow using them incorrectly? I had tried adding UniqueEntries but that produced a drastic negative net profit.

                  note: in the for loop "series" iterates through the 5min bar for each instrument and "series+3" iterates through the 1min bars for each instrument.
                  Attached Files
                  Last edited by zachj; 07-08-2013, 09:07 PM.

                  Comment


                    #54
                    Hello,

                    Things to keep in mind when dealing with multi series scripts.

                    Bars required affects all time frames. In other words all the bars series have to be loaded before trades begin. This will often result in many less trades than when dealing with a single series script.

                    LanceNinjaTrader Customer Service

                    Comment


                      #55
                      Is that all the bars for all series for every instrument need to be loaded or all series per instrument? If all the instruments need to be loaded before the first trade, I thought that was the purpose of the UniqueEntries to have each instrument independent of the next?

                      Otherwise I guess this complete overhaul with converting it to an IOrder-Execution format was a big effort for nothing.

                      Comment


                        #56
                        Hello,

                        All the series, regardless of the instrument need to be loaded.

                        For example if BarsRequired is set to 20 (on a strategy) and you have 3 bar series. Each bar series will need 20 bars loaded before it begins processing.

                        If you're highest bar series was a 30 minute chart, it would take 20, 30minute bars to pass before processing on any of the bar series begins.

                        The OnExecution change was in regards to stop orders not being placed at the right time.
                        LanceNinjaTrader Customer Service

                        Comment


                          #57
                          My highest series is a 5min bar, so 100min need to pass before a trade will trigger and having more instruments makes no difference it sounds like. And the only difference between my single script and the multi script is that the multi is handling multiple instruments at once, so why would anything change? Each instrument should start loading at the same time I would think until 100minutes has passed.


                          Originally posted by NinjaTrader_Lance View Post
                          Hello,

                          All the series, regardless of the instrument need to be loaded.

                          For example if BarsRequired is set to 20 (on a strategy) and you have 3 bar series. Each bar series will need 20 bars loaded before it begins processing.

                          If you're highest bar series was a 30 minute chart, it would take 20, 30minute bars to pass before processing on any of the bar series begins.

                          The OnExecution change was in regards to stop orders not being placed at the right time.

                          Comment


                            #58
                            Looking at the most recent scripts you've posted I'm seeing they are both Multi series scripts and you may have some logical issues as well.

                            For example look at line 76 in your test order multi:
                            for (int series = 0; series < 3; series++)

                            This for loop is not necessary. When OBU() is called by a series it will have a BarsInProgress number.
                            You only need a single if statement to determine which BIP is in use. Looping will not achieve anything here as the call to OBU() can only have a single BIP.

                            Please review this documentation here for more information on using multi series scripts: http://www.ninjatrader.com/support/h...nstruments.htm

                            Your NinjaScript / C# Code will always be logically processed and evaluate according to your set logic – this can of course lead to unexpected results at times, thus we would suggest to simplify and debug your code to better understand the event sequence it would go through

                            Please see the following for debugging tips: http://www.ninjatrader.com/support/f...ead.php?t=3418
                            LanceNinjaTrader Customer Service

                            Comment


                              #59
                              This is just info I am obtaining from other NT reps, I've never been told up to this point that I should not be using this. When you say all I need is a single if statement do you mean for instance if (BIP == 0)? If so how does it know to take bip 0(5min for 1st instr.) & 3(1min for 1st instr.) , then on the next run to take bip 1(5min for 2nd instr.) & 4(1min for 2nd instr.) ) and so on. Or will it somehow automatically move on through all the ADD's in this fashion until they are complete?

                              Comment


                                #60
                                Hello,

                                While you can use a for loop it will be inefficient and is not needed.

                                You need to section your multi series scripts in a way that isolates the logic based on the BIP being used.

                                Each time one of your added series has a bar update it will call OnBarUpdate()
                                It will then calculate based on your BIP logic.

                                if(BIP ==0)
                                //do something for the primary series (the first one added)

                                if(BIP == 1)
                                //do something for the secondary series

                                The following provides great instructions and examples for creating multi series scripts: http://www.ninjatrader.com/support/h...nstruments.htm

                                Alternatively we have a great 2 day intensive NInjaScript class that covers NinjaScript and multi series scripts here: http://www.ninjatrader.com/PremiumEducation.php
                                LanceNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

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