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

Entry based on price challenge

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

    Entry based on price challenge

    I have a strategy based on price. When price is above the open by X points it buys long. However, when it hits the profit target it automatically enters the trade again because it’s still X pints above open. I want to make it to where price has to retrace to the open price before it would allow a long entry again. Is there a way to do that on strategy builder?

    #2
    Hello Shiner452,

    Thanks for your post and welcome to the NinjaTrader forums!

    What you can do here is to create and use a bool type variable (one that is true or false) that is set to true initially.

    In the entry set, add the condition that checks to see if the bool is true. On the action side, (where you place your order) add the action to set the bool to false. This will prevent further entries until the bool is reset to true. Create another set that checks that price is less equal to the open price and the action would be to set the bool to true, thus enabling the first set to place a trade again when your other entry conditions are true.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks so much for this! Great idea!

      Comment


        #4
        So i'm doing this using the strategy builder and on the actions side there is no option for me to set the bool to true. I only get 3 main folders, 'Drawings', 'Misc', and 'Order Management'. I don't see any action options that would enable me to effect any other components.

        Comment


          #5
          Hello Shiner452,

          Thanks for your reply.

          Once you have created the bool variable on the Inputs and variables screen, the bool can be set in the action of a set by selecting the Misc folder and scroll to the bottom, You will find the bool (or any variable you create) listed there with the word "Set" in front of it.

          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hey Paul. Thanks for your help with this. I have created the bool and the actions as you described. So I have a bool called 'AllowLong' Default value is True. The conditions are when price is greater than XXX and when AllowLong is True...the Action is EnterLong. However, nothing happens. However, when I take the bool off the conditions it enters the long no problem. But then immediately re-enters once I close the position since price is still above XXX. I don't understand why the bool being set for true and the condition of the bool being true is not allowing the order to fill.

            Comment


              #7
              Hello Shiner452,

              Thanks for your reply.

              Do you have another set that could be setting the bool to false?

              You may want to work through debugging your script.

              Here is a short example of how you might approach this: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                It seems as though that while running the backtest the previous candles are tripping the bool to be false. I want the bool to be True at RTH open for the NY session. I can't seem to figure that one out.

                Comment


                  #9
                  Hello Shiner452,

                  You can consider checking Misc > First bar of session Equals Misc > True for your strategy's first condition to (re)set your bool to true. Your later logic can then set the bool to false and any logic controlled by the bool would no longer be reached as the bool would be false, until it is reset on the first bar of the next session.

                  We look forward to assisting.

                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Jim This worked but the problem here is that as long as that bar is open the conditions are true...even if they are set to false they re-set to true if the bar is open.

                    Comment


                      #11
                      Is there a way for me to say 'at a certain time setvalue to true'?

                      Comment


                        #12
                        Hello Shiner452,

                        Thanks for your reply.

                        Yes, you can use a time-based condition, please see the example in the help guide here: https://ninjatrader.com/support/help...imeComparisons
                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        26 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by bmartz, 03-12-2024, 06:12 AM
                        3 responses
                        29 views
                        0 likes
                        Last Post NinjaTrader_Zachary  
                        Started by Aviram Y, Today, 05:29 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post Aviram Y  
                        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