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:	153
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:	146
Size:	20.3 KB
ID:	1314799

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

Name:	image.png
Views:	151
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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          51 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          142 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          275 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X