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

How to create a false condition

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

    How to create a false condition

    Hello,

    I notice when building conditions they are all (if Y is true, do X). I want to create a condition where (if Y is true, don't do X).

    I am building a strategy where one of my conditions for order entry is the CCI indicator period 50 cannot be less than level -350 in the past 30 bars.

    How do I create such a condition? I am also very new to ninjatrader and strategy building so please walk me through step by step.

    Thanks so much!

    #2
    Hello Cross161,

    Thanks for your post.

    I am assuming you are referring to the Strategy Builder, and not how you can check if a condition is false using C# in unlocked NinjaScript.

    Action blocks will always be executed if the controlling condition evaluates to true.

    You can consider creating a bool "AllowAction" (a variable that is true/false) and then setting that bool to false when your desired condition becomes true, and then in the Condition/Action set that triggers your action, simply check if the "AllowAction" bool is true for the action to be taken. When your desired condition is no longer true (opposite conditions occur) you can set the "AllowAction" bool back to true.

    Bool variables can be made in the Inputs and Variables page of the Strategy Builder. They can then be referenced in a condition under "User variables" and can be set in an action under Misc > Set "AllowAction."

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Another quick question via strategy builder, how would I create a condition where if the price dropped less than $10 dollars over the past 20 bars to be true?

      For example the ES-Mini just fell $40 dollars over the past 20 bars. I want avoid my entry condition due to the volatility of the large drop so I am trying to make a condition where my entry will only trigger if the move is less than $10 dollars over 20 bars.

      Comment


        #4
        Hello Cross161,

        You could consider checking if the lowest low over the last 20 bars is greater than the Close of 20 bars ago with an offset applied. This can be done using the MIN indicator on the Low Price Series, using a Period of 20 bars, and then checking that this value is greater than Close[20] with an offset of -10.

        For example:

        Click image for larger version

Name:	NinjaTrader_2020-10-08_08-04-11.png
Views:	562
Size:	28.1 KB
ID:	1121786

        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          One last question and this is an indicator question so you may not be able to help me?

          The TSI (True Strength Index) indicator has a indicator range from 100 through -100
          The MFI (Money Flow Index) indicator has a indicator range from 100 to 0

          I enjoy using these two overlapped manually trading as you can overlap indicator panels using scale justification = overlay in the indicator settings. When trying to us them in strategy builder they are on very different scales. Would it be possible to edit one of the indicators to match the indicator scale of the other?

          I just also wanted to say thanks Jim! You guys do a great job answering our questions and always being there to help.

          Comment


            #6
            Hello Cross161,

            Thanks for your kind words.

            You can create a copy of the indicator by opening it in the NinjaScript Editor, right clicking in the code editor and then selecting Save As to make a copy that you can edit.

            From here, you can modify the plot values that are assigned to Value[0] so that they are normalized to the same range.

            A publicly available resource on normalizing values with C# code can be found below.

            I have a number range -100 to 100. I'm trying to Normalize it to 0 to 3 with decimal places. -100 = 0 -50 = 0.75 0 = 1.5 50 = 2.25 100 = 3 I want to create a program function to normalize...


            If you have any new inquires, please don't hesitate to open a new thread.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            602 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            22 views
            0 likes
            Last Post xiinteractive  
            Started by Pattontje, Yesterday, 02:10 PM
            2 responses
            19 views
            0 likes
            Last Post Pattontje  
            Started by flybuzz, 04-21-2024, 04:07 PM
            17 responses
            230 views
            0 likes
            Last Post TradingLoss  
            Started by agclub, 04-21-2024, 08:57 PM
            3 responses
            17 views
            0 likes
            Last Post TradingLoss  
            Working...
            X