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

How to set a fixed target and stop based on an indicator like say Moving Averages

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

    How to set a fixed target and stop based on an indicator like say Moving Averages

    I would like to set my targets and stops based on the price level of indicators on my chart, using the strategy builder, all at the time of entry. However, I would like these to be fixed and not move to different prices with the passage of time. So if I enter a trade at time 0, set my target to the price of an indicator at time 0, set my stop to the price of another indicator at time 0 and keep them fixed (i.e. not change to a new price as time goes by). How can I do that?

    #2
    Hi kal1212, thanks for your question.

    You will not be able to use the Stop and Target section of the builder if your stop or target are going to be the value of an indicator. After the strategy submits an entry order submit an exit order and the price can be set to an indicator value. I have attached a semi-relevant example (it shows how to submit a stop loss order). The example implements a break even action.

    Please let me know if I can assist any further.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks a lot. This really helps. I am also trying to set the strategy to take profits at different price targets as a trade moves in my favor. So say 1/3 of position at target 1, another 1/3 at target 2 and the remaining third to exit when the condition to take the trade in the first place is no longer true. Can you kindly provide a video on how this can be accomplished using the strategy builder?

      Thanks

      Comment


        #4
        Hi kal1212, thanks for your reply.

        I know of this example from our colleague Chelsea that implements a scale out:



        Please let me know if you have any questions on this material.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello,
          it appears that this sample strategy does not apply the BE and the SL respectively when the high of the entry bar does not reach the BE trigger level and when the close of the entry bar ends below the SL.
          Another issue is that the strategy does not apply on the entry bar the Low[0]<Low[1] exit condition that I added in order to avoid this. This is also shown on the attached image, where point 1 is causing points 2 and 3.
          Please can you show if there a way to fix this? thx

          Click image for larger version

Name:	ES 06-20 (1 Minute) 2020_05_14 (12_39_37).jpg
Views:	740
Size:	197.4 KB
ID:	1100800
          [ATTACH]n1100799[/ATTACH]

          Comment


            #6
            Hi guidoisot, thanks for posting.

            Please print out the price of your MIT order and make sure its at a valid price level. There might also be errors in the log tab of your control center on the error. The strategy comes "as is " so I would not be able to debug any modifications.

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              I accorded above breakevenstrategy sample to try. I found there is a bug! The bug is when entry bar triggered the stop loss, NT8 do not fire the exit order!
              It only work for 2nd bar or later bar to trigger stop loss!
              Can Customer Service checks the provided Sample what happens?!

              Comment


                #8
                Hi cyjoe, thanks for your post.

                I am getting a stop loss when the order fills. Could you let me know what kind of chart are you running this on so I can test try to replicate what you tested?

                I look forward to hearing from you.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Click image for larger version

Name:	capture.png
Views:	510
Size:	94.9 KB
ID:	1101940

                  I use
                  "HSI 05-20" instrument 15-minutes Chart for Backtest

                  * Whenever entry and trigger stop loss in the same bar, the stop loss cannot function!


                  Comment


                    #10
                    Hi cyjoe, thanks for your reply.

                    I have noticed the problem myself in the Strategy Analyzer. I'll take a look into the problem and reply here once I fix it.

                    Thanks in advance for your patience.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello guidoisot,

                      This would be a limitation of the Strategy Builder strategy example which uses OnBarUpdate to trigger the logic for the stop loss handling.

                      With the unlocked strategy, I would suggest using OnExecutionUpdate to trigger your stop loss, and I would also suggest submitting the order to a single to tick data series to have the order filled with intrabar geanularity.

                      SampleOnOrderUpdate can demonstrate using OnExecutionUpdate to submit orders for target and stop with OnExectuionUpdate and SampleIntrabarBacktest can demonstrate submitting orders to a single tick data series so they are filled with intrabar granularity instead of using the OHLC of the next bar.

                      SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

                      SampleIntrabarBacktest - https://ninjatrader.com/support/help...ipt_strate.htm

                      We look forward to assisting.
                      JimNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by PaulMohn, Today, 12:36 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post PaulMohn  
                      Started by love2code2trade, 04-17-2024, 01:45 PM
                      4 responses
                      38 views
                      0 likes
                      Last Post love2code2trade  
                      Started by alifarahani, Today, 09:40 AM
                      2 responses
                      14 views
                      0 likes
                      Last Post alifarahani  
                      Started by junkone, Today, 11:37 AM
                      3 responses
                      20 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by frankthearm, Yesterday, 09:08 AM
                      12 responses
                      44 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Working...
                      X