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

Synching to Account with Multi-instrument strategy

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

    Synching to Account with Multi-instrument strategy

    Hello- I created a multi-instrument strategy and want to better understand sycncing the strategy to my account. For my entry orders I'm using the following structure: entryOrder = EnterLong(BarsInProgress, shares1[BarsInProgress],"BuyMkt1"+BarsInProgress); For exiting this particular order I'm using the following code: entryOrder = ExitLong("BuyMkt1"+BarsInProgress); I am declaring the following in my variables section: private IOrder[] activeOrders = new IOrder[100]; omegle discord xender

    So for syncing purposes, how exactly does the strategy identify or keep track of the exact market order entered in this case? Does it work by only remembering the tag "BuyMkt1"+BarsInProgress which it uses to associate it with other order parameters Market order, time, etc? If you notice, the exit statement doesn't indicate how many shares to sell but I verified from strategy backtest that it is correctly selling the quantity = shares1[BarsInProgress] so I'm thinking it must be remembering it only by the tag "BuyMkt1"+BarsInProgress".

    2nd question: If I make a benign tweak in my strategy -say adding print statements or graphics- later in time after I deploy and sync, will the strategy forget the shares that were previously bought and mess everything up?

    Thank you
    Last edited by JorgeDamien; 03-31-2020, 09:37 PM.

    #2
    Originally posted by JorgeDamien View Post
    Hello- I created a multi-instrument strategy and want to better understand sycncing the strategy to my account. For my entry orders I'm using the following structure: entryOrder = EnterLong(BarsInProgress, shares1[BarsInProgress],"BuyMkt1"+BarsInProgress); For exiting this particular order I'm using the following code: entryOrder = ExitLong("BuyMkt1"+BarsInProgress); I am declaring the following in my variables section: private IOrder[] activeOrders = new IOrder[100];

    So for syncing purposes, how exactly does the strategy identify or keep track of the exact market order entered in this case? Does it work by only remembering the tag "BuyMkt1"+BarsInProgress which it uses to associate it with other order parameters Market order, time, etc? If you notice, the exit statement doesn't indicate how many shares to sell but I verified from strategy backtest that it is correctly selling the quantity = shares1[BarsInProgress] so I'm thinking it must be remembering it only by the tag "BuyMkt1"+BarsInProgress".

    2nd question: If I make a benign tweak in my strategy -say adding print statements or graphics- later in time after I deploy and sync, will the strategy forget the shares that were previously bought and mess everything up?
    Welcome to the forums!

    But first, your nomenclature is a bit off -- "syncing the strategy to your account" is actually
    the well-known and established title of a completely different topic. You should probably not
    use the word 'sync' to describe this feature of EnterLong/ExitLong -- matching orders via
    a 'tag' name is much more specific to what you're asking -- this concept of matching orders
    via a 'tag' is one of the main conveniences provided by the "Managed" approach.

    But, yes, ExitLong works exactly by matching the 'tag' (called the "fromEntrySignal" in the
    documentation
    ) to a previous EntrySignal 'tag' from a previous Long entry order which is
    still active.

    If you recompile your strategy on the same machine while that strategy is actively running,
    this is, by itself, not a good thing. Long ago I stopped doing that because of strange
    issues I seemed to create for myself. But doing this while the strategy is running and
    has a position open
    -- well, I am not that courageous to try it on a live account, since
    my earlier experiences seemed to indicate I was doing something pretty stupid to begin
    with. I don't know if it will 'forget the shares', but IMHO there is a high potential for your
    recompile to certainly 'mess everything up' in ways that are probably unpredictable.

    I'm sure NT support would not recommend you recompile a strategy while it is actively
    running -- this cannot be a best practice -- you must resist the temptation to recompile
    your 'benign tweak' while it's running.

    When I want to recompile a strategy, I always exit any current positions, then I Disable
    and Remove the strategy (via the right-click menu of the Strategy tab in Control Center),
    only then do I recompile. After recompiling, I right-click inside the chart and re-add the
    strategy. I have never had a single issue by following these steps.

    The best advice, however, is to develop your strategies on a different PC -- such that
    if you're running a strategy (esp running it on a live account), you should not be developing
    that strategy (or any other) while that strategy is running live.

    First Golden Rule: while a strategy is running, do not recompile anything -- first stop
    the strategy, then recompile, and then add it back to the chart and restart it.

    Better Golden Rule: don't develop your strategies on the same machine you run them,
    esp from a live account, because you will cause yourself grief and frustration (if I remember
    correctly, even from a Sim101 account) if you don't follow the First Golden Rule.

    Best Golden Rule: run your strategies using a VPS, use your local PC for testing
    and development only.
    Last edited by bltdavid; 03-30-2020, 06:48 AM.

    Comment


      #3
      Hi JorgeDamien, thanks for your note.

      If you use ExitLong with a signal name parameter the strategy will target only the entry signal with the exact matching signal name. For the second question, there are options for how you want to start the strategy see here for documentation:



      The default setting is Wait Until Flat, but if you have a strategy with an open position/resting orders that needed to be reset or disabled, you can use the various other options.

      Please let me know if I can assist any further.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        The default setting is Wait Until Flat, but if you have a strategy with an open position/resting orders that needed to be reset or disabled, you can use the various other options.
        Yeh, here is a link on a strategy when re-enabling and matching previously placed orders: https://ninjatrader.com/support/foru...fit#post742142

        Comment


          #5
          mariasbarker,

          Welcome to the NinjaTrader forums!
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by elirion, Today, 01:36 AM
          2 responses
          12 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by DJ888, 04-16-2024, 06:09 PM
          5 responses
          14 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by samish18, Yesterday, 08:31 AM
          4 responses
          14 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by funk10101, Yesterday, 09:43 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          5 responses
          551 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X