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 -

    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 kevinenergy, 02-17-2023, 12:42 PM
          118 responses
          2,778 views
          1 like
          Last Post kevinenergy  
          Started by briansaul, Today, 05:31 AM
          0 responses
          9 views
          0 likes
          Last Post briansaul  
          Started by traderqz, Yesterday, 12:06 AM
          11 responses
          28 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by PaulMohn, Today, 03:49 AM
          0 responses
          8 views
          0 likes
          Last Post PaulMohn  
          Started by inanazsocial, Today, 01:15 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Jason  
          Working...
          X