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

Moving stoploss

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

    Moving stoploss

    Hello,

    I am coding a trend following strategy.
    I enter the trades manually, when my strategy tells me that my condition have been met.
    However, i wish for the strategy to manage my orders after my manual entry.
    My logic: if in uptrend and the stochastic indicator crosses above 20. Move my stop( that i set myself based on current market volatility) 5 ticks below that low of the bar that triggered the stochastic cross. Is something like this possible?
    If so, can someone help?

    #2
    Hello mikethelen, and thank you for your question.

    NinjaScript can be thought of as a C# library, and so it is possible for you as a coder to extend your strategy using C# to accomplish your goal. We do not have documentation for this approach, and NinjaScript does not directly support managing user placed orders.

    Please let us know if there are any other ways we may help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for clarifying that for me. Would moving my stop with the stochastic indicator be possible if the order and the stoploss were set by my strategy and not by me?

      Thank you

      Comment


        #4
        Hi mikethelen,

        I have done the same idea, but not for moving stops. You can do as follows: when stochastics crosses 20/80 set a bool true and store the low/high to a double. Then with your conditon or the bool (that is true from the moment of cross) you make (if you use setstoploss):

        SetStopLoss("long", CalculationMode.Price, double "X"-5*TickSize, false);
        or
        SetStopLoss("short", CalculationMode.Price, double "A"+5*TickSize, false);

        But I think you should be able to do it more easily when cross occurs then do

        SetStopLoss("long", CalculationMode.Price, Low[0]-5*TickSize, false);

        Hope that helps (and it is not wrong, because I´m not a programmer, but have done so)
        Tony

        Comment


          #5
          This can easily be accomplished in NinjaTrader. This code example would move a stop loss order to the stochastics K value for a stochastics indicator with a 3 period D series, 14 period K series, and smoothing value of 7.

          Code:
          [FONT=Courier New]protected override void OnBarUpdate()
          {
              SetStopLoss([/FONT][FONT=Courier New]Stochastics(3, 14, 7).K[0]);
          }[/FONT]
          Jessica P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by adeelshahzad, Today, 03:54 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          7 responses
          32 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by merzo, 06-25-2023, 02:19 AM
          10 responses
          823 views
          1 like
          Last Post NinjaTrader_ChristopherJ  
          Started by frankthearm, Today, 09:08 AM
          5 responses
          21 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          43 views
          0 likes
          Last Post jeronymite  
          Working...
          X