Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entries Count per minute

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

    #31
    Ok what if I have a script which is a single series(has a secondary but it's negligible because it's just a lower time frame of primary) but i'm running the single series against a portfolio of instruments in strategy analyzer. Should I be using Performance.AllTrades.Count or Positions.Quantity?

    It seems like if I use Performance it's stopping many trades but Positions is ignoring BarsSinceEntry. I can't quite figure out what's happening there.

    Comment


      #32
      Zachj,

      You may want to try printing out the values of the Performance.AllTrades.Count and Positions.Quantity and make sure they are the values you want.

      What results are you getting and what do you expect the results to be?
      Cal H.NinjaTrader Customer Service

      Comment


        #33
        I'm not sure what printing out the values would do, I'm often suggested that but it doesn't make sense to me. I know that when the trades do trigger they are triggering in the correct locations its only a matter of a trade actually triggering or not triggering. I've come to the conclusion that the Performance can't be the way to go because it's just summing up all the trades for all instruments combined and not per individual instrument as I need. So once the very first trade triggers regardless of instrument it's now bypassing the Performance statement and sending all trades to the BarsSinceEntry statement. This is apparently stopping a lot of trades from triggering. So when I switch to the Positions statement it now let's the additional trades through but when it gets to the BSE statement it seems to be ignoring it because I see it entering one particular symbol 4x's in a row 1minute after the other. I have BSE set to > 2 on a 5min time frame. I even tried changing that to >10 and it makes no difference.

        I was thinking maybe do I need a statement at the end of the script that changes the bool back to the default of false or something?

        Comment


          #34
          Zachj,

          In your other post that you use a portfolio of instruments from the strategy analyzer and your code only has a lower time frame for the primary.

          When you run a portfolio in a strategy analyzer each instrument will get its own strategy attached to run which means its own trade collection of all the trades that take place.

          What this means is that the first trade will only apply to the instrument that the strategy is being applied to. After that first trade is taken then the rest of your strategy will send the trades to the BSE portion of your code.
          Cal H.NinjaTrader Customer Service

          Comment


            #35
            Well then I don't understand why when using Performance (if it is counting seperately for each instrument as you say) that it has half as many trades as when using Position.

            I can't believe how difficult this is to just simply get it to not trade unless a certain amount of bars has passed since the last trade. It's like brain surgery here.

            Comment


              #36
              Zachj,

              Let's take a step back here and attack the BarsSinceEntry().

              Based off what you told me with the script running a two time frame series, I would try having the BSE able to determine which BIP you want the bars to be calculated on.

              Code Example:
              Code:
              BarsSinceEntry(int barsInProgressIndex, string signalName, int entriesAgo)
              If you want the BSE off the primary series use 0, otherwise use 1 for the smaller time frame.

              If you require any more assistance please go ahead and send a request into support[at]ninjatrader[dot]com
              Cal H.NinjaTrader Customer Service

              Comment


                #37
                I was looking at the manual closer and Position.Quantity is the position size not the # of trades, so that won't work right?

                Anyhow, using the single script and running a portfolio in strategy analyzer this piece of script works below when you have me add in the BIP into the BSE statement. It's entering all trades that it should and its only allowing trades after 2 primary bars have passed...
                Code:
                 bool enterTrade = false;
                                if (Performance.AllTrades.Count < 1)
                				
                					{
                					enterTrade = true;
                					}
                					else
                					{
                					enterTrade = BarsSinceEntry(0, "", 0) > 2; 
                					} 
                
                     			if(enterTrade)  //Rest of code...//
                But now I'm still faced with the original challenge of getting this to work in the multi-instrument script(where I have the portfolio all worked into one script). I can't use the if (Performance.AllTrades.Count < 1) because that is not computing the trade count for each instrument seperately. Using Position.Quantity is not working and it seems that's the position size and not the trade count anyways. I don't think there's a way to do it is there? I even tried using if (Positions[0].MarketPosition == MarketPosition.Flat)

                Comment


                  #38
                  The only way I can think of to do this would be to create your own tracking variables. Each time a trade completed you would update your variable. You would need a variable for each instrument (or index location if storing in a list/array) to store this value.

                  I'll leave this open for others to provide input on as well.
                  LanceNinjaTrader Customer Service

                  Comment


                    #39
                    Can I just do something like this below where I create the variable NumEntries and have it count after EnterLong? If so how can I get a series/instrument to tie to the variable? Would I have to create a user defined method maybe?

                    Code:
                         for (int series = 0; series < 5; series++)
                    		if (BarsInProgress == series)
                                     {
                                        bool enterTrade = false;
                    		    if ([COLOR="Blue"]NumEntries[/COLOR] < 1)
                    				{
                    				enterTrade = true;
                    				}
                    				else
                    				{
                    				enterTrade = BarsSinceEntry(series, "", 0) > 2; 
                    				} 
                    
                                        if (enterTrade)
                                          { 
                                               //Conditions for Entry
                                               EnterLong(series, 200, "");
                    			   [COLOR="blue"]NumEntries++[/COLOR];
                    		      }
                                       }
                    Last edited by zachj; 08-15-2013, 09:06 PM.

                    Comment


                      #40
                      This is the correct general concept, but you need a way to distinguish between different instruments, otherwise you'll be recreating the total trade count
                      LanceNinjaTrader Customer Service

                      Comment


                        #41
                        Well that was the whole point of my post asking how I can tie the different instruments to the NumEntries Variable created. Just as I tied the instruments to BIP, BSE & EnterLong. Is there a way to do this?

                        Comment


                          #42
                          Consider creating a variable list or array to index the location per instrument.
                          LanceNinjaTrader Customer Service

                          Comment


                            #43
                            Ok so if I have this variable list below, is there a way to have it tie NumEntries1 to instrument 1 and NumEntries2 to instrument 2 and so on? And also have NumEntries1 to switch to NumEntries2-->3-->4-->5. Or can I create a user defined method of NumEntries(BIP) or something to that effect? Kinda like how there's is a BarsSinceEntry().

                            Code:
                             
                            private int NumEntries1 = 0;
                            private int NumEntries2 = 0;
                            private int NumEntries3 = 0;
                            private int NumEntries4 = 0;
                            private int NumEntries5 = 0;
                             
                             
                            for (int series = 0; series < 5; series++)
                                    if (BarsInProgress == series)
                            {
                            bool enterTrade = false;
                                     if ([COLOR=blue]NumEntries1[/COLOR] < 1)
                                            {
                                            enterTrade = true;
                                            }
                                            else
                                            {
                                            enterTrade = BarsSinceEntry(series, "", 0) > 2; 
                                            } 
                             
                            if (enterTrade)
                            { 
                            //Conditions for Entry
                            EnterLong(series, 200, "");
                            [COLOR=blue]NumEntries1[/COLOR]++;
                                     }
                            }
                            Last edited by zachj; 08-18-2013, 07:31 PM.

                            Comment


                              #44
                              This whole dispute could have been easily resolved with the simple code below. I don't understand why this wasn't suggested to me. I spent almost 2 months working on how to resolve the issue of controlling how many trades can trigger within a given time period for multi-instrument script. Then I found this below.

                              if (BarsSinceEntry(series, "" ,0) > 1 || BarsSinceExit(series, "" ,0) == -1)
                              Last edited by zachj; 10-09-2013, 08:33 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              602 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              347 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              559 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X