Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sending strategy positions

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

    Sending strategy positions

    Hello,

    In NT7 to match the strategy positions with the account positions I save the positions details in a database. When I restarted the stategy, before real-time data was executed, I submited an order to create the strategy position.

    In NT8 I am doing exactly the same with the code:

    MyOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market,MyQuantity, 0, 0, "", "MyOrder");

    but the strategy position is not created. I execute this code in OnBarUpdate() when historical data is processed. The same than in NT7.

    I also tried to read the Account Position and submit the order but it doesn't work.

    What would be the solution for this?

    #2
    Hello,

    Thank you for the post.

    I wanted to clarify, you are saying that when you submit an order in Historical it is not being executed, is that correct?

    Are you able to see that the order was submitted using the OnOrderUpdate override? Also are you able to see if the order is being filled at all using OnExecutionUpdate? Another item to check would be BarsRequiredToTrade, are you past the minimum BarsRequiredToTrade that was set?

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

    Comment


      #3
      Sorry for not explaining very well.

      When I submit an order during historical data execution I do not expect to be executed in the "real world". I just pretend to create a strategy position to match with an account position that is already open in the "real world". If this "fake" order is executed then it would duplicate the real world position and, of course, I have to avoid it.

      I have been doing it in NT7 and it always worked. My strategy positions have to match the account positions. When I did it in NT7 it created a strategy position without affecting the account positions.

      Comment


        #4
        Hello,

        Thank you for the reply.

        I wanted to clarify what you are doing.

        You said:
        When I submit an order during historical data execution I do not expect to be executed in the "real world"
        Are you saying that you do not expect a historical order to be placed? or that you do not expect a Realtime order to be placed? I am not certain how to understand this statement, can you clarify what you mean by "real world" here? Are you seeing a live order being placed instead of a historical order or something else?

        I just pretend to create a strategy position to match with an account position that is already open in the "real world". If this "fake" order is executed then it would duplicate the real world position and, of course, I have to avoid it.
        If you are using order methods, I would expect that orders are submitted either in historical or realtime when called, are you expecting to only calculate your position but not place any orders in historical data?

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

        Comment


          #5
          I'll try to explain in another way.

          When I am using NT7 this is the scenario:

          - When executing a strategy, this one opens a new position. At this point I have a strategy position and an account position that match.

          - If I need to stop this strategy, for any reason that here is irrelevant, the strategy position disappears but the account position is active in the broker account.

          - If I restart the strategy again there will be an account position but the strategy position will not exist. In that case I cannot do the follow up of the position to decide when I close it.

          - To avoid it in NT7, I set a code in the strategy that is executed when it is still processing historical data to create a strategy position that matches with the account position. All the information is read from a database because in NT7 I cannot read the account position in the broker from a strategy.

          I want to reproduce it in NT8 but when using the code:

          MyOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market,MyQuantity, 0, 0, "", "MyOrder");

          No strategy position is created.

          When executing this code during the process of historical data no account position should be created. I insist, the aim is to create a strategy position to match an account position that already exists.

          But the same that I do in NT7 doesn't work in NT8.

          I hope it helps

          Comment


            #6
            This is what could originate problem: "An order placed at '22/01/2018 1:00:00' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met."

            But if I set the code:

            if (CurrentBar < BarsRequiredToTrade)
            {
            return;
            }

            then it will execute the code when receiving real-time data and this will duplicate the account position. It's not what I am looking for.

            Comment


              #7
              Ok. Solved. This was the solution.

              Thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by elirion, Today, 01:36 AM
              0 responses
              2 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by gentlebenthebear, Today, 01:30 AM
              0 responses
              2 views
              0 likes
              Last Post gentlebenthebear  
              Started by samish18, Yesterday, 08:31 AM
              2 responses
              9 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by Mestor, 03-10-2023, 01:50 AM
              16 responses
              389 views
              0 likes
              Last Post z.franck  
              Started by rtwave, 04-12-2024, 09:30 AM
              4 responses
              31 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Working...
              X