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

Position management. Portfolio

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

    #16
    Reverse position

    Hello.
    EOD data. Strategy Analyzer.
    Need to reverse position. Is it possible to close long position and open short in one bar? As I understand, this mean to exit long position by market and let short order to be placed in market.

    Comment


      #17
      Alexstox,

      If you are using the Managed Approach you can use EnterShort() for your long position. This will close the long position and enter you into a short position.
      Cal H.NinjaTrader Customer Service

      Comment


        #18
        Originally posted by NinjaTrader_Cal View Post
        Alexstox,

        If you are using the Managed Approach you can use EnterShort() for your long position. This will close the long position and enter you into a short position.
        Message in CC Log tab
        An Enter() method to submit an entry order at '09.12.2005 22:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

        Click image for larger version

Name:	reverse order.PNG
Views:	1
Size:	12.0 KB
ID:	870862

        Comment


          #19
          Alexstox,

          You will want to use TraceOrders to help in debugging your script.

          Put TraceOrders = true; in your Initialize()

          This will print out to your Output window, Tools -> Output window
          Cal H.NinjaTrader Customer Service

          Comment


            #20
            Originally posted by NinjaTrader_Cal View Post
            Alexstox,
            You will want to use TraceOrders to help in debugging your script.
            Put TraceOrders = true; in your Initialize()
            This will print out to your Output window, Tools -> Output window

            07.12.2005 22:00:00 Entered internal PlaceOrder() method at 07.12.2005 22:00:00: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1,1590 SignalName='trail1' FromEntrySignal='Long1'
            07.12.2005 22:00:00 Entered internal PlaceOrder() method at 07.12.2005 22:00:00: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=1 LimitPrice=1,2467 StopPrice=0 SignalName='targetOrder1' FromEntrySignal='Long1'
            09.12.2005 22:00:00 Entered internal PlaceOrder() method at 09.12.2005 22:00:00: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1,1712 SignalName='Short1' FromEntrySignal=''
            09.12.2005 22:00:00 Ignored PlaceOrder() method at 09.12.2005 22:00:00: Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1,1712 SignalName=Short1' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
            **NT** An Enter() method to submit an entry order at '09.12.2005 22:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

            Comment


              #21
              Alex,

              More than likely you have a working order for long while you trying to submit the short order, thus causing the internal rules to ignore it.

              http://www.ninjatrader.com/support/h...d_approach.htm
              Cal H.NinjaTrader Customer Service

              Comment


                #22
                Originally posted by NinjaTrader_Cal View Post
                Alex,

                More than likely you have a working order for long while you trying to submit the short order, thus causing the internal rules to ignore it.

                http://www.ninjatrader.com/support/h...d_approach.htm
                Did I understand you carefully? This mean there are opened long position and working long order simultaneously? And I should null this opened long order. Well, I think this happen because long order did not have time to close, because I null all orders in OnExecution() in the end of script. Please advise what to do.

                Comment


                  #23
                  Alexstox,

                  There are rules there as well that would interfere with this, such as using SetStopLoss() or having an ExitLong() order sitting.

                  Do you have either of these in your script?
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by NinjaTrader_Cal View Post
                    Alexstox,
                    There are rules there as well that would interfere with this, such as using SetStopLoss() or having an ExitLong() order sitting.
                    Do you have either of these in your script?
                    Short construction of my script
                    Code:
                    [SIZE="2"]Variables
                     protected override void Initialize()
                            {
                    [B]EntriesPerDirection = 1; [/B]
                    [B]EntryHandling = EntryHandling.UniqueEntries;[/B]
                    [B]There are 3 unique entries possible for long and 3 for short[/B]
                    indicators and additional data series}
                    protected override void OnBarUpdate()
                            {
                    lots of additional conditions
                    
                    BarsInProgress==0
                    extra trails exits and changes for long positions
                    long positions rules
                    trails exits for long positions
                    
                    extra trails exits and changes for short positions
                    short positions rules
                    trails exits for short positions
                    
                    protected override void OnExecution(IExecution execution)
                            {stops, null orders, exits}[/SIZE]
                    So, as I understand, in OnBarUpdate() short is ready to go, but can't because long order will null later in OnExecution(). What you think?

                    Comment


                      #25
                      Alexstox,

                      What kind of orders are these Trail stops that you are using and are they being placed when you enter Long?
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #26
                        Originally posted by alexstox View Post
                        Message in CC Log tab
                        An Enter() method to submit an entry order at '09.12.2005 22:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

                        [ATTACH]29492[/ATTACH]
                        You cannot reverse on the same bar if you have protective orders on the position. This has been discussed many times in the forum.

                        You might want to read this rather long, sometimes contentious thread, to understand all the gory details that came out, when we discussed this very issue earlier.

                        ref: http://www.ninjatrader.com/support/f...d.php?p=241778

                        Comment


                          #27
                          Originally posted by NinjaTrader_Cal View Post
                          Alexstox,
                          What kind of orders are these Trail stops that you are using and are they being placed when you enter Long?
                          Long position created 1 bar earlier. So, this bar Long is opened with Profit order and StopLoss order. And script try to enter short. And even can't place an order.

                          Comment


                            #28
                            Alexstox,

                            This is because you have working protective orders as Koganam pointed out.

                            Since, you have these orders working for your long position the EnterShort() orders are going to get ignored.
                            Cal H.NinjaTrader Customer Service

                            Comment


                              #29
                              Originally posted by NinjaTrader_Cal View Post
                              Alexstox,
                              This is because you have working protective orders as Koganam pointed out.
                              Since, you have these orders working for your long position the EnterShort() orders are going to get ignored.
                              So, is it possible to exit protective orders and enter short?

                              Comment


                                #30
                                You will need to either wait for the exit orders to get filled or you will need to cancel them and place a EnterShort()
                                Cal H.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by geddyisodin, 04-25-2024, 05:20 AM
                                8 responses
                                58 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by jxs_xrj, 01-12-2020, 09:49 AM
                                4 responses
                                3,285 views
                                1 like
                                Last Post jgualdronc  
                                Started by Option Whisperer, Today, 09:55 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post Option Whisperer  
                                Started by halgo_boulder, 04-20-2024, 08:44 AM
                                2 responses
                                22 views
                                0 likes
                                Last Post halgo_boulder  
                                Started by mishhh, 05-25-2010, 08:54 AM
                                19 responses
                                6,189 views
                                0 likes
                                Last Post rene69851  
                                Working...
                                X