Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable Strategy after a certain date

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

    Disable Strategy after a certain date

    I would like to have a strategy disable itself when a specified date is reached (Time bomb). I've been trying the Date.Time.Now without sucess.

    Thanks

    #2
    Hello mlarocco,

    Are you printing the values used in the condition to confirm the condition is evaluating as true?


    Are there labels in your prints to show what each value is?

    Is there a print in the action block of the condition set to show the logic is being reached?

    Are you calling SetState(Terminated), or CloseStrategy(), or are you calling return to prevent logic execution without disabling the script?

    Are you printing the State to confirm the State has not changed?

    Please provide the output from the prints saved to a text file and I will be happy to assist with analyzing the output.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello mlarocco,

      Are you printing the values used in the condition to confirm the condition is evaluating as true?


      Are there labels in your prints to show what each value is?

      Is there a print in the action block of the condition set to show the logic is being reached?

      Are you calling SetState(Terminated), or CloseStrategy(), or are you calling return to prevent logic execution without disabling the script?

      Are you printing the State to confirm the State has not changed?

      Please provide the output from the prints saved to a text file and I will be happy to assist with analyzing the output.
      I'm really not getting that far. I thought I could use if (DateTime.Now < (some future date/time) but I can't get the syntax correct, it won't compile no matter what I try

      Comment


        #4
        Hello mlarocco,

        If you are having a compile error you want assistance with, please provide the full error message and the line of code.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello mlarocco,

          If you are having a compile error you want assistance with, please provide the full error message and the line of code.
          I figured it out, this code works...

          if (ToDay(Time[0]) > 20220608)
          {
          Print ("Strategy is Disabled");
          CloseStrategy("Disable");
          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X