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

Concerning Strategy/Account syncing after weekend shutdown

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

    Concerning Strategy/Account syncing after weekend shutdown

    From the help files on Immediately Submit/Syncronize Account:

    A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
    Can someone confirm what each of these are referring to:

    order action
    order type
    limit price
    stop price

    On my strategy an order is placed using EnterLong(entrySize,entryName). Two order positions are often created showing an average price on the account position for entry that has multiple decimal places (i.e. 1278.638452154567).

    Now I can recreate this position when I restart the strategy on Sunday night ahead of the market open by injecting the exact values of the account position into my strategy code. I then want it to sync with the account position without submitting any reconciliatory orders.

    What paramaters do I have to match? Do i have to match that entry price with the many decimal places exactly?

    #2
    Hello pmn100,

    Thanks for opening the thread.

    The Synchronize Account Position behavior is force the account to be in sync with the strategy position so the strategy may be started immediately with the security that it will be making profitable trades as designed. If you do not want the reconciliary order to be placed, I would advise to turn off Sync Account Position as that behavior wouldn't be desired.

    Your approach seems the opposite of the behavior. You wish to sync the Strategy Position to the Account Position instead when the positions are out of sync.

    You are correct that this could be done by injecting orders with your own recorded actions within historical processing, and then to let the strategy transition into those orders with the Immediately Submit Start Behavior. I may suggest to write these values to a file and read from the file during historical processing to have the strategy create historical orders that match orders made externally.

    As for Order Action, Order Type, Limit Price and Stop Price, I will refer to the Unmanaged Approach documentation page for submitting orders
    • Order Action = Buy or Sell
    • Order Type = OrderType.Limit, OrderType.Market, OrderType.MIT, OrderType.StopMarket, OrderType.StopLimit
    • Limit Price = Order limit price. Use "0" should this parameter be irrelevant for the OrderType being submitted.
    • Stop Price = Order stop price. Use "0" should this parameter be irrelevant for the OrderType being submitted.

    If you are using the Managed Approach, you may use the appropriate order methods to create the order submission without noting a 0 for the Stop Price or Limit Price if one is irrelevant.

    Order prices must be a multiple of the TickSize. There should not be an excess of decimals.

    SampleOnOrderUpdate is a good strategy that demonstrates how a strategy can resume orders it makes historically.

    SampleOnOrderUpdate - https://ninjatrader.com/support/foru...ead.php?t=7499

    If you have any additional questions, please don't hesitate to ask.
    Last edited by NinjaTrader_Jim; 11-21-2017, 12:42 PM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim

      Yes this is all unmanaged order approach and I am trying to replicate the account position on the strategy rather than vice versa. What I'm really trying to avoid is the reconciliatory orders that I assume take place on market open when spreads and liquidity are likely unpredictable.

      So this is an example of my strategy I have right now on XAUUSD:

      An entry order was made using EnterLong(34) on bar close.

      This is filled partially in two trades at slightly different entry prices, one for 6 and one for 28 and so it created a long position on account of 34 at average price 1281.63823529412.

      So to match this account position to my strategy upon restart I would substitute my historical order of this trade with the following:

      EnterLongStopMarket(34,1281.64) (rounded up to 2 decimal places)

      I would then use the Immediately Submit option without syncronize account and this would 'match' and therefore the account and strategy will be in sync?

      Comment


        #4
        Hello pnm100,

        Thanks for the reply.

        The order methods referenced are from the Managed Approach. The Unmanaged Approach would use SubmitOrderUnmanaged().

        You would want to match the orders instead of the executions that filled them. This would mean submitting the historical order at the same price that you used to enter. Orders must be submitted in multiples of the TickSize to be valid, and much match what is in the NinjaTrader database to match up with a strategy.

        While you can have success matching orders by outlining the strategy like you have, if you are referring to matching orders from the same strategy, I would suggest to leave it running over the weekend, and try to keep your strategy online as long as possible.

        Other than that I think we are in agreeance with how this would be outlined.

        Please note that this approach takes advantage of what we have documented in a way that doesn't follow our supported Start Behaviors. I would recommend to use caution and perform extensive tests using Market Replay data to verify the desired behavior before going live.
        JimNinjaTrader Customer Service

        Comment


          #5
          Sorry I meant managed approach. Okay I'll try some variations and see how the positions are handled.

          I think I actually have it working already but something confused me today where a EnterLong() caused a close out of a short position along with a logic based buy to cover so the position doubled up on longs. I thought this was my strategy out of sync from when I closed down NT last night and restarted, but it turns out EnterLong whilst short will both enter long AND close out the short at the same time, so I didn't need that buy to cover. Something the strategy analyser seems to ignore in backtesting.

          I'd like to keep NT open permenantly but it has been prone to freezing up and you guys recommend restarting once a day anyway. I will leave it open though to see how long it remains working.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Waxavi, Today, 02:10 AM
          0 responses
          3 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          9 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          4 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X