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

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.
    BertrandNinjaTrader Customer Service

    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 :

        BertrandNinjaTrader Customer Service

        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 dniezby, Today, 04:50 PM
          0 responses
          4 views
          0 likes
          Last Post dniezby
          by dniezby
           
          Started by dbennett3, Today, 04:21 PM
          0 responses
          2 views
          0 likes
          Last Post dbennett3  
          Started by GKonheiser, 09-23-2014, 08:25 AM
          2 responses
          1,500 views
          0 likes
          Last Post PaulMohn  
          Started by MiCe1999, Yesterday, 10:41 AM
          8 responses
          21 views
          0 likes
          Last Post MiCe1999  
          Started by EB Worx, 03-07-2023, 05:05 AM
          6 responses
          114 views
          1 like
          Last Post cls71
          by cls71
           
          Working...
          X