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

Strategy Triggering Several Times in A Row

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

    Strategy Triggering Several Times in A Row

    Hello,

    Im practicing making srategies and Ive come across an weird issue. I using the RSI as apart of a multi-condition trigger. Take a trade when the RSI crosses above the RSI AVG. Something just happened when the RSI and RSI AVG was bouncing back and forward across each other for like 2 mins. Between 8:30 and 8:32, there was over 100 trades taken, resulting a huge loss in my sim account.

    My strat is set to calculate on bar close and 1 entry per direction.

    How can i make sure that it does not perform like this? Bool? Is there a way to disable the strat if there are so many consecutive trades in a short time period.

    Also, when i back test this doenst seem to happen at all. And, when I disabled and re-enabled the strat in my chart and go look at statergy performance, it does not show this issue at all.

    Any help would be appreciated.

    #2
    Hello amigatlin,

    To have one action per bar, use a bool. In the action set the bool to true. When IsFirstTickOfBar is true set the bool back to false. Require the bool to be false in the condition.
    https://ninjatrader.com/support/help...ttickofbar.htm

    To count events, like the number of times a condition is true, use an integer that is incremented.
    https://ninjatrader.com/support/foru...260#post812260

    To disable a strategy call CloseStrategy().
    https://ninjatrader.com/support/help...sestrategy.htm

    "My strat is set to calculate on bar close and 1 entry per direction."

    Are you certain?
    Have you printed the value of Calculate in OnBarUpdate() to confirm?

    "when i back test this doenst seem to happen at all"

    For intra-bar actions and fills, you will need to implement 1-tick intra-bar granularity and enable TickReplay.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea.

      Is there away to perform the IsFirstTickOf Bar suggestion from stratergy builder. Currently I have 2 Sets and Set 1 is setting up a long. 3 Conditions and 1 action to enter long.

      "To have one action per bar, use a bool.Done. Shold bool default to Tue or False. In the action set the bool to true. When IsFirstTickOfBar is true set the bool back to false. Require the bool to be false in the condition."

      Comment


        #4
        Hello amigatlin,

        Yes, on the left select Misc -> IsFirstTickOfBar, in the center select Equals, on the right select Misc -> True.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks. At what point do I set the bool back to false? After the trade has completed?
          Last edited by amigatlin; 02-21-2023, 08:43 PM.

          Comment


            #6
            Hello amigatlin,

            If you are trying to trigger one action per bar, the bool would be set back to false when Misc -> IsFirstTickOfBar is equal to Misc -> True.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks. I tied to implement the steps from your first comment and the most recent one but now im getting an trade at the begenning of every bar. Do you have an example strategy built that has the steps above in it.

              For example. 1. If MACD crosses over MACD AVG enter long 1. If SMA 2 crosses below DEMA 15 exit long.

              Im having trouble knowing where to place the following

              1. Default value for my bool
              2. IsFirstTickOfBar = True
              3. where to "Require the bool to be false in the condition"
              4. Set the bool back to true

              Thanks Again

              Comment


                #8
                Hello amigatlin,

                Below is a link to a post with sample code.
                hi, please i am in the early stages of putting together a simple crossover strategy where a momentum indicator has influence on. The challenge is that when the market is in a deadlock where momentum keeps oscillating within a single bar, my strategy keeps opening and closing trades within the same bar. sometimes opening trades
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  NinjaTrader_ChelseaB

                  Thanks for the help. I was able to use it in my strat and it fixed my issues.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by dward123, 01-02-2024, 09:59 PM
                  3 responses
                  159 views
                  0 likes
                  Last Post bjunaid
                  by bjunaid
                   
                  Started by ETFVoyageur, Today, 04:00 PM
                  1 response
                  7 views
                  0 likes
                  Last Post ETFVoyageur  
                  Started by AaronKTradingForum, Today, 03:44 PM
                  1 response
                  8 views
                  0 likes
                  Last Post AaronKTradingForum  
                  Started by Felix Reichert, 04-26-2024, 02:12 PM
                  11 responses
                  77 views
                  0 likes
                  Last Post Felix Reichert  
                  Started by junkone, 04-28-2024, 02:19 PM
                  7 responses
                  83 views
                  1 like
                  Last Post junkone
                  by junkone
                   
                  Working...
                  X