Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time and day filters

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

    Time and day filters

    Hey all,

    I am looking to close any open positions and prevent entry between the times of 1224 and 1235 on Friday. I am using a 60 minute chart, with calculate on close = False.

    What I have is the following;

    Code:
    if (Time[0].DayOfWeek == DayOfWeek.Friday && (ToTime(Times[0]) >= 122400 && ToTime(Time[0]) <= 123500))
    				{
    						ExitShort();
    						ExitLong();
    				}
    				
    				else
                                    {
                                                    // Do something
                                    }
    I can't get this time filter to work in Market Replay, what is it that I am missing?

    #2
    Hello,
    I would first recommend, if you haven't already, to add a print to check that that time filter is
    working. You could do something like Print("Time filter is working Bar Time is " + Time[0]); If you are unfamiliar with working with prints to debug please see the following link: http://ninjatrader.com/support/forum...ead.php?t=3418

    Once you have checked using the print that your time filter is working then that could mean that there is an error with getting the orders to exit. It would be recommended to use TraceOrders to track what the orders are doing and checking for any errors that occurring when the exit orders are submitted. Please see the following link on working with TraceOrders: http://ninjatrader.com/support/forum...ead.php?t=3627
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    51 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    275 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X