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

Help with strategy builder

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

    Help with strategy builder

    I would like assistance with building a strategy to enter into a trade based off a certain amount of ticks the price exceeds the bollinger bands on a certain side. I am currently using the attached tool and ninja trader To enter into a trade a certain amount of ticks outside the band of my choosing. I would like a strategy where it enters into the trade immediately once conditions are met versus having a limit order sit for the market to see.I like what the attach tool does.. Any help would be greatly appreciated
    thanks
    - Ace

    #2
    Hello Aadejimi89,

    Thank you for your post.

    I've created a simple example Strategy Builder strategy that will enter long or short once the price exceeds the upper Bollinger band by BreakoutTicks number of ticks, or the lower Bollinger band by LongBreakoutTicks. If you run this OnPriceChange, it will enter as soon as the current price reaches that point in real time with a market order. This should give you a starting point to build upon.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks for responding Kate . Will code be required if i wanted to enter trade when price goes outside bollinger band on two different charts with two different time frames at the same time?

      Comment


        #4
        Hello Aadejimi89,

        Thank you for your reply.

        You can use the same strategy on different instruments at the same time using different time frames without modifying the code. It would not be advisable to run multiple strategies on the same account and instrument combination using different time frames simultaneously as strategies can interact with each other. For example, if I have two instances of a strategy running on the same account and instrument combination using different time frames, and strategy A takes a position of 5 long, then strategy B submits orders to take a position of 5 short, strategy A would still think it is in a 5 long position, strategy B would think it's in a 5 short position, but the overall account position would be flat. This would cause both strategies to be out of sync with the account and to remain out of sync with the account position, resulting in incorrect PNL being reported by each strategy.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Yes, I understand. Not sure if I was being clear, apologies. when the 60 min chart and the 10 min chart go outside my bollinger band a certain amount of ticks I'd like the strategy to enter the trade based on 10 min chart. I'm only trying to run one strategy based on price location of 2 different time charts but same instrument.

          Comment


            #6
            Hello Aadejimi89,

            Thank you for your reply.

            You would need to add an additional 60 minute data series to the strategy from the Additional Data screen of the Builder and add logic to calculate the Bollinger on that series. Then run the strategy on the 10 minute chart as Strategy Builder strategies do not allow you to submit orders to an added series - you can only use additional data series as the input for an indicator in the Builder. You'd then need to add logic to check the current close price against a bollinger calculated on that secondary series as well as the bollinger on the primary series, see if both are below the close price by X number of ticks, and then submit your entry if that is the case.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7

              Hello,
              I'm trying a variation to this strategy but despite the various attempts I can not get to a solution:

              I would like to enter into a reversal trade based off a certain amount of bars when the price exceeds the bollinger bands.

              Example: the upper bollinger has been touched by 5 bars consecutively and at the close of the 5th bar I'd like to open a sell position. I'd like also to optimize the parameter "n° of bars" in order to find the best number of bars before a reversal.

              ​Any help would be greatly appreciated!

              Alex

              Comment


                #8
                Hello Alex,

                Thanks for your note.

                "the upper bollinger has been touched by 5 bars consecutively"

                When you mention that you want to check if the Upper Bollinger Band has "been touched" are you referring to if the current Close price is greater than or equal to the Upper Bollinger Band for 5 bars in a row?

                "I'd like also to optimize the parameter "n° of bars" in order to find the best number of bars before a reversal."

                Note that it would not be possible to use a dynamic input for the BarsAgo value of a price or indicator plot in the Strategy Builder. This would require unlocking the script and manually programming your strategy to use a dynamic value such as a user-defined input.

                I look forward to assisting further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Brandon and thanks for Your fast reply!

                  When you mention that you want to check if the Upper Bollinger Band has "been touched" are you referring to if the current Close price is greater than or equal to the Upper Bollinger Band for 5 bars in a row?
                  yes exactly!

                  Note that it would not be possible to use a dynamic input for the BarsAgo value of a price or indicator plot in the Strategy Builder. This would require unlocking the script and manually programming your strategy to use a dynamic value such as a user-defined input.
                  oh ok,I thought it was simpler than that.

                  Comment


                    #10
                    Hello Alex,

                    Thanks for your note.

                    To check if the current Close price is greater than or equal to the Upper Bollinger Band over the last 5 bars, you will create 5 conditions in the same Set.

                    The first condition: On the left side of the Condition Builder, select the Price folder > Close price > set the 'Bars ago' field to 0. In the center drop-down menu, set the drop-down menu to 'Greater equal. On the right side of the Condition Builder, select the Indicators folder > select 'Bollinger > set the 'Bars ago' field to 0 > set the 'Value plot' field to 'Upper'.

                    The second condition: On the left side of the Condition Builder, select the Price folder > Close price > set the 'Bars ago' field to 1. In the center drop-down menu, set the drop-down menu to 'Greater equal. On the right side of the Condition Builder, select the Indicators folder > select 'Bollinger > set the 'Bars ago' field to 1 > set the 'Value plot' field to 'Upper'.

                    The third condition: On the left side of the Condition Builder, select the Price folder > Close price > set the 'Bars ago' field to 2. In the center drop-down menu, set the drop-down menu to 'Greater equal. On the right side of the Condition Builder, select the Indicators folder > select 'Bollinger > set the 'Bars ago' field to 2 > set the 'Value plot' field to 'Upper'.

                    The fourth condition: On the left side of the Condition Builder, select the Price folder > Close price > set the 'Bars ago' field to 3. In the center drop-down menu, set the drop-down menu to 'Greater equal. On the right side of the Condition Builder, select the Indicators folder > select 'Bollinger > set the 'Bars ago' field to 3 > set the 'Value plot' field to 'Upper'.

                    The fifth condition: On the left side of the Condition Builder, select the Price folder > Close price > set the 'Bars ago' field to 4. In the center drop-down menu, set the drop-down menu to 'Greater equal. On the right side of the Condition Builder, select the Indicators folder > select 'Bollinger > set the 'Bars ago' field to 4 > set the 'Value plot' field to 'Upper'.

                    See the attached screenshot.

                    Note that a BarsAgo value of 0 checks the current forming bar, BarsAgo of 1 checks the previous bar value, BarsAgo of 2 check the value 2 bars prior to the current bar, and so on.

                    Let me know if I may assist further.​
                    Attached Files
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      thanks Brandon for the complete explanation! You've been really clear

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Segwin, 05-07-2018, 02:15 PM
                      14 responses
                      1,789 views
                      0 likes
                      Last Post aligator  
                      Started by Jimmyk, 01-26-2018, 05:19 AM
                      6 responses
                      837 views
                      0 likes
                      Last Post emuns
                      by emuns
                       
                      Started by jxs_xrj, 01-12-2020, 09:49 AM
                      6 responses
                      3,293 views
                      1 like
                      Last Post jgualdronc  
                      Started by Touch-Ups, Today, 10:36 AM
                      0 responses
                      13 views
                      0 likes
                      Last Post Touch-Ups  
                      Started by geddyisodin, 04-25-2024, 05:20 AM
                      11 responses
                      63 views
                      0 likes
                      Last Post halgo_boulder  
                      Working...
                      X