Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Taking off half of my position deleted the entire trailing stop

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

    Taking off half of my position deleted the entire trailing stop

    Hello.... I have the following code that takes half my position off after a number of ticks in profit
    The number of ticks is "IWantHalf"

    The problem is... when I do that it deletes my trailing stop entirely instead of just modifying the quantity.

    Do I need to re-establish a trail stop after selling half of my position?

    Thank you.

    if (IWantHalf > 10
    && Positions[1].MarketPosition != MarketPosition.Flat
    && Positions[1].Quantity > DefaultOrderQuantity
    && Positions[1].Quantity >= 2
    )
    {
    if ( //down candle X above price
    Closes[0][0] > Positions[1].AveragePrice - Convert.ToDouble(IWantHalf / TickSize)
    && Closes[0][0] < Opens[0][0]
    )
    {
    Print("Price reached "
    + IWantHalf.ToString()
    + " above entry price of "
    + Positions[1].AveragePrice.ToString());
    Print("Take off this many: " + Convert.ToInt32(Positions[1].Quantity/2).ToString());

    ExitLong(1,Convert.ToInt32(Positions[1].Quantity/2), "","");
    }
    }​

    #2
    Hello halgo_boulder,

    Thanks for your post.

    It sounds like to are looking to scale out of a position in your strategy.

    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
    <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, Yesterday, 05:17 AM
    0 responses
    63 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X