Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Between operator in C#, time filter, check values...

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

    Between operator in C#, time filter, check values...

    Hi,
    Is there between operator in C# please? I'm trying to apply a time filter similar to this:

    if (ToDay(Time[0]) "Between" 20101615 and "Tomorrow" 20100300) then plot no signals.

    I'm not sure how to do this correctly. Please help. Which time format to use American -a.m/p.m. or 24 hrs format? I would like to create time filter/restriction in my program to plot no signals between 16:15 today and 03:00 tomorrow morning. I simply want to ignore Asian session and start plotting signals when European session starts. What would be the correct syntax please?

    Another question I have is how to check values of some indicator after session ends please? Thanks to Ninja support I know how to do this during the session with print() and output window... Do I need to run a replay or there is a way to see the value of some indicator at specific time in the past? For ex., what was the value of SMA(50) at 14:00 E.T.? Or better how to see/print the value of indicator where clicked on the chart? Is there a way?
    Thank you very much.
    Art.

    #2
    If (ToTime(Time[0]) < 30000 || ToTime(Time[0]) > 161500)
    no signals
    Last edited by dave1992; 11-06-2010, 01:22 PM. Reason: Fixed the deliberate error ;-)

    Comment


      #3
      Art09, Dave's suggestion looks good, and you can also take a look at the reference sample that goes over how to manipulate DateTime objects.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Thank you very much to Dave and Austin.
        There is one unanswered question below - how to check the values of indicators in the past times, e.g. today (Sat) I'd like to check what was the val. of 50 SMA Past Fri at 14:00 E.T.? Or better yet to print values of indicators on the screen where mouse clicked... Is it possible?
        Thank you.
        Regards, Art.
        Last edited by Art09; 11-06-2010, 07:00 PM.

        Comment


          #5
          Art09, there is also a reference sample that goes over how to access an indicator's value in the past.

          Unfortunately getting the value from a mouse click is not supported.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Hi,
            I have another between question please. How to check if Stoch.K is between 75 and 21? Do I use OR or AND operators to check if Stoch.K is between those numbers? For ex., if Stoch.K[0] < 75 and/or Stoch.K[0] > 21 probably is incorrect bcs if Stoch.K < 75 then it is already or may be > 21... And which is correct please - Stoch.K[0] > 21 or Stoch.K[1] > 21?
            What I want is to check if Stoch.K was rising but did not reach 80 and reversed @76 and is between 75 and 21 and falling-check if cross blw 75-t/f... Then all the the same and betw. 65 and 21 and falling etc... please? Is there an easy way?
            Maybe somebody from community has examples please?
            Thank you all very much.

            Comment


              #7
              if it was < 75 OR > 21 that would be always true, right? Which is useless.

              so it must be < 75 AND > 21, since they're only true when it's between 21 and 75.

              Comment


                #8
                Thank you very much, Dave.
                The first check is always if < 80 then check for cross below - t/f. How can I stop the program from checking if < 75 etc... in this case please? Is there substitution for booleans in C#? If bool 1 false then return bool 2 and the opposite?
                I tried using t/f flags but so far the program checks if < 80 true then cross below, then if < 75 true - cross below again. It works lk if < 80 OR < 75... I have to stop it somehow if < 80 true. And only when the cycle is completed I have to check for < 80, < 75.... again. I want a single cross check per cycle... But how to tell the program that cycle completed at 75 and not at 80?
                Another thing, if Sto< 80 it means it is already or may be less then 75... Confusing...
                Any help with second part of the question please? How to refer to Stoch.K correctly - Stoch.K[0] > 21 or Stoch.K[1] > 21?
                Thank you very much.
                Last edited by Art09; 11-23-2010, 09:28 AM.

                Comment


                  #9
                  Hello,

                  This is more strategy logic that I will have the community assist with. However I would like to mention that our NinjaScript consultants can help with this as well if you still cant get it figured out.


                  NinjaScript Consultants:


                  Let me know if I can be of further assistance.
                  BrettNinjaTrader Product Management

                  Comment


                    #10
                    Thank you Brett.

                    Dave, if you do not mind, please help and reply to [email protected] or send personal message... Whichever you prefer.
                    Thank you.
                    Regards, Art.

                    Comment


                      #11
                      Hi Art,

                      I don't actually fully understand what you're asking. It's also quite involved strategy logic. Have you considered doing a Ninja script tutorial (or reading the help files) and a c# tutorial. I think they'd be useful.

                      regards
                      Dave

                      Comment


                        #12
                        Hi Dave,
                        What I want is simple - if Stoch.K < 80 and falling then check for cross blw-t/f. If false then if Stoch.K < 75 and falling -t/f... < 65 and falling ...< 55 and falling check for cross blw. If one - NOT all - of the crosses is true then stop and plot down arrow. In all those cases the Stoch.K should be between the upper value and 21. What's confusing is if Stoch.K < 80 it is already or may be < 75. Should I write smth lk if Stoch.K > 74 but < 80 then if cross blw 75 - t/f?
                        In SQL there is a Between operator but no such thing in C# unfortunatelly.

                        And Brett or Dave, is second part of the question is for consultants too - Stoch.K[0]<75 && Stoch.K[1] > 21 or Stoch.K[0]<75 && Stoch.K[0] > 21 ? Which is correct please?
                        Thank you very much.
                        Regards, Art.

                        Comment


                          #13
                          Should I write smth lk if Stoch.K > 74 but < 80 then if cross blw 75 - t/f?
                          yes

                          In SQL there is a Between operator but no such thing in C# unfortunatelly.
                          That's really not your problem. Between can be replicated with 100% accuracy.

                          And Brett or Dave, is second part of the question is for consultants too - Stoch.K[0]<75 && Stoch.K[1] > 21 or Stoch.K[0]<75 && Stoch.K[0] > 21 ? Which is correct please?
                          Well, it must be both 0, since 0 and 1 refer to different values, and you just want to check whether one value is in between, right?

                          Comment


                            #14
                            Yes Dave, I want to check if one value is between, thank you.
                            Any example of between replication is appreciated.
                            If between can be replicated then why not make it easier for all and provide such method or operator...? I guess I should not ask this question - no answer required.
                            Thank you very much.
                            Regards, Art.

                            Comment


                              #15
                              Between is simple - it's been shown already on this thread

                              value between 21 and 75

                              is identical to

                              value < 75 and value > 21

                              (where between is not inclusive) There's no seperate method needed.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              669 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              378 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              111 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
                              581 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X