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

Condition to NOT start a trade

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

    Condition to NOT start a trade

    On my strategy I have several condition to open a trade, But I want to make a condition when it's true, my strategy doesn't start any trades.
    Unlike what I usually do is I give the strategy conditions, when they are true, the strategy open the trades, and when they are false, the strategy doesn't open any trades.
    I want to do the opposite now, When the condition is TRUE the strategy does not start any trades even if the other conditions are true it should ignore them.

    How can I do that plz
    Thank you

    #2
    That could be done using a parameter called i.e. NoTrade. Set NoTrade=0 by default.
    In Set 1 you will put the special no-trade Condition you want to use. If that Condition is true, then NoTrade=1 else NoTrade=0.
    All other Sets have to first check that NoTrade=0 as a requirement to proceed evaluating the rest conditions.
    Last edited by KonstantinosNT; 12-31-2022, 01:26 PM.

    Comment


      #3
      Hello onlinebusiness,

      Thanks for your post.

      KonstantinosNT is correct. You could use an int variable in your script to control how trades are placed. A variable could be set up as KonstantinosNT has described so that trades are only placed when the NoTrade variable is equal to 0. That way if NoTrade does not equal 0 then trades will not be placed.

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

      Comment


        #4
        Originally posted by KonstantinosNT View Post
        That could be done using a parameter called i.e. NoTrade. Set NoTrade=0 by default.
        In Set 1 you will put the special no-trade Condition you want to use. If that Condition is true, then NoTrade=1 else NoTrade=0.
        All other Sets have to first check that NoTrade=0 as a requirement to proceed evaluating the rest conditions.
        Thanks it worked

        Comment


          #5
          Hello,


          I'm currently creating a strategy in Strategy Builder (SB). I'd like to know how to not enter a trade on subsequent bars if both of my criteria are not triggered on their respective current bars. I'm using the 50 and 150 tick charts. For example, I only want to enter a Buy when the (current bar) on the 150 tick BOP is >.01 and when the (current bar) on the 50 tick TRIX is rising. If this does not occur, then I don't want to enter a Buy and I will wait for another potential setup.

          Let's say at 8:15, the current bar 150 tick BOP is now > .01 but the current bar 50 tick TRIX is not rising, so I don't enter the Buy at 8:15 - which is fine. However, what happens is, 2 bars later, at 8:19, the 50 tick TRIX begins to rise and since the 150 tick BOP is still > .01, the strategy enters me in a Buy at 8:19. But, I don't want to enter the Buy at 8:19. Since both criteria weren't met at 8:15, I don't want to enter a Buy on subsequent bars, I want to wait for another potential setup. Do I need to ? turn off ? the strategy if all of my criteria isn't initially met at the same time on their respective current bars? If not, what do I need to do?


          Can anyone provide guidance on how to accomplish this in SB? Thanks for your help. ​

          Comment


            #6
            Hello Trade12,

            Thanks for your notes.

            A trade would only be placed by a strategy on a bar if the conditions to place the trade in the script on that bar become true.

            You could consider adding both conditions within the same Set in the Strategy Builder and call your entry order method if you want the order to be placed when both conditions become true.

            If you want to use multiple instruments for conditions, you could add the secondary instrument in the Additional Data screen of the Strategy Builder. Then, you could set up conditions based on that added series by setting the 'Input series' property of indicators to use the added series. Or, setting the 'Series 1' property of a price to use the added series.

            See the help guide documentation below for more information about working with the Strategy Builder.

            Strategy Builder Screens: https://ninjatrader.com/support/help...er_screens.htm
            Conditions: https://ninjatrader.com/support/help...on_builder.htm
            Actions: https://ninjatrader.com/support/help...t8/actions.htm
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hi BrandonH,



              Thanks for your response. Yes, I understand using the multiple instruments and adding the additional data in SB. I've done that. I've also put both conditions in the same set. Maybe I didn't describe my issue that well. I'd like to enter on a bar only when both conditions are triggered for the 1st time on their (respective) current bars. So, if at 8:15 only 1 condition is met, I wouldn't enter, but I also wouldn't want to enter at 8:19 (when the 2nd condition gets met) since both conditions were not triggered on the same bar. However, if both conditions trigger for the first time on the 9:02 bar, then that's when I would want to enter. Does that make sense?

              Comment


                #8
                Hello Ttrade12,

                Thanks for your notes.

                If you place both conditions in the same Set in the Strategy Builder and set the Conditions "of the following conditions are met" drop-down menu to "If All" then all of the conditions in the Set would need to become true on the same bar for the strategy to place an order.

                See the attached screenshot showing where this drop-down menu is located.

                You could confirm how the conditions are evaluating by adding prints to the strategy (outside of that condition) that prints out all the logic used for the conditions along with the Time of the bar.

                Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                https://ninjatrader.com/support/foru...121#post791121
                Attached Files
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks, I'll do that!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by llanqui, Today, 03:53 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post llanqui
                  by llanqui
                   
                  Started by burtoninlondon, Today, 12:38 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post burtoninlondon  
                  Started by AaronKoRn, Yesterday, 09:49 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post AaronKoRn  
                  Started by carnitron, Yesterday, 08:42 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Yesterday, 07:51 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post strategist007  
                  Working...
                  X