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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          46 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          22 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          33 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          50 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          42 views
          0 likes
          Last Post CarlTrading  
          Working...
          X