Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mimic Entry Handling in Unmanaged Strategy

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

    Mimic Entry Handling in Unmanaged Strategy

    How would I mimic Entry Handling in an Unmanged Strategy? Both all entries and unique entries?

    #2
    Hello cutzpr,

    This tracking would need to be accomplished with the logic of your script.

    If you were tracking a single entry, you could look for the position to be flat to allow any new entries.
    Or you could use a counter that increments on each (complete) entry order fill and decrements when an exit order fills.

    If you are wanting multiple entries based on the signal name and logic to allow up to a set number of entries for each signal name, you would need custom logic to store this information. You might use a dictionary of ints used as counters where the key is the signal name. This would make one entry per signal name that tracks the number of entries for that signal name.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I know there are several ways to go about it, this is what I figured. I am posting here to help anyone else that may find it useful

      PHP Code:
      
      Order lastOrder;
      
       protected override void OnOrderUpdate(...)
      {
      lastOrder = order;
      }
          
      
              public bool MaxPositionSizeMet()
              {
                  if(IsFlat()) return false;
                  else if (Position.Quantity >= this.maxPositions)
                  {
                  return true;
                  }
                  else return false;    
              }
              
              
              public bool MaxEntriesPerDirectionMet()
              {
                  
                  OpenOrders.Add(lastOrder);
                  int count = 0;
      
                  if(IsFlat())
                  {
                  OpenOrders.Clear();
                  count = 0;
                  return false;
                  }
      
      
                  //For Max Entries for All Entries----------
                  foreach(Order o in OpenOrders)
                  {
                      if(o.FromEntrySignal == lastOrder.FromEntrySignal) count++;
                  }
                  
                  if (count >= maxEntriesPerDirection) return true;
                  else return false;
                  //----------------------------------------
                  
      
              }
              
      public bool zMaxUniqueEntriesMet()
              {
                  OpenOrders.Add(lastOrder);
                  bool u = false;
                  
                  if(zIsFlat())
                  {
                  OpenOrders.Clear();
                  return false;
                  }
      
                  if (OpenOrders.Any())
                  {
                      var OrderGroups = OpenOrders.GroupBy(x => x.FromEntrySignal);
      
                      foreach (var g in OrderGroups)
                      {
                          if (lastOrder.FromEntrySignal == g.Key)
                          {
                              if (g.Count() >= maxUniqueEntriesPerDirection)
                                  u = true;
                              else
                                  u = false;
                          }
                      }
                  }
      
                  return u;
                          
              } 
      
      Last edited by cutzpr; 09-30-2018, 10:51 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      55 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      132 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X