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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    29 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    46 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X