Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

reset stop loss set as a percent

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

    reset stop loss set as a percent

    Hello,

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

    How can you do this? I am backtesting a strategy but the trailing stop does not work properly. I suspect that this is my issue.

    #2
    Following my previous message, I do not understand why when I backtest my strategy the Trailing Stop triggers at my entryprice and does not follow the 2.5% I set. Would it come from the fact that I am backtesting on daily data? how can I adjust this?
    Last edited by Manuel17; 12-08-2015, 09:33 PM.

    Comment


      #3
      Hello Manuel17,

      Thanks for your posts.

      To answer your first post: If for example in one area you set to a 2.5% stop and then in another area you set it to a 1.5% stop, if the 1.5% stop was the last used, then it (SetTrailStop) will remain at 1.5% for your next entry. The helpguide is advising that if you have changed the trailstop in the code to remember to reset it (if you need to) to 2.5% in this example.

      To reset your trail stop when flat you can use the following example code:

      if (Position.MarketPosition == MarketPosition.Flat)
      {
      SetTrailStop(your settings in here); // reset trail stop to preferred value.
      }

      Here is the helpguide link on MarketPosition: http://ninjatrader.com/support/helpG...etposition.htm


      For your second post, please post the specific line of code where you are setting your trail stop. If you use CalculationMode.Ticks,and specify an appropriate amount of ticks, does the same thing occur?
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks Paul for your quick reply. I do not want to change the percentage dynamically, so I am going to use it in the Initialize section. Here is the code that I am using:

        protected override void Initialize()
        {
        CalculateOnBarClose = true;
        EntriesPerDirection = 1;
        ExitOnClose = false;
        EntryHandling = EntryHandling.AllEntries;
        Add (SMA(smalength));
        Add(MACD(12,26,9));
        MACD(12,26,9).Panel=2;

        MACDsignal = new DataSeries(this);
        RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;

        SetTrailStop(CalculationMode.Percent, trailingstop);


        }
        I am using this strategy on various instruments (currencies, commodities) and with daily data, so I want to set my trailing stop as a percentage, not on a tick basis.

        Comment


          #5
          Hello Manuel17,

          Thanks for your reply.

          Can you clarify what the specific value is that you are entering for the variable "trailingstop". Also, is the variable "trailingstop" an integer or a double type?
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            I use a double variable set at 0.025

            Comment


              #7
              Hello Manuel17,

              Could you post a screenshot showing the issue you are experiencing?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Hello Paul,

                Please kindly find attached a screenshot of my issue.

                Thanks,

                Manuel
                Attached Files

                Comment


                  #9
                  Hello Manuel17,

                  Thanks for your post.

                  Using the information provided I've not be able to replicate what you are seeing. At this point to resolve, please post your strategy code and settings used in the strategy analyzer. You may want to take a screen shot of the settings used.

                  If you would prefer not to post publicly, please fee free to send to PlatformSupport[at]NinjaTrader[dot]Com. In the subject line please use "Forum Post: reset stop loss set as a percentage, Atten Paul.
                  Paul H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by PaulMohn, Today, 05:00 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post PaulMohn  
                  Started by ZenCortexAuCost, Today, 04:24 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post ZenCortexAuCost  
                  Started by ZenCortexAuCost, Today, 04:22 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post ZenCortexAuCost  
                  Started by SantoshXX, Today, 03:09 AM
                  0 responses
                  16 views
                  0 likes
                  Last Post SantoshXX  
                  Started by DanielTynera, Today, 01:14 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post DanielTynera  
                  Working...
                  X