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

Problem with PositionAccount in strategy.

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

    Problem with PositionAccount in strategy.

    Hi, i'm using version 8.0.28.0 64-bit.
    PositionAccount.MarketPosition and PositionAccount.Quantity don't work as expected(on SIM or IB TWS).

    Case 1 to reproduce:
    1. OnBarUpdate Add Print status
      Code:
      " Print(PositionAccount.MarketPosition.ToString() + " " + PositionAccount.Quantity.ToString());​"
    2. When start strategy I don't have opened position on account.
    3. When strategy is running I open position via broker terminal or NT ChartTrader
    4. Code print always that market Position is flat and Quantity is 0

    Case 2 to reproduce:
    1. When start strategy I have opened position on account.
    2. Code print correct information about position
    3. When strategy is running I close position via broker terminal or NT ChartTrader
    4. Code print always that market Potion is previous status and previous quantity

    Seems like PositionAccount for Strategy Updated only when strategy started, after does not updated.

    How can I retrieve real data in real-time?

    #2
    Hello, thanks for writing in. PositionAccount is working for me. I attached my test script if you would like to try this out. Please make sure you are running the supported version of TWS/Gateway. They can be downloaded here:
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks! I found my mistake. I try to access data from UI thread, and I think it was a problem.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by EvaisDery, Today, 05:44 AM
      0 responses
      5 views
      0 likes
      Last Post EvaisDery  
      Started by JerryWar, 11-19-2016, 08:14 AM
      3 responses
      2,067 views
      0 likes
      Last Post tradertom2012  
      Started by capt34, Today, 03:46 AM
      0 responses
      5 views
      0 likes
      Last Post capt34
      by capt34
       
      Started by wuannetraam, Today, 12:22 AM
      1 response
      10 views
      0 likes
      Last Post wuannetraam  
      Started by TGOG1, Yesterday, 03:02 PM
      2 responses
      24 views
      0 likes
      Last Post TGOG1
      by TGOG1
       
      Working...
      X