Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

End Plots with Time Setting

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

    End Plots with Time Setting

    if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
    && (Times[3][0].TimeOfDay != EndTimeSet.TimeOfDay))

    I am starting a plot calculation with a set TimeOfDay
    This is or could be an extended Hours chart and has secondary dataseries ie Times[3][0]

    The below starts the Plot as expected time

    if (Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)

    Looking for way to end the Plot at the end of the session so that Plot is not shown into the next session prior to reset

    THIS did not work with != EndTimeSet.TimeOfDay or with < EndTimeSet.TimeOfDay THE EndTimeSet is set to 4:10 PM ie 16:10

    if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
    && (Times[3][0].TimeOfDay != EndTimeSet.TimeOfDay))

    Thanks​

    #2
    Hello DTSSTS,

    For a time condition that spans a period of time you would generally use greater and lesser than the start and end time. There is a sample of a span of time in the following page: https://ninjatrader.com/support/help...ightsub=totime

    Comment


      #3
      As stated in my post "THIS did not work with != EndTimeSet.TimeOfDay or with < EndTimeSet.TimeOfDay " I did try < as well as below

      if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
      && (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay)) << with EndTiimeSet 16:10

      just ignored that

      is Times[3][0].TimeOfDay and (ToTime(Time[3]) ARE THESE THE SAME ? Times[3][0].TimeOfDay works on the start point

      I have try some times using the inputs and had to use the time format below before for them to work, but I need to use the variable for user input
      if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)

      would this make a difference

      if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
      && (ToTime(Time[3]) < EndTimeSet.TimeOfDay))

      or i need to add " To " to this second line

      if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
      && (ToTimes[3][0].TimeOfDay < EndTimeSet.TimeOfDay)) << with EndTiimeSet 16:10

      Thanks​​

      ​Also tried this with NO Compile - does not like == or <

      if (ToTime(Times[3][0]) == TimeSet1.TimeOfDay

      && ToTime(Times[3][0]) < EndTimeSet.TimeOfDay)​
      Last edited by DTSSTS; 04-28-2023, 06:12 AM.

      Comment


        #4
        I tried this as well and it compiles but the End Time to stop the plot from appear still is ignored

        int endTime = ToTime(16, 10, 00);

        if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
        && (ToTime(Times[3][1]) < endTime)) ​

        could it be that I Cannot accomplish my goal here with this method

        Would there be a way to just clear all plots from chart at 4:15 as Session Close

        Thanks again
        Last edited by DTSSTS; 04-28-2023, 07:16 AM.

        Comment


          #5
          Hello DTSSTS,

          Code:
          if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
          && (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay))


          This would only work for the start time, once the start time has passed it won't matter what end time you choose because its no longer going to be equal to the start time.

          A plot will only continue if you keep setting a value to a plot. This is a very simple example where a plot would only be set for a pre determined period of time:

          Code:
          if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)
          {
              Value[0] = Close[0]; // plot the close from 7:45 am to 1:45pm
          }
          If your logic is structured differently and you have the plot being set outside of the time condition it will continue plotting as long as that plotting logic is being called.

          The Times series is the way to access multi series time values, Time[0] would represent the series calling OnBarUpdate which can be any of the series you added, Times[3][0] is a specific series time.




          Comment


            #6
            I do not see what is different I am using

            if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
            && (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay))

            {
            ​ conditions to calculate the value
            }

            else
            {
            more conditions to calculate the value
            }

            ​i have multiple sections that create calculations as above
            then I have all Values defined for the plots

            So where my values are listed I just tried to state

            if (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay) // EndTimeSet is 16:10

            {

            value[0] = xyz;

            }

            BUT THAT HAD NOT EFFECT EITHER

            Thanks

            Comment


              #7
              Hello DTSSTS,

              Code:
              if ((Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)
              && (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay))


              Think about how this will equate when using AND && operator. You are saying if the time of day equals TimeSet1 AND the time is less than EndTimeSet. When the time no longer equals TimeSet1 it wont matter what the EndTimeSet is because that condition is now false. This is not a period of time, its only the TimeSet1 time.

              Code:
              if (Times[3][0].TimeOfDay < EndTimeSet.TimeOfDay) // EndTimeSet is 16:10
              {
                  value[0] = xyz;
              }
              Now think about how this will work in relation to bar processing. This is saying plot as long as the time is less than EndTimeSet. During the current session that is true up until the EndTimeSet. At the beginning of the next session that's going to continue to be true so it will keep plotting as soon as the session starts which will continue the plot.

              If you only want to plot for a specific segment in the session and stop plotting you need to make sure the condition won't be true going into the next session.


              Code:
              if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)
              {
                  Value[0] = Close[0]; // plot the close from 7:45 am to 1:45pm
              }​
              Lets assume the session starts at 7:00am for this example. This is saying if the Time is greater than 7:45 AND less than 1:45pm plot. At 7 am until 7:45 this is false so there is no plot at the start of the session.

              Comment


                #8
                I was in error for the beginning I did not use the EndTimeSet in the conditions ONLY

                if (Times[3][0].TimeOfDay == TimeSet1.TimeOfDay)

                *******************************************

                I want to start the plot at the above condition

                I want to end the plot at EndTimeSet 16:10 so at 6:00 PM or RTH 9:30 AM I want to wait untile the if (Times[3][0].TimeOfDay == TimeSet1.TimeOfDay) occurs to restart the plot

                ********************************************** so the chart is an ETH chart and I used
                if (Times[3][0].TimeOfDay == TimeSet1.TimeOfDay) // to start my plot calculations as before that worked

                // and in my area where I have been creating the values for the plots I added this

                if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 161000)

                COMPILES AN NO LOG ERRORS BUT on the chart it shows calculating and NEVER completes that process SO NO VALUES OR PLOTS

                THANKS​

                Comment


                  #9
                  Hello DTSSTS,

                  If the indicator just shows calculating you may have an error in the script that is being logged to the output window. You can make a condition similar to what I posted using your existing DateTime objects.

                  Code:
                  if (ToTime(Times[3][0]) >= ToTime(TimeSet1) && ToTime(Times[3][0]) <= ToTime(EndTimeSet))
                  This is saying if the Times[3][0] is greater or equal to the TimeSet1 and is also less or equal to EndTimeSet which creates a window of time.

                  Comment


                    #10
                    My data for MNQ stopped flowing at 11: 10 am so I am not sure if that is why calculating is STUCK, I change my script back to what is was and still stuck on calculations
                    MES data is still current on the charts

                    this happen yesterday as well. today entire platform locked after I tried to disconnect form Kinetick

                    Last edited by DTSSTS; 04-28-2023, 10:45 AM.

                    Comment


                      #11
                      Hello DTSSTS,

                      If you are having data or platform problems I would suggest to split that off into a new thread in the platform technical support section. For right now I would suggest to exit NinjaTrader and restart it then reconnect to see if that helps with the chart and indicator being stuck.

                      Comment


                        #12
                        yes that was the issue of stuck on calculating, restarted and NOW what you have been assisting with is working as expected

                        THANKS !!!!!!!!!!!!!!!!!!!!!!!! I GOT IT

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        597 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        343 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        103 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        556 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        555 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X