Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DayOfWeek or ToTime or Time?

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

    DayOfWeek or ToTime or Time?

    Anyone know how to set it up to have your system NOT take entry trades after a certain time Friday but it will take trades any other day of the week? Thank you!

    GT

    #2
    You would need a combination of both.



    if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime....)
    // Do something
    RayNinjaTrader Customer Service

    Comment


      #3
      Problems with day of week

      Hello good morning, what is the way to write code in c # if it's Monday, Tuesday or Wednesday, including in market.

      I'm doing well but the code breaks.

      if(Position .MarketPosition != MarketPosition .Long )
      if (Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday ||Time[0].DayOfWeek == DayOfWeek.Wednesday )
      if ( Close [0] > Open [1] )
      if (T3Time (Time[0])>=hc// 1530

      && T3Time (Time[0])<= hf)//2200
      {
      EnterLong ();
      SetProfitTarget (CalculationMode .Ticks ,profit);
      SetStopLoss (CalculationMode .Ticks ,loss);
      }

      That is because not working properly?.

      Thank you very much.

      Comment


        #4
        Hello optimuss,
        In your code you have coded like T3Time. There is no function like that. It should be ToTime. Please try the below code and please see if it compiles or not
        if(Position .MarketPosition != MarketPosition .Long )
        {
        if (Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday ||Time[0].DayOfWeek == DayOfWeek.Wednesday )
        if ( Close [0] > Open [1] )
        if (ToTime (Time[0])>=hc// 1530

        && ToTime (Time[0])<= hf)//2200
        {
        EnterLong ();
        SetProfitTarget (CalculationMode .Ticks ,profit);
        SetStopLoss (CalculationMode .Ticks ,loss);
        }
        }

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hello to Totime fails, the code breaks alike. Where is the problem?.


          if(Position .MarketPosition != MarketPosition .Long )
          if (Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday ||Time[0].DayOfWeek == DayOfWeek.Wednesday )


          if(Close[0]-Open [1] )

          if (ToTime (Time[0])>=153000
          && ToTime (Time[
          0])<= 220000)
          {
          EnterLong ();
          SetProfitTarget (CalculationMode .Ticks ,profit);

          SetStopLoss (CalculationMode .Ticks ,loss);

          }


          Thank you very much.

          Comment


            #6
            Hello optimuss,
            What error you are getting? Can you send a screenshot of it.


            • Open NinjaTrader
            • From the Control Center select the Tools menu--> select the Edit NinjaScript menu item--> select Strategy
            • Select the strategy and double click on it.
            • A new window will appear and you will need to right click in the window and select Compile to compile the indicators.
            • At the bottom of the window a new section will appear were you can find the error locations.

            Here is a video of the above instructions.
            World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


            Please let us know the exact error messages you're seeing within the NinjaScript compile and we can provide the next steps. A screenshot will be helpful for us to identify.


            To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.
            For detailed instructions please visit the following link

            * http://take-a-screenshot.org/

            I look forward to assisting you further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Hello the error is not to copilar here no problem, but the test back this wild and does not match what was written in code.

              Notice how he makes the following entry has nothing to do with;
              if (Close [0]> Open [1])

              What can happen?, Thanks.
              Attached Files

              Comment


                #8
                Hello optimuss,
                Can you send the "toy code"* to support[AT]ninjatrader[DOT]com so that I an test it at my end.

                Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

                I look forward to assisting you further.

                *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Ok, as you pass the code by mail, greetings

                  Comment


                    #10
                    Hello optimuss,
                    This is to confirm that I have received the code and will be replying to you via email.
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by optimuss View Post
                      Hello the error is not to copilar here no problem, but the test back this wild and does not match what was written in code.

                      Notice how he makes the following entry has nothing to do with;
                      if (Close [0]> Open [1])

                      What can happen?, Thanks.
                      Your DayOfWeek filter does nothing. It just stands there. You would need to encase your code that you want to be filtered, into a code block that is dependent on the filter.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      666 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      377 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      110 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      575 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      580 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X