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

Issue with immediately submit

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

    Issue with immediately submit

    Hello!!

    I will try to explain my problem through an example.

    If I make a long position ("2L") and I disconnect the strategy, I let some time pass. During that time historical trades open and close. But when I connect the strategy using immediately submit, the last position is long but with a different quantity ("5L"). The strategy will seek to sell the 5L. but I don't have that amount in my account and I don't want it to go short.

    How should I operate so that my strategy knows how much to sell? I have other strategies operating on that instrument so I cannot use adopt account position.

    Thanks!

    #2
    Hello 7robert,

    Lets break this down a bit.

    We know we're using immediately submit, but are we using the synchronize account?
    https://ninjatrader.com/support/foru...541#post811541

    With immediately submit without account sync ninjatrader isn't going to send any orders to the account and the strategy position assumes you know what you are doing with the account. The strategy position and account position can be out of sync.
    https://ninjatrader.com/support/foru...660#post792660
    https://ninjatrader.com/support/help...ediatelySubmit

    Is intra-bar granularity added to the script (with TickReplay for any indicators)?
    https://ninjatrader.com/support/foru...182#post783182
    https://ninjatrader.com/support/foru...377#post773377


    So you are long 2. Is this from a previous run of the strategy or manual orders placed? (i.e. does ninjatrader recognize the orders and resume the orders?)

    The strategy is enabled and it calculates long 5.

    At this point the account is still long 2? Without the sync this stays the case.

    Last, you mention there would be sells. This wouldn't take place. The account is long 2, the strategy calculates long 5.
    If the sync is on, then an order is sent to buy 3. This increase the long position of the account from long 2 to long 5 with a synchronization order.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi again Chelsea

      If the last historical trade was 5L and my account is in 2L I don't want to buy 3L, I just want to sell my 2L.

      Comment


        #4
        Hello 7robert,

        To confirm, you would like custom logic where if the account does not match the strategy, you would like an order to flatten the account and leave the strategy in its calculated position where the two will not be in sync, is this correct?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Let me explain myself better, if the last historical trade was 5L and my account is in 2L I don't want to buy 3L, I just want the strategy sell my 2L instead of 5L. Leaving my account and strategy in flat.

          Comment


            #6
            Hello 7robert,

            If the account and strategy are not in sync then the accounts would need to put back to flat separately using different approaches.

            You could choose to always start the strategy flat and use the synchronize account so the account also always starts flat using the tip from the forum link in post #2.


            Alternatively, you could check the PositionAccount.MarketPosition and compare this to the strategy's Position.MarketPosition on the last historical bar and decide to place a historical order in the strategy and use the account sync.


            Or without using the account you could separately send an order using the addon approach to the account outside of the strategy to flatten the account, and also send an internal historical order to the strategy to flatten the strategy position.

            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            19 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            45 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            21 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            181 views
            0 likes
            Last Post jeronymite  
            Working...
            X