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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    167 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    88 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    128 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    208 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    185 views
    0 likes
    Last Post CarlTrading  
    Working...
    X