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

Timefilter

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

    Timefilter

    i can not manage it to limit a time filter. I can set a starting point but the end point is not respected. Like in this basic expression:

    // Set 1
    if ((Times[0][0].TimeOfDay > new TimeSpan(17, 1, 0))
    && (GetCurrentAsk(0) > EMA1[0])
    && (Times[0][0].TimeOfDay < new TimeSpan(20, 0, 0)))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }


    what am i doing wrong?

    #2
    Hello smk200, thanks for your note.

    I made a clone script that works. Please see attached. Could you test this on your end and compare it with your custom script?

    I look forward to assisting.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      thank you for answer. i have tested your file but the end is not respected as well. i would be verry happy if you could if you find a solution.

      Comment


        #4
        Hello, thanks for your reply.

        Could you let me know what instrument, bar type, and bar period you are using to test?

        I look forward to hearing from you.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          i tested several futures in various periods. bar type is probably candlestick

          Comment


            #6
            Hello smk200, thanks for your reply.

            I am testing on a 1 minute ES 03-21 chart. Please add a Print statement to your script for debugging purposes. Printing the Times[0][0] value in your entry condition to print the time when the condition is true:

            if ((Times[0][0].TimeOfDay > new TimeSpan(17, 1, 0))
            && (GetCurrentAsk(0) > EMA1[0])
            && (Times[0][0].TimeOfDay < new TimeSpan(20, 0, 0)))
            {
            Print(Times[0][0]);
            EnterLong(Convert.ToInt32(DefaultQuantity), "");
            }

            The Print method can be found in the Misc folder in the actions. If you are seeing a time outside of the conditions printing I could take a look at your script if you Export it and post it here.

            Another good addition to the condition will be a check for Position.MarketPosition = MarketPosition.Flat so the strategy is not entering when already long e.g.



            I look forward to assisting.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Stanfillirenfro, Today, 07:23 AM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            2 responses
            19 views
            0 likes
            Last Post cmtjoancolmenero  
            Started by olisav57, Yesterday, 07:39 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by cocoescala, 10-12-2018, 11:02 PM
            7 responses
            943 views
            0 likes
            Last Post Jquiroz1975  
            Started by oviejo, Today, 12:28 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X