Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Closing a Partial Position using an Exit Method

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

    Closing a Partial Position using an Exit Method

    I enter with 2 contracts and after the first exit with 1 contract, the second exit is ignored by NT.
    Here's a log summary:

    Enter for 2 contracts: Order Status: Order='f875f3c7e1cd45e5a6ae7f1393b6ae71/Replay101' Name='Buy' New state=Initialized Instrument='xxxxx' Action=Buy Limit price=0 Stop price=0 Quantity=2 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''

    Then the first exit which is executed: Issued Exit Order for: 1 Contracts
    Order Status: GenericTracker: Order='f12325f180544c1593068fb9fa745500/Replay101' Name='Sell' New state=Initialized Instrument='xxxxx' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''


    Then the second exit which is not executed: Issued Exit Order for: 1 Contracts
    But no order is present ...

    #2
    Hello epcompany,

    Thank you for your post.

    Can you provide your .cs file for the strategy and your log and trace files to support[at]ninajtrader[dot]com with 'ATTN: Patrick - 1069304' in the subject line?

    You will find your strategy in the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Strategy. You can send your log and trace files by going to the Control Center-> Help-> Mail to Support.

    Comment


      #3
      strategy structure is pretty generic ...

      protected override void OnBarUpdate()
      {
      if (this.Position.MarketPosition == MarketPosition.Long)
      {

      //__________________________________________________ __________________________________________________ ______
      // Begin UP exit tests
      if (EvaluateUpExit(this.Time[0]))
      {
      // Exit Long
      _entryOrder = this.ExitLong(_numberOfContractsExited);
      Print("Issued Exit Order for: " + _numberOfContractsExited.ToString() + " Contracts" );

      }
      }
      // End UP exits

      //__________________________________________________ ______________
      // Begin DOWN exit tests
      if (this.Position.MarketPosition == MarketPosition.Short)
      {
      if (EvaluateDownExit(this.Time[0]))
      {
      // exit short ...
      _entryOrder = this.ExitShort(_numberOfContractsExited);
      Print("Issued Exit Order for: " + _numberOfContractsExited.ToString() + " Contracts");

      }
      }


      //__________________________________________________ ______________
      // Begin entry tests
      if (this.FirstTickOfBar)
      {
      if (this.Position.MarketPosition == MarketPosition.Flat)
      {
      // Enter an UP trade
      if (EvaluateUpTrade(this.Time[0]))
      {

      // reset stop loss before entering ...
      this.SetStopLoss(CalculationMode.Ticks, 20);

      // enter the up trade ...
      _entryOrder = this.EnterLong(_numberOfContractsTraded);
      }

      // Enter a DOWN trade
      if (EvaluateDownTrade(this.Time[0]))
      {
      // reset stop loss before entering ...
      this.SetStopLoss(CalculationMode.Ticks, 20);

      // enter the down trade ...
      _entryOrder = this.EnterShort(_numberOfContractsTraded);
      }
      }
      } //End First Tick of Bar
      }

      Comment


        #4
        Hello epcompany,

        Thank you for your response.

        So I may investigate this matter further can you provide your log and trace files to support[at]ninajtrader[dot]com with 'ATTN: Patrick - 1069304' in the subject line?

        Comment


          #5
          Originally posted by epcompany View Post
          protected override void OnBarUpdate()
          {
          if (this.Position.MarketPosition == MarketPosition.Long)
          {

          //__________________________________________________ __________________________________________________ ______
          // Begin UP exit tests
          if (EvaluateUpExit(this.Time[0]))
          {
          // Exit Long
          _entryOrder = this.ExitLong(_numberOfContractsExited);
          Print("Issued Exit Order for: " + _numberOfContractsExited.ToString() + " Contracts" );

          }
          }
          // End UP exits

          //__________________________________________________ ______________
          // Begin DOWN exit tests
          if (this.Position.MarketPosition == MarketPosition.Short)
          {
          if (EvaluateDownExit(this.Time[0]))
          {
          // exit short ...
          _entryOrder = this.ExitShort(_numberOfContractsExited);
          Print("Issued Exit Order for: " + _numberOfContractsExited.ToString() + " Contracts");

          }
          }


          //__________________________________________________ ______________
          // Begin entry tests
          if (this.FirstTickOfBar)
          {
          if (this.Position.MarketPosition == MarketPosition.Flat)
          {
          // Enter an UP trade
          if (EvaluateUpTrade(this.Time[0]))
          {

          // reset stop loss before entering ...
          this.SetStopLoss(CalculationMode.Ticks, 20);

          // enter the up trade ...
          _entryOrder = this.EnterLong(_numberOfContractsTraded);
          }

          // Enter a DOWN trade
          if (EvaluateDownTrade(this.Time[0]))
          {
          // reset stop loss before entering ...
          this.SetStopLoss(CalculationMode.Ticks, 20);

          // enter the down trade ...
          _entryOrder = this.EnterShort(_numberOfContractsTraded);
          }
          }
          } //End First Tick of Bar
          }
          As currently written you cannot scale out without scaling in. This is a bug that NT has already acknowledged, but will not fix in the current iteration.

          More information is in this single post: http://ninjatrader.com/support/forum...61&postcount=3

          It is part of two pretty long discussions which show that, in NT7, one cannot scale out without scaling in.
          Last edited by koganam; 03-18-2016, 12:48 PM. Reason: Corrected link.

          Comment


            #6
            I'm not sure what the term scale out and scale in means? I enter into a 2 contract position, then exit 1 contract (market position is still not flat). Any calls to exit for 1 contract at this point are ignored by NT? is this the bug that you are referring to?

            Comment


              #7
              Originally posted by epcompany View Post
              I'm not sure what the term scale out and scale in means? I enter into a 2 contract position, then exit 1 contract (market position is still not flat). Any calls to exit for 1 contract at this point are ignored by NT? is this the bug that you are referring to?
              Scaling means not buying or selling your position all at once, but in pieces, usually as things go your way.

              ref: http://www.investopedia.com/terms/s/scale-out.asp

              So, yes, that is what I mean.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              647 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              368 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              571 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X