Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing Stop Not Working

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

    Trailing Stop Not Working

    Hi,

    Something weird is happening. Regular stop losses work fine, but with absolutely zero changes in my code other than changing 'SetStopLoss' to 'SetTrailStop', the backtesting just stops working.

    Attached are screenshots of me using a 20% stop loss and a 20% trailing stop.

    As you can see, the regular stop loss works fine, triggering at 20%, but the trailing stop for some weird reason triggers on the same bar every single time.

    No idea why this is happening.

    Thanks for any help.
    Attached Files

    #2
    Hello zuhayr123,

    Thanks for your post.

    Please post your strategy or a sample that demonstrates the issue so we can test. If you do not wish to post publicly, please feel free to send to PlatformSupport[at]NinjaTrader[dot]Com In the subject line add Atten: Paul and a link to this thread.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello zuhayr123,

      Thanks for your post.

      Please post your strategy or a sample that demonstrates the issue so we can test. If you do not wish to post publicly, please feel free to send to PlatformSupport[at]NinjaTrader[dot]Com In the subject line add Atten: Paul and a link to this thread.
      Hi, thanks for the reply. Here is an example of my code (Bars Array 0 is a 15 minute data-set):

      #region Variables
      private double startingCash = 20000;
      private bool crossDown = true;
      #endregion

      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      Add("ABCD", PeriodType.Day, 1);
      Add("EFGH", PeriodType.Day, 1);
      SetTrailStop(CalculationMode.Percent, 0.2);
      }

      protected override void OnBarUpdate()
      {
      if (BarsInProgress == 0)
      {
      if (CrossBelow(EMA(BarsArray[1], 9), EMA(BarsArray[1], 20), 1))
      {
      crossDown = true;
      }

      bool entryCondition =
      (CrossAbove(EMA(BarsArray[1], 20), EMA(BarsArray[1], 40), 10)) &&
      (EMA(BarsArray[1], 20)[0] > EMA(BarsArray[1], 40)[0]) &&
      (Closes[2][0] > EMA(BarsArray[2], 50)[0]) &&
      (crossDown);
      double ql = ((startingCash)*0.95)/Close[0];
      int quantL = (int)ql;

      if ((entryCondition) && (Position.MarketPosition == MarketPosition.Flat))
      {
      crossDown = false;
      EnterLong(quantL, "Open Long");
      }
      }
      }

      Comment


        #4
        Hello zuhayr123,

        Thanks for your reply.

        What instrument are you using when looking at a 20% trailing stop or 20% stop loss?

        What is your setting for exit On Close, true or false?

        Can you post a chart that shows the trailing stop exiting on the same bar?
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello zuhayr123,

          Thanks for your reply.

          What instrument are you using when looking at a 20% trailing stop or 20% stop loss?

          What is your setting for exit On Close, true or false?

          Can you post a chart that shows the trailing stop exiting on the same bar?
          Hi,

          Instrument is UVXY.

          exit on close is False.

          Attached is the chart with one of the trades.

          Thanks,

          Zuhayr
          Attached Files

          Comment


            #6
            Hello zuhayr123,

            Thank you for your response.

            In testing I cannot reproduce the behavior and only errors when the bar's update.
            May we schedule a support with you? Please send a note to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H - 1548531' in the subject line, include a time that works best for you and a phone number we may reach you at.

            Comment


              #7
              Originally posted by NinjaTrader_Paul View Post
              Hello zuhayr123,

              Thanks for your post.

              Please post your strategy or a sample that demonstrates the issue so we can test. If you do not wish to post publicly, please feel free to send to PlatformSupport[at]NinjaTrader[dot]Com In the subject line add Atten: Paul and a link to this thread.
              Hi, I tried the strategy with different instruments. The trailing stop works for all instruments except UVXY. I think it may have something to do with the reverse split that occurred today messing up Kinetick data. This exact script was working fine before today in the early morning. I have tried resetting data and instruments but that didn't seem to work.

              Is there any other way to reset instruments? I think it would work if I did that.

              Thank you.
              Last edited by zuhayr123; 07-25-2016, 06:21 PM.

              Comment


                #8
                Hi, I was looking around the forums and it seems that this is not the first time this has happened.

                Please see this post. This person was experiencing exactly what I was:



                I have done everything to update the chart for the split and it is now current, but the trailing stop is still broken.

                Is there a simple way to fix it or would we need to schedule a call?

                Thank you,

                Zuhayr

                Comment


                  #9
                  Hello zuhayr123,

                  Thank you for your response.

                  I do not believe this is related to the split. Please send a note to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H - 1548531' in the subject line, include a time that works best for you and a phone number we may reach you at.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Haiasi, 04-25-2024, 06:53 PM
                  2 responses
                  17 views
                  0 likes
                  Last Post Massinisa  
                  Started by Creamers, Today, 05:32 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Creamers  
                  Started by Segwin, 05-07-2018, 02:15 PM
                  12 responses
                  1,786 views
                  0 likes
                  Last Post Leafcutter  
                  Started by poplagelu, Today, 05:00 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post poplagelu  
                  Started by fx.practic, 10-15-2013, 12:53 AM
                  5 responses
                  5,408 views
                  0 likes
                  Last Post Bidder
                  by Bidder
                   
                  Working...
                  X