Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 jclose, Today, 09:37 PM
          0 responses
          6 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,414 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          11 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          11 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X