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

Setup a trail stop in wizard strategy

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

    Setup a trail stop in wizard strategy

    Hello,

    In my strategy, I want to setup a trail stop when my position is in positive for example a 0.90% percent since the entry and put the trail stop in a 0.10%

    How I can put the trail stop when is in positive?


    Thanks and regards.

    #2
    Hello ziquillo,
    Thanks for posting today.

    You can use the GetProfitLoss() method to determine your current profit or loss for the current position.

    Here is a link to the GetProfitLoss() method documentation from the online help guide. http://ninjatrader.com/support/helpG...profitloss.htm

    Then when the specific condition is met you can use the SetTrailStop() to set your trailing stop at that point.

    Here is a link to SetTrailStop() method documentation from the online help guide. http://ninjatrader.com/support/helpG...ttrailstop.htm

    Please let us know if we may be of further assistance for anything NinjaTrader.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alex,

      But how I can use GetProfitLoss and SetTrailStop in wizard strategies?

      Is there some example without touch the code directly?



      Thanks and regards.

      Comment


        #4
        Hello ziquillo,
        Thanks for the reply.

        This will not be able to be done within the strategy wizard.

        The strategy wizard applies profit targets, trailing stops, and stop losses only to the Initialize method and this would not allow you to set the trailing stop based on a conditional statement within the OnBarUpdate.

        However, you could use the strategy wizard to set most of your conditions and then unlock the code to manually move the trailing stop to a conditional statement based on your unrealized PnL.

        Please let us know if we may be of further assistance for anything NinjaTrader.
        Alex G.NinjaTrader Customer Service

        Comment


          #5
          trailing stop

          looks like this in view code is this correct for after entry long or short that the stop market order will trail by 7 ticks for every price move of 1 new tick

          protected override void Initialize()
          {
          SetTrailStop("NewTrendwithMOMO", CalculationMode.Ticks, 7, false);

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()

          Comment


            #6
            Hello RicRules,

            Yes, based your example, each new entry named "NewTrendwithMOMO" will have a 7 tick trailing stop.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Board game geek, Yesterday, 02:20 AM
            2 responses
            21 views
            0 likes
            Last Post Board game geek  
            Started by jackiegils, Yesterday, 11:05 PM
            0 responses
            5 views
            0 likes
            Last Post jackiegils  
            Started by cre8able, 05-09-2024, 09:15 PM
            2 responses
            17 views
            0 likes
            Last Post cre8able  
            Started by Trader146, Yesterday, 09:17 PM
            0 responses
            10 views
            0 likes
            Last Post Trader146  
            Started by ttrader23, 05-08-2024, 09:04 AM
            9 responses
            44 views
            0 likes
            Last Post ttrader23  
            Working...
            X