Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to chart a stop-loss when in position

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

    How to chart a stop-loss when in position

    Hi All,

    I was wondering if there is a way to plot a traling stoploss on my chart once the following strategy is in position (long):

    Code:
     
    if (Position.MarketPosition == MarketPosition.Flat )
    {
      SetTrailStop("Trailing Stop", CalculationMode.Ticks, 0.01 * ATR(10)[0]);
      EnterLong()
    }
    I thought about using DrawLine, but I am not sure this makes sense. Any suggestions? Basically I want to see the trailing stop on my chart ONLY when I have an open position

    #2
    sburtt, yes you could capture the stop loss / trail stop amendments in the OnOrderUpdate() and then use the stopprice for example in a drawing method as value to visualize -

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      sburtt, yes you could capture the stop loss / trail stop amendments in the OnOrderUpdate() and then use the stopprice for example in a drawing method as value to visualize -

      http://www.ninjatrader.com/support/f...ead.php?t=5790
      I will try this later today, I was hoping in something more simple like adding a condition like this:

      Code:
       
      if (Position.MarketPosition == MarketPosition.Long)
      {
        Print(Trailing Stop + ";")
        }
      would this code work or doesn't it make sense?
      Forgive me

      Comment


        #4
        No worries - this would unfortunately not be sufficient here. As you would need an object / variable first that would track the trail stop current price, so you could then access, print or visualize it in the next step. The Set() methods are convenient to work with, but would not expose such detailed info per default - hence the technique from the reference I posted would be needed to bridge this gap.

        Comment


          #5
          Originally posted by sburtt View Post
          I will try this later today, I was hoping in something more simple like adding a condition like this:

          Code:
           
          if (Position.MarketPosition == MarketPosition.Long)
          {
            Print(Trailing Stop + ";")
            }
          would this code work or doesn't it make sense?
          Forgive me
          You know the TrailingStop price. Just track it however you will.

          Code:
           
          TStopPrice = Math.Max(TStopPrice, (Close[0] - TrailStopTicks * TickSize));

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          85 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          47 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X