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

Weekday with Strategy Builder

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

    Weekday with Strategy Builder

    Good morning, I am starting with the Strategy Buyilder and I would like to know how to set the option so that between certain days a week it is a variable.

    Thank you.

    #2
    Hi corman, thanks for your note.

    Please elaborate on your question if I am not accurate here. Do you want to set up a time filter in the builder to limit trading hours? We have documentation here that explains how to set up time conditions in the builder:



    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      The hours I have clear how to configure them, what I want is to set the day and the week (Monday, Tuesday ...) as a variable to define what days the system works.

      Thank you.

      Las horas tengo claras como configurarlas, lo que quiero es pone como variable el día e la semana (lunes, martes . . .) para definir que días trabaja el sistema.

      Gracias.


      Comment


        #4
        Hello Corman,

        Thanks for your reply.

        You would not be able to set the Days of the week directly as an input to select what days to trade. What you can do is to create a inputs of the bool type that you can name Sunday through Friday. These bools will provide check boxes that you can use to select the days to trade when you apply the strategy. In turn when the bool is true and the bar is on a selected day another bool can be used as part of your entry sets.

        I've created an example strategy builder strategy that you can download, import and test that demonstrates this by drawing the background only on the days you select. Note that there are two sets that are used to enable the bool OkToTrade as well as turn it off if not that day, both sets must be used.

        Here is an example screenshot of when Wednesday and Thursday are selected, the gray areas indicator that trades could occur on those days (There is no trade entry logic in the example).

        Click image for larger version

Name:	Corman-1.PNG
Views:	899
Size:	41.1 KB
ID:	1094311

        [ATTACH]n1094312[/ATTACH]
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul
          I am not very clear on how to implement this in my strategy. I only use strategy builder for my strategies creations and was thinking about implementing this week of day trading where i will have input for day of week as checkboxes and if i uncheck a box it would not trade on that day, do i need to enter my logic in separate sets in your example or i can enter my logic in set 1 and set 2. I know set 3 is just painting the background grey. I also do not understand variable associated with it, i think i have difficulty understanding concept of a variable associated with an event to make it true or false. I think a little couple minutes of video will help me to conceptualize. Thx

          Comment


            #6
            Hi trader333, thanks for your question.

            The third set is where you would check for if(OkToTrade == true). So your condition combined with OkToTrade would be the way to expand on the example e.g. if(<my conditions> && OkToTrade)
            {
            BackBrush = Gray;
            EnterLong();
            }

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi trader333,
              What Chris kindly shared with you is a very nice and compact piece of code to determine if a trade can be placed on different days of the week based on user input (one bool for each day from Sunday to Friday, which can be checked/unchecked in StrategyAnalyzer).
              The code then tests in just two "sets", if
              1) you have checked the respective weekday(s) (e.g. Monday and Wednesday) and if today is one of the respective weekday(s) (e.g. Monday or Wednesday), then OKtoTrade or
              2) if you disallowed the respective weekday(s) (e.g. Tuesday and Thursday) and if today is one of the respective weekday(s) (e.g. Tuesday or Thursday), then NOT OKtoTrade.
              That makes perfect sense if you use the same entry/exit conditions for all days of the week.
              If you wanted to test different entry/exit conditions for each weekday, you could take a slightly different approach. Rather than pulling the weekday test "in front of the bracket" on two separate sets as shown by Chris, you would add the weekday test to your individual "set" of rules for the respective week day, and perhaps even use individual names for your entries like this:
              If ((Monday == True )
              && (Times[0][0].DayOfWeek == DayOfWeek.Monday)
              && your other entry conditions)
              EnterLong(DefaultQuantity, @"MondayBull")
              No matter which way to go. It can definitely be done using the StrategyBuilder. No coding required.
              Have fun, NT-Roland

              Comment


                #8
                Chris L and NT-Roland
                Thanks for your contributions and making my concept of variable controlling events a breeze, now i have achieved what i wanted to do for a very long time in strategy wizard

                Comment


                  #9
                  Hello, thank you all for the comments. I have made a system with the file that you attach, I have unchecked some days so that it does not enter and it enters every day, in the screenshot that I attach you will see that Tuesday comes in, even though it is unmarked.

                  Thanks again.

                  Hola, gracias a todos por los comentarios. He hecho un sistema con el fichero que adjuntas, he desmarcado algunos días para que no entre y entra todos los dias, en el pantallazo que adjunto verás que entra martes, a pesar que esta desmarcado.

                  Gracias de nuevo.
                  Attached Files

                  Comment


                    #10
                    Hi corman, thanks for your reply.

                    Can you share the code you have?

                    I look forward to hearing from you.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      I attach the compressed file, it won't let me attach the file. cs

                      Thanks.

                      Attached Files

                      Comment


                        #12
                        Hi corman, thanks for your reply.

                        The additional logic doesn't have a check for OkToTrade. You should add a check for OkToTrade == true within set 5.

                        Kind regards.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi, I'm interested in this strategy example to try and use it for a strategy I'm building. Could someone re-upload it as it has some type of error that doesn't show the link. All I see it [ATTACH]n1094312[/ATTACH.

                          Thank you in advance.

                          Ariel Rodriguez

                          Comment


                            #14
                            Hello Ariel,

                            Thanks for your post.

                            Are you referring to the link in post # 2 that explains how to set up time conditions in the Strategy Builder?

                            If so, see the 'How to create time comparisons' section of this help guide page:


                            Or, are you referring to the 'DayOfWeekTest' sample shared on post # 4?

                            If so, I have attached the reference sample to this forum thread for you to view.
                            Attached Files
                            Brandon H.NinjaTrader Customer Service

                            Comment


                              #15
                              Yes, That was it. Thanks for the prompt response. This thread had not been seen for years, I never thought I was going to get a response so quick. Thanks once again.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by MarianApalaghiei, Today, 10:49 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by love2code2trade, Yesterday, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Started by funk10101, Today, 09:43 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post funk10101  
                              Started by pkefal, 04-11-2024, 07:39 AM
                              11 responses
                              37 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Yesterday, 08:51 AM
                              8 responses
                              46 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X