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

Lost Entry Signal

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

    Lost Entry Signal

    I have a strategy that enters x number of days before a set date. Yet, if the entry day falls on a Saturday or Sunday the trade does not execute. Is there any type of code I can use so that when this happens the strategy will fall on either the Friday before hand or the the following Monday?

    #2
    Hi cboat,

    Perhaps you can build a filter to see if check if the entry will occur on a certain day of the week, then resubmit accordingly using Time[0].DayOfWeek

    More info at - http://www.ninjatrader-support.com/H...html?DayOfWeek

    Creating a custom time filter example at - http://www.ninjatrader.com/support/f...ead.php?t=3226
    Last edited by NinjaTrader_Tim; 06-09-2010, 02:21 PM.
    TimNinjaTrader Customer Service

    Comment


      #3
      I have the filter that uses an if statement such as this

      if(Time[0].DayOfWeek == DayOfWeek.Saturday)
      {

      }

      Yet i am unsure as to how i would have the order resubmit on that following monday.

      Comment


        #4
        Hi cboat,

        A few options...

        You can return out, something like...
        Code:
        if(Time[0].DayOfWeek == DayOfWeek.Saturday || Time[0].DayOfWeek == DayOfWeek.Sunday)
        return;
        or, you can set a bool flag, something like...
        Code:
        if (Time[0].DayOfWeek == DayOfWeek.Saturday)
        weekendBool = true;
        
        if (Time[0].DayOfWeek == DayOfWeek.Monday)
        weekendBool = false;
        
        if(entry conditions && weekendBool ==false)
        do something;
        TimNinjaTrader Customer Service

        Comment


          #5
          The boolean seems to be the way I would like to go the only problem with it is when I do it that way the trade gets completely skipped. I would rather find a way that the trade would execute just at a later time.

          Comment


            #6
            Hi cboat,

            The entry doesn't get executed when you try this? Can you clarify, and provide code snippet of your implementation?
            TimNinjaTrader Customer Service

            Comment


              #7
              The strategy is designed to enter "x" amount of days before a given date. Now if x amount of days happens to fall on a saturday or sunday the trade is skipped. I would like to find a way that if the entry signal falls onto one of these days that it would enter on that following monday.

              today = Time[0];
              entryDate1 = XXXX.AddDays(XXX);

              if (entryDate1 == today)
              {

              }



              The strategy works for everything except if the entryDate falls on a saturday or sunday

              Comment


                #8
                Hi cboat,

                You can check with a conditon if you strategy condition lands on a Saturday, then add the entryDate1 the appropriate number of days to execute on Monday instead.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  so would it be something like

                  if(entrydate = DayOfWeek.Saturday)
                  {
                  entrydate.AddDays
                  }

                  Comment


                    #10
                    Hi cboat,

                    Yes, that should do it, have you tried this on your end?
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      Yes I have already tried this. It doesn't seem to be working. Would I have to create another DateTime variable maybe "entrydate1add"?
                      Last edited by cboat; 06-14-2010, 08:06 AM.

                      Comment


                        #12
                        Hi cboat,

                        You can set the original variable to this, something like...
                        Code:
                        entrydate = entrydate.AddDays
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          OK this is what i have at the moment.

                          if( entryDate1 == DayOfWeek.Saturday)
                          {
                          entryDate1 = entryDate1.AddDays(2);
                          }

                          When I compile I get the error that "Operator '==' cannot be applied to operands of type 'System.DateTime' and 'System.DayOfWeek'

                          Is there something simple i am missing?

                          Comment


                            #14
                            Hi cboat,

                            Try...

                            Code:
                            if (entryDate1.DayOfWeek == DayOfWeek.Saturday)
                            TimNinjaTrader Customer Service

                            Comment


                              #15
                              Excellent Thank you very much. My last question although it isn't that important at the moment is:

                              Is there anyway that when using the adddays function that it would not count saturday or sunday?

                              I am just worried that during backtesting I will be getting unreliable data.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Skifree, Today, 03:41 AM
                              5 responses
                              13 views
                              0 likes
                              Last Post Skifree
                              by Skifree
                               
                              Started by Mongo, Today, 11:05 AM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by traderqz, Today, 12:06 AM
                              6 responses
                              13 views
                              0 likes
                              Last Post traderqz  
                              Started by traderqz, Yesterday, 09:06 AM
                              5 responses
                              34 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by guillembm, Today, 11:25 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X