• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Activate Trail after Target#1

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

    Activate Trail after Target#1

    Hi,

    Through Strategy Builder I am able to create 4 Market orders with 3 separate Targets and 4 trailing stops... Currently, the trail is set to shift N ticks at Bar close.

    Is it possible to activate the trailing stops after Target#1 is achieved?

    #2
    Hello Kingkoda,

    Thank you for writing in.

    At the following link you could see reference sample, BreakEvenBuilderExample, which will demonstrate how you can have a stop moved to breakeven, which is what you could use as a template for how to trigger the trailing stop. In your case it would be when PT 1 is hit.

    The other example, TrailBuilderExample demonstrates how you write a strategy in the builder to adjust your stop as profits increase.

    Please see the following link,
    https://ninjatrader.com/support/foru...427#post527427

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan,

      The examples help a lot... I understand that these are just example strategies for demonstration purposes and do not have indicator/price based conditions for entry... I understand the logic behind Conditions and Actions in both examples except for the last set which does the following: ExitLongStopMarket(DefaultQuantity, StopPrice,@"exit',@"entry"). Also, there are no stop or trail orders under Stops and Targets.

      Does the strategy have to exit position under a condition set?
      Is there a way to tie the trail order to StopPrice which is under Variables?

      Comment


        #4
        Hello KingKoda,

        The last set which calls ExitLongStopMarket, just submits a stop order which is triggered when the price goes below the StopPrice.

        You would want to see the TrailBuilderExample for an example of how to trigger the trailing stop logic once the price had in your case, gone above the profit target price.

        In the TrailBuilderExample, on set two, you would want to modify the CurrentTriggerPrice to equal Default input[0]+Profit Target Ticks rather than TrailFrequency.

        I attached a modified version, which will start modifying the trailing stop when the price gets above 10 ticks from entry price.

        You could add a SetStopLoss to this strategy as well, so it would have a regular stop as well as a dynamic trailing stop.

        Please let us know if you need further assistance.
        Attached Files
        Last edited by NinjaTrader_AlanP; 04-01-2018, 07:41 PM.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hello Alan
          I have tried to test on the strategy analyzer the modified TrailBuilderExample you provided. I first added an entry condition (an SMA crossover) on condition set 2, but it did not produce any trade.
          I then tried also by running on the strategy analyzer just the TrailBuilderExample as you posted it, but also this second attempt did not trigger any trade.
          Could you please explain know why there are no trades?
          Thanks.
          Attached Files

          Comment


            #6
            Hey Alan,

            The trail works but it disables the strategy because of ExitLongStopMarket... Is there a way to make it isSimulatedStop so that it would simulate the stop order and submit as market once triggered?
            I tried changing the order type to ExitLongMIT, but it would exit the position immediately after entering.

            Comment


              #7
              Hello guidoisot,

              Try testing on PlayBack.

              Comment


                #8
                Hello KINGKODA,

                Are you seeing errors in the log when the strategy disables? If you expand the distance of the trailing stop to further back, from 5 ticks to say 10 ticks, do you still have an issue.

                You could modify the stop to a simulated stop if you'd like, however if your internet goes down you leave yourself open to a dangerous situation.

                I look forward to your reply.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello guidoisot,

                  The strategy has a line if State==Realtime. This would not be called in the strategy analyzer, which uses historical data. You could do as KingKoda suggests, and run the strategy in Market Replay.

                  Please let us know if you need further assistance.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hey Alan,

                    Yea I’m still having issues with the trail... The error message says strategy cannot place stop order above market price... I understand that if the internet is down there will be no stop order to exit the position, but wouldn’t adding a SetStoploss be a safe way to protect the position? And how do I modify the stop to a simulated stop?

                    Comment


                      #11
                      Hello KINGKODA,

                      Debugging on my end I realized the issue was that the problem is CurrentStopPrice in that sample is defined as a integer rather than a double, so its its rounding stop price to a whole number. Ex, uusing 60 rather than 60.60 for the stop. This is causing the error.

                      I modified the sample and it should work.

                      You could add SetStopLoss to the sample without a issue.

                      I'm not sure why you want to make the stop a simulated stop, but if you did want to make that move at your own risk, when selecting your SetStopLoss in the Builder on the Stops and Targets dialog, you would check Simulated Stop.

                      You could read more about SetStopLoss at the following link,
                      https://ninjatrader.com/support/help...ttrailstop.htm

                      See attached.

                      Please let us know if you need further assistance.
                      Attached Files
                      Alan P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by lavalampmj, Today, 05:25 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post lavalampmj  
                      Started by Antares66, Today, 05:19 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post Antares66  
                      Started by jmneto, Today, 05:18 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post jmneto
                      by jmneto
                       
                      Started by Bobbyj78, Today, 02:21 PM
                      2 responses
                      12 views
                      0 likes
                      Last Post bltdavid  
                      Started by EnveousColnago, Today, 02:10 PM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_Ariana  
                      Working...
                      X