Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optionally Run Time-Based Trading Rule

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

    Optionally Run Time-Based Trading Rule

    Good morning! I'd like to use a time filter, which I understand from examples. I'd like to use this time filter optionally and set up a bool. Testing this morning, it was not filtering when TimeFrame was set to true. Is there a better method or is there a problem with this method?



    StartTime = DateTime.Parse("08:45", System.Globalization.CultureInfo.InvariantCulture) ;
    EndTime = DateTime.Parse("14:45", System.Globalization.CultureInfo.InvariantCulture) ;
    ​TimeFilter = true;


    if ((TimeFilter == true && (Times[0][0].TimeOfDay >= StartTime.TimeOfDay) && (Times[0][0].TimeOfDay < EndTime.TimeOfDay)) || (TF == false))


    #2
    Hello trilliantrader,

    For this type of question I would suggest adding a Print to output the values you have used in your condition. That will let you see what the Time values are to get a better idea of what is happening with the condition.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 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