Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order stops at OrderState.Working when backtesting strategy

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

    Order stops at OrderState.Working when backtesting strategy

    Hi.

    We're debugging and testing our backtest strategy using Historical Fill Processing=High / Tick / 1. Strategy is using our own indicator.

    The backtest strategy was able to submit an order:

    Code:
    SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, _OrderQuantity, 0, 0, string.Empty, signalName);
    and it was able to go thru states but appears to stop at OrderState.Working:

    Code:
    27/04/2020 9:55:00 AM Strategy 'Absinthian - BackTesting Strategy/-1': Entered internal SubmitOrderUnmanaged() method at 27/04/2020 9:55:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Entry/Trade Strategy 1'
    Entry Order assigned to entryOrder. orderId='NT-00000-442' account='Backtest' name='Entry/Trade Strategy 1' orderState=Submitted instrument='FDAX 06-20' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-30 03:59:00' gtd='2099-12-01' statementDate='2020-05-11'
    orderId='NT-00000-442' account='Backtest' name='Entry/Trade Strategy 1' orderState=Accepted instrument='FDAX 06-20' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-30 03:59:00' gtd='2099-12-01' statementDate='2020-05-11'
    orderId='NT-00000-442' account='Backtest' name='Entry/Trade Strategy 1' orderState=Working instrument='FDAX 06-20' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-30 03:59:00' gtd='2099-12-01' statementDate='2020-05-11'
    Could it be because we submit the order via event and not directly in strategy.OnBarUpdate():

    Code:
    indicator.OnBarUpdate()
    -> indicator.OnCriteria(message) public event
    
    strategy.OnCriteria(message) bound to indicator.OnCriteria(message)
    -> call submitorderunmanaged()
    Or is there something we missed setting up?

    Thanks.
    Last edited by cmarkb; 05-10-2020, 11:42 PM. Reason: add tags

    #2
    Okay after adding Print()s and attaching a debugger on both strategy.OnBarUpdate() and indicator.OnBarUpdate(), looks like strategy goes thru all the bars first then afterwards the indicator goes thru all the bars. I thought both OnBarUpdate()s runs inbetween each other or something like that.

    So the order on previous post was submitted when strategy has already gone thru all the bars.

    Comment


      #3
      Ok seems to be working now. Was just removing and adding Print()s. Orders are getting submitted and filled.

      Earlier, I did move the SubmitOrderUnmanaged() calls into OnBarUpdate() -- queued up messages received in OnCriteria() -- but that resulted to nothing.
      Last edited by cmarkb; 05-11-2020, 02:21 AM.

      Comment


        #4
        Looks like using the indicator in the strategy.OnBarUpdate() made it work. I added indicator[0] to the Print() to see its output and that's when the orders get started being processed.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 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