• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

After each strategy restart, I can not track of previous open positions

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

    After each strategy restart, I can not track of previous open positions

    Hi
    Im fairly new to NT coding.
    My broker is Interactive broker and it exits (disconnects form NT) once in a day so my strategy get restarted. and for each day that market opens my strategy can not determine what are the previous positions.
    i added the script here.
    Any advice is appreciated.
    Thanks in advance

    P.S: Also, does any one has any idea how to solve the problem of each day exit from Interactive broker?
    Attached Files

    #2
    Hello godric,

    Thank you for the post.

    In this case, to avoid the disconnect you would need to use the IB Gateway instead of using TWS.

    You can find directions on how to configure the gateway in the connection guide here: https://ninjatrader.com/ConnectionGu...nnection-Guide

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks for your quick reply.
      I tried the Gateway also and the same problem.
      Lets just simplify the problem to this case that, there are some positions open in Ninja trader and you run new strategy,
      1-How one can determine if previous positions are short or long?
      2-How to count the size(number of shares ) that are already bought or sold in those positions.

      Thanks in advance

      Comment


        #4
        Hello godric,

        Thank you for the reply.

        This is going to depend on the start behavior that you select and also how your strategy is programmed. If your strategy is created to adopt the account position after it calculates you could refer to the Position object to find out the direction and quantity of the position it is in. If your strategy is not aware of the prior position meaning that when it enabled it did not re evalueate the same position or adopt it, you would need to use alternative means such as PositionsAccount or the addon account methods. I do see that you are using the addon account method already so that is one way to access the Positions collection. A position object has a MarketPosition enum which defines the direction and a Quantity property.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Botan626, Today, 04:43 AM
        0 responses
        4 views
        0 likes
        Last Post Botan626  
        Started by xsgex, Yesterday, 09:46 PM
        0 responses
        3 views
        0 likes
        Last Post xsgex
        by xsgex
         
        Started by Steve L, Yesterday, 09:36 PM
        0 responses
        6 views
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by krugman25, Yesterday, 09:34 PM
        0 responses
        4 views
        0 likes
        Last Post krugman25  
        Started by indy73, Yesterday, 04:42 PM
        0 responses
        15 views
        0 likes
        Last Post indy73
        by indy73
         
        Working...
        X