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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    89 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X