Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    22 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X