Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Target orders canceled when scaling in.

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

    Target orders canceled when scaling in.

    My custom strategy allows multiple profit targets and position scaling. The problem is that once a target order has filled the original contracts count, all other orders, including the stop loss order, are canceled, leaving the position still in the market without any targets or a stop.

    Here is an example scenario:
    • Go Long with three contracts, three target orders with one contract each, and a stop order.
    • Scale in a quantity of three more contracts while the position is not flat, updating each target to have two contracts.
    • The first target is hit, bringing the total of the target fills to two and reducing the total position size to four.
      • everything is still working as expected at this point
    • The second target is hit, which brings the target fills to four, one more than the original entry position of three.
      • This causes all other orders to cancel automatically, including the stop order, which is not what I want to happen.
    It does not matter how many target orders you have. I've tested up to five, and as soon as the original poison quantity is hit, all other orders are canceled. It can be the first order, second, third, or fourth that cancels all other orders. The magic is based on the original entry position count being filed by a target order.

    Is there a way to increment this total position size when scaling in so that my orders are not canceled before I want them to be canceled? Or do you have a suggested workaround?

    Thank You!
    Last edited by bojim; 09-30-2023, 04:37 PM.

    #2
    Strategy->Properties->Entry handling-> change to 'unique entries' not 'all entries'

    I will include an attachment with Rithmic Friendly Examples also. You will want to look at the 'Multiple Entries Example' it is in nullified coding which is similar to bools. Variables are null; until they aren't, which is like setting bools to false initially and then in the sets change the bools to true. You can also find more info on nullified coding on google search C# nullified coding.
    Attached Files

    Comment


      #3
      Hello bojim,

      Thanks for your post.

      Scaling into a position is controlled with the signal names of your strategy, and properties EntryHandling and EntriesPerDirection. This reference sample can help with scaling in and out of a strategy.
      https://ninjatrader.com/suppport/helpGuides/nt8/en-us/scaling_out_of_a_position.htm

      This sample can assist further with managing multiple exit/entry signals:
      https://ninjatrader.com/support/helpGuides/nt8/en-us/using_multiple_entry_exit_sign.htm\

      EntriesPerDirection and EntryHandling could be used to control the maximum number of entries allowed per direction while a position.

      If you set Entry Handling to EntryHandling.AllEntries, NinjaScript will process all entry order methods up to the maximum allowable entries set in the EntriesPerDirection property. For example, if you set EntriesPerDirection to 3 and use EntryHandling.AllEntries, up to a total of 3 entry orders will process.

      If you set Entry Handling to EntryHandling.UniqueEntries, NinjaScript will process order entry methods up to the maximum allowable entries set by the EntriesPerDirection property for each uniquely named entry. For example, if you have two entry order methods using unique signal names ("entry1" and "entry2"), set EntriesPerDirection to 3, and use EntryHandling.UniqueEntries, a maximum number of 3 entry orders will process for each uniquely named entry order (up to 3 orders for "entry1" and 3 orders for "entry2").

      EntriesPerDirection: https://ninjatrader.com/support/help...rdirection.htm

      EntryHandling: https://ninjatrader.com/support/help...ryhandling.htm​​​
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X