Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timespan Problem.

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

    Timespan Problem.

    I'm trying to create a strategy that uses the TimeSpan object to conduct trades.
    Here is a simplified version of what I want to do, without any actual logic behind the trades.

    Click image for larger version

Name:	image.png
Views:	138
Size:	14.7 KB
ID:	1314730

    I am currently using Calculate.OnEachTick. The program detects when it is the first Tick of the bar, but it never runs the If statement to sell after 30 seconds have gone by.

    Am I doing something wrong? Please get back to me when you can.

    #2
    Hello Matthagoras,

    Add debugging prints to understand the issue.


    Print the current bar time, print the entry time, and print the span.TotalSeconds.
    Enable TraceOrders.

    Save the output (right-click the output window, select Save As) and attach the text file to your next post.

    Let us know the bar time where you are expecting the condition to evaluate as true.

    I would be happy to assist in analyzing the output.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Alright, I changed the code a little bit to print the times:
      Click image for larger version

Name:	image.png
Views:	131
Size:	20.3 KB
ID:	1314799

      The Output that I'm given is:
      Click image for larger version

Name:	image.png
Views:	131
Size:	11.0 KB
ID:	1314800

      It seems to only counting the minutes. The data series that I am currently working with is 1 minute intervals. Will i have to change that to seconds to have this work the way I want it to?

      Comment


        #4
        Hello Matthagoras,

        To save the output to a text file right-click the Output Window and select Save As.

        The output you are showing is showing the bar time and entry time as the same date and time so the timespan between would be 0.

        Yes, if you want to measure seconds, the bar type selected in the Data Series window would have to be set to 1 Second.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for clearing that up. Have a great day

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          557 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X