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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          52 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          142 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X