Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to address multiple triggers when you can't use CrossAbove/CrossBelow?

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

    How to address multiple triggers when you can't use CrossAbove/CrossBelow?

    So, I'm having an issue (obviously).

    In the Strategy Builder, I am trying to do some candlestick patterns with OnTick calculation. What I want is:
    If price crosses above the high of X bars ago, buy to enter
    If prices crosses below the low of X bars ago, sell to enter

    Then exit longs if they fall below the low of the previous bar, exit shorts if they cross above the high of the previous bar.

    Now, I know I can't use CrossAbove() or CrossBelow() to do these things. So I am stuck with things like:
    If Default input[0] > High[1]
    Then either enter long or exit short as the case may be.

    Here's the question: how in the heck do I accomplish this without sending a zillion signals?

    This is ESPECIALLY plaguing me when exiting - sometimes I will exit a long (for example) but there will be one-to-many exits and I end up accidentally entering a short from the long exit order(s)!

    This is just a test script for something much more complicated, but I cannot move forward until this is addressed. It even seems to occur when I put BarsSinceEntry != 0 on the entry page or BarsSinceExit != 0 on the exit condition page (again, this is in the Strategy Builder for now).

    Thank you!

    #2
    Hello Mistoffelees,

    For a cross condition that uses a bars ago you just need to use numeric value for that as it disables the bars ago property on the indicators being used. For example on the left of the condition builder select Price -> Close, select cross above or below, then on the right select misc -> numeric value and click Set. Then select the indicator and bars ago you wanted.

    Comment


      #3
      Woohoo, neat trick! Thanks! I will be testing this out tomorrow!
      Last edited by Mistoffelees; 06-25-2024, 08:11 PM.

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello Mistoffelees,

        For a cross condition that uses a bars ago you just need to use numeric value for that as it disables the bars ago property on the indicators being used. For example on the left of the condition builder select Price -> Close, select cross above or below, then on the right select misc -> numeric value and click Set. Then select the indicator and bars ago you wanted.
        I use the CCI indicator in a strategy and would like to set the CCI Value i.e., 100, 0, -100 / Cross Above or Below / AND 1 Bar Ago. How would this be accomplished?

        CCI > Cross Above/Below > Misc > Numeric Value= 100, 0, -100 etc.,

        This is being used in the strategy as an exit signal. How then to Exit on the Next Bar Open and not the close of the signal?

        Run Stragety on Each Tick THEN: Misc -> Is First tick of bar. That can be compared with Misc -> True. ?

        Last edited by AlpinesTrading; 09-19-2024, 05:57 AM.

        Comment


          #5
          Hello AlpinesTrading,

          "I use the CCI indicator in a strategy and would like to set the CCI Value i.e., 100, 0, -100 / Cross Above or Below / AND 1 Bar Ago. How would this be accomplished?"

          To confirm, you want to know when the CCI of 2 bars ago has crossed above 100 1 bar ago?

          For this you would need two conditions in the set

          Indicators > CCI with Bars ago 2, Less, Misc > Numeric value 100.
          Indicators > CCI with Bars ago 1, Greater, Misc > Numeric value 100.


          Yes, using Misc > IsFirstTickOfBar, Equals, Misc > True would evaluate the logic on the first tick of a new bar.

          In historical TickReplay is necessary to allow Calculate to update for each tick or price change.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you much for the reply

            Comment


              #7
              How would I accomplish this Entry: Tick Data

              Price Cross Above Trendline 1 Bar Ago
              Enter on the Open of the Next Bar

              Cross Above and Greater Than examples

              I am using Market Replay/PlayBack and have tried a number of different ways to have the Trade Entry at Bar Open. Is it best to Unlock Strategy?
              Last edited by AlpinesTrading; 09-29-2024, 08:58 PM.

              Comment


                #8
                Hello AlpinesTrading,

                That would require using a variable and 2 sets. In your first set you would check the cross condition with the trendline of 1 bar ago and as the action set a bool variable to true. In a second set you would need to check if the bool variable is true in addition to checking if it is the first tick of the bar. That will only execute that condition ono the bar following when the first condition was true.

                You can set up the crossover condition as previously explained or if you want to use the current bar you can also use the crossabove or crossbelow operators.

                To check if the update is the first tick of the bar you can use Misc -> is first tick of bar -> equals -> misc ->true.

                Comment


                  #9
                  Can you show the example(s), I've done this exact same procedure before though a visual example would put the exclamation point I need, thanks
                  Last edited by AlpinesTrading; 09-30-2024, 04:52 PM.

                  Comment


                    #10
                    Hello AlpinesTrading,

                    Which part were you looking for examples of? While I cannot create the whole strategy for you as an example I can go over the steps required to do those tasks if some part is not clear.

                    Comment


                      #11
                      Step by Step is good. I just need to understand where to put what. set #1 then set #2 what to put exactly where. I will be taking some courses for ninjascript soon so I might be able to explain Boolean too
                      Thanks for the helps
                      Last edited by AlpinesTrading; 10-01-2024, 12:05 PM.

                      Comment


                        #12
                        Hello AlpinesTrading,

                        To create a bool variable you can use the inputs and variables screen in the builder. You can see information about using that screen here: https://ninjatrader.com/support/help..._builder.htm#H owToUseUserDefinedInputsAndVariables

                        Once you are in that screen create a bool variable with a default value of false, you can use what you like for the name.
                        After doing that go to your set with your entry conditions and add another condition. The condition would be:
                        User variables -> Your variable name
                        Equals
                        Misc -> false

                        In the actions section of that set add a new action
                        Choose Misc -> Set your variables name and set it to true

                        In another set add a new condition
                        User variables -> Your variable name
                        Equals
                        Misc -> true

                        Add one more condition and choose
                        Misc -> Is first tick of bar
                        Equals
                        Misc -> true

                        As an action in that set
                        Choose Misc -> Set your variables name and set it to false​​

                        The second set would only work after the first set has become true and a new bar is formed.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by NullPointStrategies, Yesterday, 05:17 AM
                        0 responses
                        63 views
                        0 likes
                        Last Post NullPointStrategies  
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        139 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        75 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        45 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        50 views
                        0 likes
                        Last Post TheRealMorford  
                        Working...
                        X