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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    155 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    137 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X