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

Enter trade 1 tick above signal bar high

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

    Enter trade 1 tick above signal bar high

    Hello, I have a custom indicator that detects breakouts and prints a horizontal line 1 tick above the signal bar where you would enter a long position (images attached). So for example the indicator would print the line, I would manually place my buy order at that level and if the price reaches that level it’ll enter a long position. By using the ninjatrader strategy builder how can I ensure that the buy order is at the exact level of the horizontal line provided by the indicator? Basically- in the strategy builder settings, how can I set it so that it automatically opens a long position 1 tick above signal bar (high). Thank you

    On the image the:
    Orange circle= breakouts

    Green horizontal lines= where the indicator indicates recommended entry into long position

    Few trades to show that orders aren’t being placed at that horizontal line
    Attached Files

    #2
    Hello Brandon9821,

    Thanks for your post and welcome to the NinjaTrader forums!

    For your custom indicator to work with the Strategy Builder, it will need to provide a "signal" type plot. The signal plot would either be 0 (or -1 if you wish) and the value of the line when there is a signal. This plot can be transparent so it does not change your indicators display on the chart.

    The strategy builder could then read the plot and you can create conditions based on the value of the plot, including placing your limit order.

    In the strategy builder when you place a limit type order, the order is automatically canceled if not filled on the bar it is submitted so you would need to resubmit the order on each bar until it fills or the condition is no longer needed.

    Here are the educational resource available on the strategy builder:
    Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
    Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
    Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello, thank you for the advice. The signal plot for the long position is “2” according to the custom indicator. I managed to get my entries at the level I wanted earlier but I have another issue now. Some long positions are being filled which shouldn’t according to the conditions I have set (images attached)

      Conditions: if indicator signal equals 2, enter long limit 1 tick above high.

      As you see in the image, when conditions aren’t met a trade is still being placed.

      How can this be corrected in the strategy builder? Thank you!
      Attached Files

      Comment


        #4
        Hello Brandon9821,

        Thanks for your reply.

        Are you testing on real-time data or are you looking at historical entries on a live chart or are you testing with PlayBack using market replay or are you testing in the Strategy Analyzer.

        What is the Calculate setting of the strategy? (Calculate.OnBarClose, Calculate.OnEachTick, or Calculate.OnPriceChange)?

        You may want to print out the value of your signal along with the value of High[0]+ 1 tick so that you have some actual data that the strategy builder is using. Here is a link to a short video on creating a print statement in the Strategy Builder for debugging purposes: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I have a live chart of the MES open, I right-clicked to add my strategy to my chart and right clicked again and selected “strategy performance -> historical” . I believe this means historical data on a live chart. Sorry if this is a mistake as I am new to strategy development but I appreciate your help!

          The calculate settings are “on each tick”

          If you have any further suggestions I’d appreciate it but I will keep researching this issue as maybe I’m testing the strategy wrong as I haven’t seen it perform live yet- just simply adding it to my live data chart and clicking “strategy performance”

          Comment


            #6
            Hello Brandon9821,

            Thanks for your reply.

            When a strategy that is set to Calculate.OnEachtick is applied to historical data, the strategy will perform only once per bar. This is because historical bars do not contain all of the ticks the bar is built from, only the Open, High, Low and Close of each bar. The index of [0] would be of the just closed bar and any order would not be placed until the next bar.

            When the strategy is run on live charts (or playback with market replay data) then the strategy will be run on every incoming tick and [0] will point to the currently forming bar and [1] would be the just closed bar.

            I would suggest adding prints so that on bar by bar basis you can see what the strategy is actually working with when it processes on historical data. Printing the Time of the bar will provide you with a good reference to check (as shown in the video).

            You may want to also test using the playback connection to simulate live and see what your strategy performs like. When you are on live or playback, you will need to be using High[1] so that you are using the just closed bars high and not the currently forming high.

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I have been testing live but having issues like this (image attached). Is there any conditions that I can apply to ensure that if the level isn’t reached, an order won’t be placed and it resets at the next signal if an order isn’t placed? I am already using enterlonglimithigh [0]. Even testing live with [1] an order is placed even when price doesn’t break high of the signal bar
              Attached Files

              Comment


                #8
                Hello Brandon9821,

                Thanks for your reply.

                The entry order you are using is a limit order which will fill at the limit price or better and as the current price is less than the limit it fills immediately because it is a better price to go long from. The EnterLongLimit order should be used to enter below the current market.

                What you need to use, to go long above the market, is "enter long position by a stop order" , this type of order is to be placed above the current market and will fill when the price comes to it.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you very much that was a great help in understanding the type of orders. But I have another inquiry as shown on the attached images. Thank you
                  Attached Files

                  Comment


                    #10
                    Hello Brandon9821,

                    Thanks for your reply.

                    I think you are asking how to access the previous bar? If so, you would use High[1]. [2] would be 2 bars ago, [3], etc.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Sorry, that is not what I meant.
                      1) So first, the indicator shows that a breakout occurs (orange BO circle shown in images). The bar that the BO circle prints on is the signal bar. Above the signal bar is a horizontal green line 1 tick above the signal bar high that indicates where a buy order should be placed.
                      2) the only way I know how to place a trade at this horizontal green line is with the condition Indicator(10,4).Signal[0]=2 and action (EnterLongStopMarket, High[0]+ 1*ticksize). With this, trades would only be executed if the bar DIRECTLY after the signal bar reaches a level of one tick above the high of the signal bar (shown in previous image with the second BO)
                      3. Using the last image- let’s say the bar DIRECTLY after the signal bar doesn’t reach the level of 1 tick above the signal bar (like the first BO on the image shows). Then a trade wouldn’t be opened like we see. But, the price eventually reaches the level of 1 tick above the signal bar 5 bars after the signal bar. How can I get it so that even 5 bars after the signal bar- if the conditions of 1 tick above signal bar high is met a trade is opened?

                      Ideally I just want my strategy to do one thing: as soon as the BO signal prints, I want to open a long position by a stop order 1 tick above the signal bar high (which is the horizontal green line). I want the order to be placed at this level until either the price is met or until the next BO signal occurs, where this would be repeated with the new BO signal bar

                      thank you very much!

                      Comment


                        #12
                        If i Understand Correctly you got answer to your question above.

                        Indicator you are using is similar to Price Action indicator from same developer that i have....

                        As market is developing indicator do not know know witch bar will be a SIGNAL bar until that bar is finished...so than next bar as it is developing becomes TRIGGER bar witch decide if previous bar is a SIGNAL bar or not....hope that make sense.

                        Since Trigger bar is deciding and giving signal =2 to enter long you need to use [1] to position your order one tick above that bar
                        So if this is clear basically SIGNAL bar is already finished and on TRIGGER bar you are getting signal to go long.....

                        So that means you need to use [1] as posted in answer above.
                        I modify your line of code to have [1] because this is your previous bar or signal bar ---- (EnterLongStopMarket, High[1]+ 1*ticksize). Try this an see if it is working.
                        For condition ------- Indicator(10,4).Signal[0]=2 i am not sure if this needs to be modified ..... probably not.

                        Pay attention that you have a Tick Replay enabled on Data Series tab.....this step is important to see historical fill correct on chart when enable strategy if your strategy is correctly written...all so do not load to many days on chart as this will significantly slow down you chart...

                        Comment


                          #13
                          Hello Dsosta15,

                          Thanks for your post and welcome to the NinjaTreader forums!

                          Just wanted to say welcome and appreciate your efforts to help another member!
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Brandon9821,

                            Thanks for your reply.

                            How can I get it so that even 5 bars after the signal bar- if the conditions of 1 tick above signal bar high is met a trade is opened?
                            I do not know how the indicator works so I am unsure if when it produces a signal that it maintains that signal for more than one bar and if that is the case then your entry conditions are true on more than one sequential bar which means the High[0] will change as the bars progress.

                            Keep in mind, "In the strategy builder when you place a limit type order, the order is automatically canceled if not filled on the bar it is submitted so you would need to resubmit the order on each bar until it fills or the condition is no longer needed." To be clear the Stop market is also a limit type order.

                            In order to maintain your order what I suggest is that when a signal is generated that you save the price that you draw the line at into a double type variable. In the same set you will also need to set a bool variable from false to true. In another set check that the market condition is flat https://ninjatrader.com/support/help...ionComparisons and check that the bool is true. The action of that set would be to place the stop market order at the price of the variable. If/when the order is filled you would no longer be in a flat condition. If the order doesn't fill you might determine another condition where you want to stop submitting the order and you can do this by setting the bool to false which then prevents the order from being resubmitted and then the order will be auto-canceled if not filled.

                            Paul H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bmartz, 03-12-2024, 06:12 AM
                            4 responses
                            31 views
                            0 likes
                            Last Post bmartz
                            by bmartz
                             
                            Started by Aviram Y, Today, 05:29 AM
                            4 responses
                            11 views
                            0 likes
                            Last Post Aviram Y  
                            Started by algospoke, 04-17-2024, 06:40 PM
                            3 responses
                            28 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by gentlebenthebear, Today, 01:30 AM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by cls71, Today, 04:45 AM
                            1 response
                            7 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X