• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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:

    https://ninjatrader.com/support/help...imeComparisons

    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:	144
Size:	41.1 KB
ID:	1094311

        DayOfWeekTest.zip
        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

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by BatBart, Today, 01:24 PM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_Melissa  
                        Started by ezrakoper, Today, 03:05 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by asmmbillah, Today, 02:23 PM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by steveg, Today, 02:44 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Heath  
                        Started by lightsun47, Today, 12:33 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Jim  
                        Working...
                        X