Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do you reset the stoploss price/offset value?

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

    How do you reset the stoploss price/offset value?

    In the help it says

    "Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position"

    How does one reset the value?

    thanks

    #2
    Ninjamouse,

    For example, before you open a new order you would use SetStopLoss(default).

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi

      Thanks for replying to me, you see I have this code:

      protectedoverridevoid Initialize()
      {
      SetProfitTarget(
      "", CalculationMode.Ticks, 5);
      CalculateOnBarClose = true;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      if (Position.MarketPosition == MarketPosition.Flat)
      {

      SetStopLoss(CalculationMode.Ticks,
      1);

      if (Open[3] == High[3] && enterShort == false)
      {
      SetStopLoss(CalculationMode.Ticks, High[
      0]);
      EnterShortLimit(DefaultQuantity, Open[0], "");
      enterShort = true;
      enterLong =
      false;
      }
      if (Close[3] == High[3] && enterLong == false)
      {
      SetStopLoss(CalculationMode.Ticks, Low[
      0]);
      EnterLongLimit(DefaultQuantity, Open[0], "");
      enterShort = false;
      enterLong =
      true;
      }
      }

      my stoploss never gets hit instead I get a HUGE stop loss. Would you know whats wrong?

      thanks

      Comment


        #4
        Ninjamouse,

        I see nothing wrong immediately with this. What sort of large stop loss are you getting?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by ninjamouse View Post
          Hi

          Thanks for replying to me, you see I have this code:

          protectedoverridevoid Initialize()
          {
          SetProfitTarget(
          "", CalculationMode.Ticks, 5);
          CalculateOnBarClose = true;
          }
          ///<summary>
          /// Called on each bar update event (incoming tick)
          ///</summary>
          protectedoverridevoid OnBarUpdate()
          {
          if (Position.MarketPosition == MarketPosition.Flat)
          {

          SetStopLoss(CalculationMode.Ticks,
          1);

          if (Open[3] == High[3] && enterShort == false)
          {
          SetStopLoss(CalculationMode.Ticks, High[
          0]);
          EnterShortLimit(DefaultQuantity, Open[0], "");
          enterShort = true;
          enterLong =
          false;
          }
          ...
          }

          my stoploss never gets hit instead I get a HUGE stop loss. Would you know whats wrong?

          thanks
          Emphasis mine. Let us assume that you are using /ES and the price High[0] is 1257. Your coding is asking for a StopLoss of 1257 ticks! Whew! If you want to use a price as a StopLoss, then you should code using the CalculateMode.Price syntax. A price is a price; a tick is a tick,

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X