Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to exclude 5 o clock from trading?

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

    how to exclude 5 o clock from trading?

    I want to include no trades from 4:59 PM-5:01PM everyday to this....how can I do this?

    Here is my current code
    {
    if (Time[0].DayOfWeek != DayOfWeek.Wednesday || ToTime(Time[0]) <= 091500 || ToTime(Time[0]) >= 094500)

    EnterLongLimit(Close[0] - 1 * TickSize);
    }

    #2
    Hello Bobbybattles,

    Thanks for your post.

    Here is an example where if the time is within your time frame the code simply returns without further code execution:

    if (ToTime(Time[0]) >= 165900 && ToTime(Time[0]) <= 170100)
    return;


    To see another example of using a time filter, please see: http://ninjatrader.com/support/forum...ead.php?t=3226
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks. Where does this get placed? In the "conditions"? Or would this be in the "action" area (i.e. sellshort, etc)

      Does this go alongside of my original code?

      Comment


        #4
        Hello,

        Thanks for your reply.

        You could try this:


        if (Time[0].DayOfWeek != DayOfWeek.Wednesday || ToTime(Time[0]) <= 091500 || ToTime(Time[0]) >= 094500)
        {
        if (ToTime(Time[0]) >= 165900 && ToTime(Time[0]) <= 170100)
        {
        return;
        }

        EnterLongLimit(Close[0] - 1 * TickSize);
        }

        So if your first set of conditions are true but the time is between 4:59 and 5:01 it will not execute your enterlonglimit statement.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          To recap, I do not want trades from the 4:30P-5:05P, nor Wednesdays from 9:15A-9:45A, yet it is still taking trades in replay right at the 5:00P mark. Here is my code.

          {
          if (Time[0].DayOfWeek != DayOfWeek.Wednesday || ToTime(Time[0]) <= 091500 || ToTime(Time[0]) >= 094500)
          if (ToTime(Time[0]) >= 163000 && ToTime(Time[0]) <= 170500)
          {
          return;
          }

          EnterShortLimit(Close[0] - 3 * TickSize);
          }

          What am I missing?

          Comment


            #6
            Hello Bobbybattles,

            Thanks for your reply.

            The code you are showing is not what I posted previously. Please note the locations of the { } as these define the action sections of the condition two conditions.

            Please try this:

            if (Time[0].DayOfWeek != DayOfWeek.Wednesday && ( ToTime(Time[0]) <= 091500 || ToTime(Time[0]) >= 094500))
            {
            if (ToTime(Time[0]) >= 163000 && ToTime(Time[0]) <= 170500)
            {
            return;
            }

            EnterShortLimit(Close[0] - 3 * TickSize);
            }

            Using the code from above, attached are screenshots from the strategy analyzer that show no entries on Wednesdays between 9:15 to 9:45 and daily no entries between 4:30 and 5:05 PM
            Attached Files
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I have placed the code directly inside as you posted, and I am still seeing some trades during the 430-505 timeframe. These trades also create massive overages for me, as this particular one I am posting is a 10 tick target, and yet, the trade yielded a 31 tick fill. I have attached screenshots below showing this.
              Attached Files

              Comment


                #8
                Hello Bobbybattles,

                Thanks for your reply.

                What time zone is your chart in?

                What trading hours template are you using? (Check in the data series of the chart for the row trading hours).
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Paul View Post
                  Hello Bobbybattles,

                  Thanks for your reply.

                  What time zone is your chart in?

                  What trading hours template are you using? (Check in the data series of the chart for the row trading hours).
                  I have opened the data series on the chart, but there is no mention of "trading hours".

                  Where can I find the time zone for the chart?

                  Comment


                    #10
                    Hello Bobbybattles,

                    Thanks for your reply.

                    Sorry, I slipped to NT8 on my trading hours question.

                    In the data series window, what session template are you using?

                    What time zone is your PC clock set to?
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      No problem. PC timezone is CT, as well is the session template timezone.

                      In the data series window, there is nothing selected, just the default "use instrment settings"

                      Comment


                        #12
                        Hello,

                        Thanks for your reply.

                        The session hours for Crude oil (default) are the Nymex Metals / Energy ETH begin at 5:00 PM and end at 4:00 PM (CST). So you have your after session exclusion of 170500 set correctly, however you need to change your end condition hours from 163000 to some value well before 160000 such as 153000.

                        For example:
                        if (Time[0].DayOfWeek != DayOfWeek.Wednesday && ( ToTime(Time[0]) <= 091500 || ToTime(Time[0]) >= 094500))
                        {
                        if (ToTime(Time[0]) >= 153000 && ToTime(Time[0]) <= 170500)
                        {
                        return;
                        }

                        EnterShortLimit(Close[0] - 3 * TickSize);
                        }
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks. I have set the appropraite session instruments, and times as well, and am rerunning a market replay contract. Will let you know how it looks. Thanks for the help.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by maybeimnotrader, Yesterday, 05:46 PM
                          4 responses
                          23 views
                          0 likes
                          Last Post maybeimnotrader  
                          Started by frankthearm, Today, 09:08 AM
                          6 responses
                          25 views
                          0 likes
                          Last Post frankthearm  
                          Started by adeelshahzad, Today, 03:54 AM
                          5 responses
                          33 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by stafe, 04-15-2024, 08:34 PM
                          7 responses
                          32 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by merzo, 06-25-2023, 02:19 AM
                          10 responses
                          823 views
                          1 like
                          Last Post NinjaTrader_ChristopherJ  
                          Working...
                          X