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

Strategy builder help

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

    Strategy builder help

    I am building a strategy to go long once the high of the current candle breaks the high of the previous candle and goes short when the current candle breaks the low of the previous candle; however, the strategy is not taking in the account of the wicks and rather the only physical candle. Is there anyway that I can have the strategy go long and short over the tops and bottoms of the wicks rather than the candle itself?

    #2
    Hello dylanbower,
    You can use High / Low from Price. Hope it helps!

    Comment


      #3
      I am using the high and low from price but when the strategy runs it is taking the high and low of the the actual candle and it does not include the wicks of the candle.

      Comment


        #4
        Hello dylanbower,

        Thanks for your post.

        s.Kinra is correct. The upper wick of a bar represents the High price and the lower wick of a bar represents the Low price. To confirm this, you could add prints to your script that print the High/Low values and compare those values to the values in a Data Box window. To open a Data Box window, click the 'Show Data Box' button on the Chart toolbar.

        Something you could do is create a condition that checks if the current Close[0] is greater than the previous bar High[1] and call your long entry order. Then, you would create another condition that checks if the Close[0] is less than the previous Low[1] and call your short entry order. If you would like to place the order above the High/Low price, you could use EnterLongLimit/EnterShortLimit with a limit price of High/Low and a Tick offset.

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Would this strategy below work for going long and short above and below wicks?

          Comment


            #6
            Hello dylanbower,
            Yes, it should work. Just in case you don't see orders on chart be sure to select appropriate Plot executions in Data Series. Hope it helps!

            Comment


              #7
              Hello dylanblower,

              Thanks for your note.

              Yes, I would expect these conditions to work. The first condition would check if the Time is between 9:30AM and 4:00PM and also check if the current High price (upper wick) is greater than the previous bar's High price (upper wick). The second condition would check if the Time is between 9:30AM and 4:00PM and also check if the current Low price (lower wick) is less than the previous bar's Low price (lower wick).

              Let us know if we may assist further.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                As seen here, the strategy goes short, but the low of that candle new broke the low of the previous candle. I have had this issue previously and the strategy is not following the parameters.

                Comment


                  #9
                  Hello dylanbower,
                  Strategy works best with OnBarClose so it will ignore the latest forming bar, your condition is met for last bar & so order placed after it is closed & new bar starts forming. Hope this clarifies!

                  Comment


                    #10
                    Hello dylanbower,

                    Thanks for your note.

                    If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.

                    To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                    Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
                    https://ninjatrader.com/support/foru...121#post791121

                    Please let me know if I may further assist.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you for your help. What prints would I have to add and what would those prints look like?

                      Comment


                        #12
                        Hello dylanbower,

                        Thank you for your note.

                        You would need to print out the values for each condition in your script that places an order. For example, if you are comparing the High[0] > High[1] in your script, you would add prints for the current High[0] and previous High[1] and compare those values.

                        Please see the forum thread linked in post number 10 which demonstrates using prints and includes a video using prints in the Strategy Builder.

                        Let us know if we may further assist.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #13
                          If I do not use the strategy builder at all and just actually write out the code with the script editor would I still need to add the prints or no?

                          Comment


                            #14
                            Hello dylanbower,

                            Thanks for your note.

                            Yes. You would need to add prints to the strategy to see how the strategy is behaving. To truly know what is causing the issue it would be necessary to use prints and debug by looking at all of the information the script is using for decisions. That forum thread previously mentioned details how to understand the behavior of a strategy by using prints.

                            Let us know if we may assist further.
                            Brandon H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by wzgy0920, 04-20-2024, 06:09 PM
                            2 responses
                            26 views
                            0 likes
                            Last Post wzgy0920  
                            Started by wzgy0920, 02-22-2024, 01:11 AM
                            5 responses
                            32 views
                            0 likes
                            Last Post wzgy0920  
                            Started by wzgy0920, 04-23-2024, 09:53 PM
                            2 responses
                            49 views
                            0 likes
                            Last Post wzgy0920  
                            Started by Kensonprib, 04-28-2021, 10:11 AM
                            5 responses
                            193 views
                            0 likes
                            Last Post Hasadafa  
                            Started by GussJ, 03-04-2020, 03:11 PM
                            11 responses
                            3,235 views
                            0 likes
                            Last Post xiinteractive  
                            Working...
                            X