Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not taking live trades but showing historical trades

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

    #31
    Hello, Chelsea B,

    I added a screen shot of what I'm working on. When I do timespan check between 1700 and 2400, the globex levels will plot. But when I do a check between 1700 and 0830, they will not and Im not getting any error messages.

    if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(24, 00, 00))
    {

    Print(Times[0][0].TimeOfDay);
    ONOpen[0] = CurrentDayOHL1.CurrentOpen[0];
    ONHigh[0] = CurrentDayOHL1.CurrentHigh[0];
    ONLow[0] = CurrentDayOHL1.CurrentLow[0];
    }
    Attached Files

    Comment


      #32
      Hello AdeptistJune,

      The transfer limit for wetransfer is 2GB. If the file you are trying to attach is that large, you need to reduce the data to a single day or couple of days where the behavior occurs, clear the output window, and run the script again to get smaller output.

      Time[0] is the time of the bar.

      Times[0][0].TimeOfDay will have the time without the date.

      From your condition:
      if (Times[0][0].TimeOfDay >= new TimeSpan(08, 30, 00) && Times[0][0].TimeOfDay <= new TimeSpan(17,00, 00))

      Look at your output.
      Session 6: Wednesday at 1700 to Thursday at 830 | CurrentDayOHL1.CurrentOpen: 4689

      What time of the bar is the print associated with?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #33
        I finally can upload the file. Here it is
        Attached Files

        Comment


          #34
          Hello AdeptistJune,

          The condition that is not evaluating as true:
          Code:
          if (Times[0][0].TimeOfDay >= new TimeSpan(08, 30, 00) && Times[0][0].TimeOfDay <= new TimeSpan(17,00, 00))
          The print to understand why this is not evauating as true:
          Code:
          Print(string.Format("{0} | Times[0][0].TimeOfDay: {1} >= new TimeSpan(08, 30, 00): {2} && Times[0][0].TimeOfDay: {1} <= new TimeSpan(17,00, 00): {3}", Time[0], Times[0][0].TimeOfDay, new TimeSpan(08, 30, 00), new TimeSpan(17,00, 00)));
          Please re-review the post on using prints to understand behavior for an example of printing all values used in a condition to understand why the condition is not evaluating as true.

          Should we focus on the first print in the output? On that first print did the condition evaluate as false?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #35
            Hello Chelsea

            This is the condition I'm evaluating as true:
            if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(08,30, 00))

            When I evaluate this condition, and I don't see any prints, is it because the condition is not evaluating as true?
            Last edited by AdeptistJune; 12-26-2021, 07:56 PM.

            Comment


              #36
              Hello AdeptistJune,

              If there is a print within the action block of this condition that is not printing, the code is not being reached because the condition is not evaluating as true.

              The print I suggested, printed above and outside of the condition will tell us for each bar, why the condition will evaluate as true or false.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #37
                I added the print outside the condition
                Attached Files

                Comment


                  #38
                  Hello AdeptistJune,

                  The first line is showing the time of the bar is outside of the time range in the condition.
                  12/20/2021 5:02:00 PM | Times[0][0].TimeOfDay: 17:02:00 >= new TimeSpan(08, 30, 00): 08:30:00 && Times[0][0].TimeOfDay: 17:02:00 <= new TimeSpan(17,00, 00): 17:00:00

                  17:02 is after 17:00.

                  But there are times i would expect the condition to be true.
                  12/21/2021 8:30:00 AM | Times[0][0].TimeOfDay: 08:30:00 >= new TimeSpan(08, 30, 00): 08:30:00 && Times[0][0].TimeOfDay: 08:30:00 <= new TimeSpan(17,00, 00): 17:00:00
                  8:30 is equal to and is less than 17:00.

                  Testing the suggested code on my end, I am seeing the print appear.
                  12/20/2021 4:01:00 PM | Times[0][0].TimeOfDay: 16:01:00 >= new TimeSpan(08, 30, 00): 08:30:00 && Times[0][0].TimeOfDay: 16:01:00 <= new TimeSpan(17,00, 00): 17:00:00
                  12/20/2021 4:01:00 PM | Condition true
                  Attached Files
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #39
                    Okay, correct me if I'm wrong: The reason my condition will not evaluate true is because the time of the bar is outside of the time range in the condition?

                    Comment


                      #40
                      Hello AdeptistJune,

                      That would be my assumption. Is the test script with that same condition I've provided printing between the hours of the range on your end?.

                      Is your condition in your script within another condition?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #41
                        Is the test script with that same condition I've provided printing between the hours of the range on your end? Yes, but the condition is only true up to 4:00pm and the next check is 5:01pm, not 5:00 pm. Why is that?

                        Comment


                          #42
                          Hello AdeptistJune,

                          Depending on your time zone and the instrument you are looking at, could be the start of a new session.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #43
                            Why will the condition if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(08,30, 00)) not evaluate true when the time of the bar is inside the time range in the conditions?

                            Comment


                              #44
                              Hello AdeptistJune,

                              I disagree. It will. I provided a test script and tested and it prints without issue when the bar time is between the range.

                              What happened when you tested it?
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #45
                                Good morning, Chelsea,

                                Here is what I'm seeing.

                                protected override void OnBarUpdate()
                                {
                                Print(string.Format("{0} | Times[0][0].TimeOfDay: {1} >= new TimeSpan(17, 00, 00): {2} && Times[0][0].TimeOfDay: {1} <= new TimeSpan(08,30, 00): {3}", Time[0], Times[0][0].TimeOfDay, new TimeSpan(17, 00, 00), new TimeSpan(08,30, 00)));

                                if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(08,30, 00))
                                {
                                Print(Time[0] + " | Condition true");
                                }
                                }
                                Attached Files

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                64 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                139 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X