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

Account synchronization

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

    Account synchronization

    I am aware that NT provides certain "account synchronization" capabilities, however, we need a bit more advanced handling.

    Can a strategy work in a global scope, i.e. seeing all orders, actual account position, etc? So it can adjust itself based on a real situation with the account.

    In other words, is it possible to obtain:
    - Actual account position, the global position (not only strategy position)
    - Actual account RPL, the global RPL (not only strategy RPL)
    - Actual account position updates (not only strategy position update)
    - All account orders updates (not only strategy order update)

    Thank you!

    P.S. Not-supported information is very welcomed too!

    #2
    Hello alex.nt,

    Thank you for your note.

    There are no supported methods to pull these values. I am aware of an unsupported method for the positions in the account (listed below), but I am not aware of any other methods to pull the other values.
    Code:
    foreach (Account acct in Cbi.Globals.Accounts)
    {
    if (acct.Positions != null)
    {
    PositionCollection positions = acct.Positions;
    foreach (Position pos in positions)
    {
    Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
    }
    }

    Comment


      #3
      That would give me the actual position for the account the strategy runs on, wouldn't it?

      For example, if my account position is flat but strategy "thinks" it is long, how would I get values for account position and strategy position?

      Next question - is it possible to continue running the strategy being out of sync with account position? For example, strategy disconnected and the reconnected but during disconnection some manual order got through. Would the strategy be able to continue running? And can it find out that there was a change in actual position?

      Comment


        #4
        Hello Alex,

        Thank you for your response.

        This would in fact give the positions of the account the strategy is running on. Strategy Position would be Position.MarketPosition: http://www.ninjatrader.com/support/h...etposition.htm

        The strategy can continue to run after the account becomes out of sync with the strategy. You would use the Position.MarketPosition for the strategy position and the unsupported method to pull the account positions.

        Comment


          #5
          Hi Patrick,

          Doesn't strategy gets held when out of sync with account occurs? Like "yellow" state in Control Center?

          If my strategy disconnects and while being disconnected an external order would change the account position. Then my strategy reconnects and "thinks" that its position is still Position.MarketPosition. However, I can always find out the actual account position via that unsupported way mentioned earlier, right? That means that strategy at least can understand that during disconnect something got changed and adjust itself accordingly.

          Is that an actual scenario? Would that work? The reason I am asking is that it appeared that strategies were blocked (yellow mode) in case of out-of-sync situation.

          Comment


            #6
            Hello alex.nt,

            Thank you for your response.

            You could use the unsupported method to pull the account position. The Yellow status indicates that the strategy is waiting until it's historical position is flat before taking live positions. This can be changed by going to Tools > Options > Strategies > NinjaScript > On starting real-time strategy > change to Immediately submit live working historical orders > OK.This will have the strategies immediately submit orders for their historical positions.

            Upon disconnect and re-connect there are options to allow you to re-calculate the strategy position. For information on these options please visit the following link: http://www.ninjatrader.com/support/h...tegies_tab.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            41 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            12 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            8 views
            0 likes
            Last Post port119
            by port119
             
            Started by Philippe56140, Today, 02:35 PM
            0 responses
            7 views
            0 likes
            Last Post Philippe56140  
            Started by 00nevest, Today, 02:27 PM
            0 responses
            7 views
            0 likes
            Last Post 00nevest  
            Working...
            X