Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting "fake" positions with unmanaged orders

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

    Setting "fake" positions with unmanaged orders

    I switched to unmanaged orders. Everything went fine except a point.

    I'm working with IB and every day it auto logs off. If I keep overnight positions I need a way to set a position on the strategy to match the real position.

    When I worked with managed positions it was easy. When the historical bar matched with the time and date of the real entered position I launched an market order that appeared on the strategy but it didn't send a real enter order on the market.

    With unmanaged when I send a SubmiOrder, even in an historical bar it sends a real market order. Thus, I'm duplicating the real position on the market.

    Any hint on how to set an historical strategy position on unmanaged orders without sending a real market order?

    #2
    guillembm, are you sure the SubmitOrder call was then done on historical bar for your script? Just tested quickly here and did not see an issue submitting a SubmitOrder() on a historical CurrentBar for example to add a strategy position...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      This is the code I use:

      if (ToDay(Time[0]) == EnterDate && ToTime(Time[0]) == EnterTime)
      {
      MyOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, NumContracts, 0, 0, "", "");
      }

      EnterDate and EnterTime are historical bars for sure. I set prints to check if this was correct and when the historical bar executes it does the submit but it always sends the real order

      Comment


        #4
        If you include a print to historical then, what would it return at the time of the SubmitOrder() call?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Sorry I think I don't understand your question.

          In the text of the print I just include Print("Enter order");

          The submit is executed for sure at the historical bar but it always send a live order.

          Comment


            #6
            Historical is a property in NinjaScript that tells you if you're processing live bars or not :



            Please include this in your prints to doublecheck you're not submitting on a realtime bar accidentially.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I'm sure this doesn't happen.

              I converted the same project again to managed and it does the right thing.

              Comment


                #8
                I'll try to make another simple strategy only with a simple submit with unmanaged to see if it works.

                Comment


                  #9
                  Yes, please do that - just create a basic script in unmanaged that would submit on a historical bar or yesterday...then set ExitOnClose to false and apply it on Sim101 - do you see any orders submitted in realtime?
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hi, I also have experienced this.
                    An unmanaged strategy placed a live order at IB from a historical bar, 3 bars from the right hand side of the chart. The order was a stop entry order, not yet filled by the end of the chart.

                    Attached is a snapshot of the chart. The large green bar 3rd from right is the bar ending at 12:30.
                    This time matches the time in the Output Window as when a trading signal and what should have been a virtual order should have been created.

                    10/30/2012 3:00:00 PM Cancelled order due to end of session handling:
                    BarsInProgress=0: Order='NT-00054/DU122562' Name='LBE1' State=Cancelled Instrument='ZC 12-12' Action=Buy Limit price=0 Stop price=763.75
                    Quantity=1 Strategy='RelTechSlicerSystem2LIVE' Type=Stop Tif=Gtc Oco='d25288fbbb184d41be27301e059f5acd' Filled=0 Fill price=0 Token='67da9c28e8094276a1882092cfa9ad54' Gtd='12/1/2099 12:00:00 AM'
                    10/31/2012 12:30:00 PM ZC 12-12 placing long breakout order at 763.75
                    10/31/2012 12:30:00 PM Entered internal SubmitOrder() method at 10/31/2012 12:30:00 PM: Action=Buy OrderType=Stop Quantity=1 LimitPrice=763.75 StopPrice=763.75 OcoId='7ec8478e27ea42c49e8f17d53382c5f3' Name='LBE1'


                    Yet it became a live order at IB when the strategy was launched at 9:14:44 (outside of the session template hours). Here is the information from the Log tab of the Control Centre.

                    10/31/2012 9:14:44 PM Order Order='2033295281/DU122562' Name='LBE1' New state=Accepted Instrument='ZC 12-12' Action=Buy Limit price=0 Stop price=763.75 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
                    10/31/2012 9:14:43 PM Order Order='NT-00055/DU122562' Name='LBE1' New state=PendingSubmit Instrument='ZC 12-12' Action=Buy Limit price=0 Stop price=763.75 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''


                    Sync Account position is False.
                    Wait Until Flat Before Executing Live is True.
                    Ninja version is .10

                    Let me know how I can assist further in an inquiry.
                    Cheers,
                    saltminer
                    Attached Files

                    Comment


                      #11
                      Thanks saltminer, this should have been cancelled by the end of session handling as your prior order shows - which session template is used on the ZS 120 min chart here so I could look into reproducing?
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Hi,
                        Attached is screenshot of the session template. Template uses Central Time, while the computer was set to Eastern Time (USA). Bars are 120 minute on ZC.
                        saltminer
                        Attached Files

                        Comment


                          #13
                          I solved the problem (after trying everything) reinstalling NT. When technology fails, restart it.

                          Silly but it works.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by yertle, Yesterday, 08:38 AM
                          7 responses
                          28 views
                          0 likes
                          Last Post yertle
                          by yertle
                           
                          Started by bmartz, 03-12-2024, 06:12 AM
                          2 responses
                          21 views
                          0 likes
                          Last Post bmartz
                          by bmartz
                           
                          Started by funk10101, Today, 12:02 AM
                          0 responses
                          5 views
                          0 likes
                          Last Post funk10101  
                          Started by gravdigaz6, Yesterday, 11:40 PM
                          1 response
                          9 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by MarianApalaghiei, Yesterday, 10:49 PM
                          3 responses
                          11 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Working...
                          X