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 triggered only once a day (using strategy builder)

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

    strategy triggered only once a day (using strategy builder)

    Hello! I would like to know if I can make my strategy to trigger only once after the conditions are met, even though the conditions might occur again in the same day.
    Ex: enter short when the price touches yesterday's high for the first time. Only enter again the next day, when the variables of the condition will change (at the next 'yesterday's high')
    Is it possible to achieve this in strategy builder? I have no experience in programming.

    thank you!

    #2
    Hello nothingtrader,

    Welcome to the NinjaTrader forums!

    Yes, you can use a bool which is a true or false value.

    Require the bool to be false in the condition set that places the order.

    Set the bool to true in the actions for that set.

    Then when its been set to true, the condition will not trigger any more because it requires the bool to be false.

    When you want a condition to allow new orders, set the bool back to false.


    Below is a link to a forum post with helpful information about getting started with NinjaScript. I recommend starting with the Strategy Builder 301 video.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      This would be very useful when I'd like to bypass a specific set from a strategy. But for backtesting it, I'd like the strategy to automatically become active again the next day, just until the conditions are met for the 1st time, then stop it again and rerun it the next day and so on. Like for example, I want to place a short only the first time price is touching yesterday's high. Thank you!

      Comment


        #4
        Hello nothingtrader,

        You can set the bool back to false when Misc -> First bar of session is true.

        You can have a condition that compares the Price -> Close to be equal to Indicator -> PriorDayOHL -> Prior High.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          It works! Thank you very much!

          Comment


            #6
            Hello:
            I have a strategy that only goes in long, I created a bool variable ReEnter=true and a condition ReEnter=true to make the entry and change ReEnter =False, but it still makes entries. How can I tell the strategy builder that I only want one post a day???I've seen this forum and I don't know if I'm doing it wrong or I don't understand it.
            Thank you
            Last edited by NinjaTrader_ChelseaB; 01-13-2021, 09:26 AM.

            Comment


              #7

              Hi,
              I have a strategy that only goes in long, I created a bool variable ReEnter=true and a condition ReEnter=true to make the entry and change ReEnter =False, but it still makes entries. How can I tell the strategy builder that I only want one post a day???I've seen this forum and I don't know if I'm doing it wrong or I don't understand it. Thank you
              Last edited by NinjaTrader_ChelseaB; 01-13-2021, 09:26 AM.

              Comment


                #8
                Hello Emilio,

                In the condition set that places the order, there will need to be a condition that requires the bool to be false.

                In the action, the bool is set to true.

                This should not be set back to false until, in a different condition set, Misc -> First bar of session is true.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Variable:
                  ReEnter bool false

                  SET 1

                  Condition:
                  .........
                  ReEnter=false

                  Do the following;
                  EnterLong.....
                  ReEnter=true

                  SET 2

                  Condition:
                  Bars.IsFirstBarOfSesion=true

                  Do de following:
                  ReEnter=false

                  Is correct????there are some days whit two or more trades.
                  Regards

                  Comment


                    #10
                    Hello Emilio,

                    The bool starts as false.

                    The bool is set to true in set 1, when the action is allowed once.

                    The bool is reset back to false in set 2, at the start of a new session.

                    The bool must be false for the action to trigger.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Got it, thanks.
                      It is possible to have within the strategy in addition to a profit target and a stop loss a trailing stop???? How could it be activated if it were possible?
                      Thank you
                      Last edited by NinjaTrader_ChelseaB; 01-13-2021, 09:25 AM.

                      Comment


                        #12
                        Hello Emilio,

                        This is Jim, responding on behalf of Chelsea who is out of the office at this time.

                        A Trailing Stop can be used with SetTrailStop under Stops and Targets in the Strategy Builder. The Auto Trail behaviors will be controlled by the strategy internally, and will update based on the Calculate mode of the strategy.

                        If you would like to control your own stop loss to make a trailing stop you can do so by creating logic to control a stop market order submitted with ExitLongStopMarket/ExitShortStopMarket in Conditions and Actions instead of using SetTrailStop.

                        An example that demonstrates how custom auto trailing behavior can be created in the Strategy Builder can be found here - https://ninjatrader.com/support/foru...596#post806596

                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Hi, I have a strategy builder scheduled that only goes in long, I have programmed a trailing stop and I can't get it to work, can you help me ????
                          inputs: stop, trailstar, trailsize
                          type: double
                          Default: 60, 40 50
                          Variable: Stoplong - double - 0
                          SET1
                          Do the following:
                          EnterLong
                          Stoplong=0
                          SET2
                          Position.MarketPosaition=MarketPosition.Long
                          Stoplong=0
                          Do the following:
                          Stoplong=(Posotion.AveragePrice-(Stop));
                          ExitLongStopMarket(DefaultQuantity,Stoplong)
                          SET 3
                          Position.MarketPosition=MarketPosition.Long
                          (Default input[0]-(Trailstar))>Position.AveragePrice
                          (Default input[0]-(Trailsize))>Stoplong
                          Do the following:
                          Stoplong=(Default input[0]-(Trailsize);
                          ExitLongStopMarket(DefaultQuantity,Stoplong)

                          Is correct?????
                          Regards
                          Last edited by NinjaTrader_ChelseaB; 01-13-2021, 09:26 AM.

                          Comment


                            #14
                            Hello Emilio,

                            Take a look at the TrailBuilderExample I have provided you a link to in post #12.

                            Use a double variable to save the price of the next trigger point.

                            When the close price reaches the trigger point, call the exit to move this to the price, then save the price of the next trigger point to the variable.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,609 views
                            0 likes
                            Last Post aligator  
                            Started by jaybedreamin, Today, 05:56 PM
                            0 responses
                            9 views
                            0 likes
                            Last Post jaybedreamin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            6 responses
                            19 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by Jon17, Today, 04:33 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post Jon17
                            by Jon17
                             
                            Started by Javierw.ok, Today, 04:12 PM
                            0 responses
                            16 views
                            0 likes
                            Last Post Javierw.ok  
                            Working...
                            X