Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading Start Date.

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

    Trading Start Date.

    I am using the following code to prevent trading before a particular start date but it seems to be blocking all tarding and I cant see why, maybe fresh eyes on it would help.

    if(
    ((Instrument.Expiry.Month == 3) && (Time[0].Date.Month == 12) && (Time[0].Date.Day < iStartTradeDate))
    || ((Instrument.Expiry.Month == 3) && (Time[0].Date.Month >3) || (Time[0].Date.Month <12))
    || ((Instrument.Expiry.Month == 6) && (Time[0].Date.Month == 3) && (Time[0].Date.Day < iStartTradeDate))
    || ((Instrument.Expiry.Month == 6) && (Time[0].Date.Month >6) || (Time[0].Date.Month <3))
    || ((Instrument.Expiry.Month == 9) && (Time[0].Date.Month == 6) && (Time[0].Date.Day < iStartTradeDate))
    || ((Instrument.Expiry.Month == 9) && (Time[0].Date.Month >9) || (Time[0].Date.Month <6))
    || ((Instrument.Expiry.Month == 12) && (Time[0].Date.Month == 9) && (Time[0].Date.Day < iStartTradeDate))
    || ((Instrument.Expiry.Month == 12) && (Time[0].Date.Month <9))
    )
    return;

    #2
    GKonheiser,

    Thank you for your post.

    What is the value of iStartTradeDate?

    Additionally, can you add a Print Statement with the return?

    Example - after the last closing parenthesis
    {
    Print("IF statement is true: " + Time[0]);
    return;
    }

    Check the Output window and see if this called on every bar.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Ya it was firing true the whole time. I had to add extra brackets and is working fine now,

      if(
      ((Instrument.Expiry.Month == 3) && (Time[0].Date.Month == 12) && (Time[0].Date.Day < iStartTradeDate))
      || ((Instrument.Expiry.Month == 3) && ((Time[0].Date.Month >3) || (Time[0].Date.Month <12)))
      || ((Instrument.Expiry.Month == 6) && (Time[0].Date.Month == 3) && (Time[0].Date.Day < iStartTradeDate))
      || ((Instrument.Expiry.Month == 6) && ((Time[0].Date.Month >6) || (Time[0].Date.Month <3)))
      || ((Instrument.Expiry.Month == 9) && (Time[0].Date.Month == 6) && (Time[0].Date.Day < iStartTradeDate))
      || ((Instrument.Expiry.Month == 9) && ((Time[0].Date.Month >9) || (Time[0].Date.Month <6)))
      || ((Instrument.Expiry.Month == 12) && (Time[0].Date.Month == 9) && (Time[0].Date.Day < iStartTradeDate))
      || ((Instrument.Expiry.Month == 12) && ((Time[0].Date.Month >12) || (Time[0].Date.Month <9)))
      )

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      630 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      566 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X