Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 jaybedreamin, Today, 05:56 PM
        0 responses
        3 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Working...
        X