Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TrailStop

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

    TrailStop

    Hi
    I am having a problem setting a trailing stop in a strategy could you take a look at the attached code and give any pointers as to where the problem lies.What i am trying to achieve is as follows; upon entry an initial stop is placed 1 tick below the last bar this part seems ok.When price has moved 5 ticks past the entry point i want to move the stop to breakeven + 4 ticks.If the trade is still alive at the close of this bar and the following one the stop loss is then moved 1 tick below the low of this bar and each successive bar after.Sorry if my explanation is not clear i have attached a screenshot with notations that should help.Also attached is the code any help you can give would be much appreciated Thanks
    Attached Files

    #2
    ohjob, unfortunately we could not debug this code for you, but generally your visual approach is good as it simplifies the debug work needed. I would ensure to print every bars info along with the current stop price and also incluce prints from which code section the stop price modification was triggered from - you can then review what event sequence leads to the unexpected stop price defined.

    Comment


      #3
      Trail stop

      Hi Bertrand, Thank you for your quick reply, is it possible to directly send you the complete strategy with indicators. I have added print statements in the relevant positions throughout the strategy, but i am still not clear as to why the strategy is not working. I am reasonably new to C# NT and trading, but i have worked as a programmer for some years.

      Regards

      ohjob

      Comment


        #4
        ohjob, if you'd like me to give the strategy a run here please contact me directly at support at ninjatrader dot com to my Attn.

        I'm not sure if you're already familiar with it, but TraceOrders is a very helpful tool available to you as well to better understand your strategy's behavior seen :

        Comment


          #5
          Originally posted by ohjob View Post
          Hi
          I am having a problem setting a trailing stop in a strategy could you take a look at the attached code and give any pointers as to where the problem lies.What i am trying to achieve is as follows; upon entry an initial stop is placed 1 tick below the last bar this part seems ok.When price has moved 5 ticks past the entry point i want to move the stop to breakeven + 4 ticks.If the trade is still alive at the close of this bar and the following one the stop loss is then moved 1 tick below the low of this bar and each successive bar after.Sorry if my explanation is not clear i have attached a screenshot with notations that should help.Also attached is the code any help you can give would be much appreciated Thanks
          You seem to have mixed SetTrailStop() method with ExitLongStop() and ExitShortStop(). As we cannot cancel SetStop()s, in effect your SetTrailStop() is always active. I am not sure that your Exit() orders are even being accepted. You may want to use TraceOrders to find out what is really going on.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          656 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X