Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChangeOrder is limited by EntriesPerDirection setting?

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

    ChangeOrder is limited by EntriesPerDirection setting?

    wondering and am looking for confirmation:

    i am using the ChangeOrder() in my strategy

    Code:
    Example
    if(entryOrder == null ) entryOrder = EnterShortLimit(0 , true , CurrentTradeSize  , EntryLevel  , "Short");
    else ChangeOrder(entryOrder,CurrentTradeSize,EntryLevel,EntryLevel );
    ​
    but it seems that if the EntriesPerDirection = 1 I get the CHANGED order ignored, with :
    Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

    it is as if the Changeorder is considered as a new order to same direction every time its used.
    if I set the EntriesPerDirection = 50. it works. (kind of)

    am I supposed to use the ChangeOrder() in some other way ?

    #2
    Hello dadarara,

    That may be due to your logic, a change order should not cause that type of error. I tried the following and see it change to a quantity of 2 without the warning. You can apply this to a 10 second chart and then watch it work in realtime.


    Code:
    public class Test : Strategy
        {
            private Order entryOrder = null;
            bool doOnce;
            
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Name                                        = "Test";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 1;
                    EntryHandling                                = EntryHandling.AllEntries;
                    TraceOrders                                    = true;
                }
            }
        
            protected override void OnBarUpdate()
            {
                if (State == State.Historical) 
                    return;
                
                if(!doOnce)
                {
                    EnterLongLimit(0, true, 1, Close[0] - 20*TickSize, "entryOrder");    
                    doOnce = true;
                } else{
                    ChangeOrder(    entryOrder, 2, Close[0] - 20*TickSize,0);
                }
    
                
            }
            
            protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
            {
              if (order.Name == "entryOrder")
                  entryOrder = order;
             
              // if entry order exists
              if (entryOrder != null && entryOrder == order)
              {
                  Print(order.ToString());
                  if (order.OrderState == OrderState.Cancelled)
                  {
                      // Do something here
                      entryOrder = null;
                  }
              }
            }
        }

    Comment


      #3
      I am not doing it once. every candle I change the order. of course if conditions are right,
      regardless, if the standing order is not executed, a change should occur with a new price.
      thats when i have a problem .

      doing it once, I also dont have an issue

      Comment


        #4
        Hello dadarara,

        That would still work if you are changing the price on each update, that sample is also updating the order for each update after its submitted, I just didn't add anything to change the price. That works with no warnings. That sample is just a proof that shows the entries per direction does not apply to ChangeOrder because that is a single order.

        In your script you would need to use prints to identify which order is being called at that time to better understand why you are getting that warning. If your entry order condition is being called again after submitting the initial entry that would cause that warning.

        Comment


          #5
          made changes
          seems to work in playback but in the HISTORY there are patches of time when the orders are simply ignored . saying the same
          Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

          what can be the issue with historical run, while in live it works .? (at least in the payback)

          Comment


            #6
            Hello dadarara,

            If you are seeing that message that means the strategy was in a position already and an entry method was called. If during a period of time in the backtest the strategy is in a position that will block any entry signals from submitting more orders. The only way around that would be to allow for more entries per direction if that is your intention, otherwise that is working as intended and preventing more entries until the position is closed.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            113 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            60 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            81 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X