Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time is Time?

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

    Time is Time?

    Hello,

    I have added to my scripts as last step timefilter. After working for years now with script coding this drives me crazy. The plotting and the variables referring the time show different as it should be.

    I have set "Time[0].ToString()" in onstartup to show what time when enabling the script and its different from the time-axis

    And in the code I have in onbarupdate with flag (and I plot the bool in chart to see if true and false).
    if(readfile1 == true && ToTime(Time[0]) > 90000 && ToTime(Time[0]) < 100000)
    {readfile1 == false
    Drawline......
    }

    if(readfile2 == true && ToTime(Time[0]) > 100000 && ToTime(Time[0]) < 110000)
    {readfile2 == false
    Drawline......
    }

    But when enabling both bools are immediately false (to debug I see my drawtext in chart false and the lines are plotted). But it should read only at the time in code.

    ???

    Is there anything to add to have the time of current day only maybe?

    Thanks
    Tony
    Last edited by tonynt; 04-03-2016, 06:30 AM. Reason: Clearifiying, typing error

    #2
    Originally posted by tonynt View Post
    Hello,

    I have added to my scripts as last step timefilter. After working for years now with script coding this drives me crazy. The plotting and the variables referring the time show different as it should be.

    I have set "Time[0].ToString()" in onstartup to show what time when enabling the script and its different from the time-axis

    And in the code I have in onbarupdate with flag (and I plot the bool in chart to see if true and false).
    if(readfile1 == true && ToTime(Time[0]) > 90000 && ToTime(Time[0]) < 100000)
    {readfile1 == false
    Drawline......
    }

    if(readfile2 == true && ToTime(Time[0]) > 100000 && ToTime(Time[0]) < 110000)
    {readfile2 == false
    Drawline......
    }

    But when enabling both bools are immediately false (to debug I see my drawtext in chart false and the lines are plotted). But it should read only at the time in code.

    ???

    Is there anything to add to have the time of current day only maybe?

    Thanks
    Tony
    And where do you ever set your bools to true again?

    Comment


      #3
      Hi koganam,

      thanks for your reply. In another step (end of day) I read the empty levels (file is empty) that time and there I set the bools to true also.

      But my issue is not to set it back to true, the problem is that when I start the script it performs what is coded with readfile2, but this should be done only after time 100000. This is the issue.

      Tthe strange thing is that the backcoloring (I do also for debugging) is exactly with my conditions, but readfile2 (from the example above) is done BEFORE Time 10000 and sets the bool to false before 100000. It should read after 100000 with the conditon above, no?

      Best
      Tony
      Last edited by tonynt; 04-03-2016, 02:16 PM. Reason: Clearifying

      Comment


        #4
        Originally posted by tonynt View Post
        Hi koganam,

        thanks for your reply. In another step (end of day) I read the empty levels (file is empty) that time and there I set the bools to true also.

        But my issue is not to set it back to true, the problem is that when I start the script it performs what is coded with readfile2, but this should be done only after time 100000. This is the issue.

        Tthe strange thing is that the backcoloring (I do also for debugging) is exactly with my conditions, but readfile2 (from the example above) is done BEFORE Time 10000 and sets the bool to false before 100000. It should read after 100000 with the conditon above, no?

        Best
        Tony
        I am not quite sure what you are trying to do, so it is hard to say, but the code will be processed in the order that it is written. That means that in transitioning from one day to the next, readfile2 today will print before readfile1 tomorrow. By the same token readfile2 today will process before readfile2 today. Are you sure you are looking at a single day in order to see precedence?

        Comment


          #5
          Hello koganam,

          thank you so much for your reply!

          I´m trying to read a csv file when time is > 90000 and time < 100000 and to read it only once I set a bool.
          Then the SR values change and it should read from the csv file with time > 100000 and time < 110000 and I set this bool also false so that it reads only one time this hour.
          Then it should read next hour....and I set every bool to false.
          And in the chart I see with drawtext that all bools are false immediately and the lines are plotted even when for testing I set in the code a time one hour later. Why does it read before the coded time is true?
          At end of day when time > 163000 I read again (the csv file is empty) and I set the bools on true for next day.

          Next day (lets assume script runs 24/5) it should read again after 90000 referring the time condition and readfile1 is true again.

          Thats it. It´s totally strange for me why it reads immediately and not in the coded time. (I have all in onbarupdate as the other conditions).

          Thanks
          Tony
          Last edited by tonynt; 04-03-2016, 02:49 PM. Reason: clearifying, translation error

          Comment


            #6
            Originally posted by tonynt View Post
            Hello koganam,

            thank you so much for your reply!

            I´m trying to read a csv file when time is > 90000 and time < 100000 and to read it only once I set a bool.
            Then the SR values change and it should read from the csv file with time > 100000 and time < 110000 and I set this bool also false so that it reads only one time this hour.
            Then it should read next hour....and I set every bool to false.
            And in the chart I see with drawtext that all bools are false immediately and the lines are plotted even when for testing I set in the code a time one hour later. Why does it read before the coded time is true?
            At end of day when time > 163000 I read again (the csv file is empty) and I set the bools on true for next day.

            Next day (lets assume script runs 24/5) it should read again after 90000 referring the time condition and readfile1 is true again.

            Thats it. It´s totally strange for me why it reads immediately and not in the coded time. (I have all in onbarupdate as the other conditions).

            Thanks
            Tony
            Given the pieces of what you are describing, someone may have to take a look at your entire code. You may have to ask NT Support if they are willing to do so.

            Comment


              #7
              Hi koganam,

              I tried to figure it out by different colors of line drawing with

              if(readA==0 and time >170000 and <180000 ) ...Drawline Blue, readA==1,
              ifI(readB==0 and time >190000) Drawline Red, readB==1

              When starting testscript at 173000 first there were lines in Blue and then in Red, means that NT reads the other file before 190000, but it should only do only after 190000 referring the code. Seems that 172000 today is for NT also ">190000" from the code - but 190000 from yesterday(???)

              Thanks
              Tony
              Last edited by tonynt; 04-03-2016, 03:33 PM. Reason: Clearifiying

              Comment


                #8
                Originally posted by tonynt View Post
                Hi koganam,

                I tried to figure it out by different colors of line drawing with

                if(readA==0 and time >170000 and <180000 ) ...Drawline Blue, readA==1,
                ifI(readB==0 and time >190000) Drawline Red, readB==1

                When starting testscript at 173000 first there were lines in Blue and then in Red, means that NT reads the other file before 190000, but it should only do only after 190000 referring the code. Seems that 172000 today is for NT also ">190000" from the code - but 190000 from yesterday(???)

                Thanks
                Tony
                How do you know when the line was drawn?
                How do you know that it is not just the old line?
                Did you ever delete the line that was already drawn the last time?

                Comment


                  #9
                  Hi,

                  * I have the time in the code and I have DrawLine(...."colorA")

                  * I read the csv again 5 minutes later and from code with DrawlIne(...."colorB")

                  * I did not delete the line that was drawn 5 minutes before because at this moment of "investigation" this was not the important thing for me

                  The question is why it continues reading and drawline (..."colorC") before time for readB which is 190000 and only in one hour from now. Seems that NT interpretes the time now as bigger than 190000 (from yesterday). If this is the reason then the condition for readB should be > 190000 and < 235900 (???)

                  Best
                  Tony

                  Comment


                    #10
                    Originally posted by tonynt View Post
                    Hi,

                    * I have the time in the code and I have DrawLine(...."colorA")

                    * I read the csv again 5 minutes later and from code with DrawlIne(...."colorB")

                    * I did not delete the line that was drawn 5 minutes before because at this moment of "investigation" this was not the important thing for me

                    The question is why it continues reading and drawline (..."colorC") before time for readB which is 190000 and only in one hour from now. Seems that NT interpretes the time now as bigger than 190000 (from yesterday). If this is the reason then the condition for readB should be > 190000 and < 235900 (???)

                    Best
                    Tony
                    As I said before, your code idea seems rather a bit complex, so someone will need to look at your code.

                    I cannot clearly follow what you are saying. If you are conditionally drawing objects which never get deleted, and whose tag is not understood by me, then it becomes simply impossible to understand all the moving pieces.

                    Comment


                      #11
                      Hi,

                      let me reduce it to the core (there is no problem with code and lines):

                      if(readB==0 and time >190000){ Drawline Red, readB==1...}

                      Why are the lines drawn and readB=1 at time opf 173000? Because 173000 is for NT "time >190000"? (173000 of today > 190000 yesterday = correct) But how to avoid this.

                      Thats it.

                      Best
                      Tony

                      Comment


                        #12
                        Originally posted by tonynt View Post
                        Hello koganam,

                        thank you so much for your reply!

                        I´m trying to read a csv file when time is > 90000 and time < 100000 and to read it only once I set a bool.
                        Then the SR values change and it should read from the csv file with time > 100000 and time < 110000 and I set this bool also false so that it

                        Thanks
                        Tony
                        I have code that does this.

                        Comment


                          #13
                          Originally posted by tonynt View Post
                          Hi koganam,

                          I tried to figure it out by different colors of line drawing with

                          if(readA==0 and time >170000 and <180000 ) ...Drawline Blue, readA==1,
                          ifI(readB==0 and time >190000) Drawline Red, readB==1

                          When starting testscript at 173000 first there were lines in Blue and then in Red, means that NT reads the other file before 190000, but it should only do only after 190000 referring the code. Seems that 172000 today is for NT also ">190000" from the code - but 190000 from yesterday(???)

                          Thanks
                          Tony

                          Code:
                          			if (   ToTime(Time[0]) >= ToTime( 08, 45, 00)
                          				&& ToTime(Time[0]) <= ToTime( 08, 58, 00)) 
                          			{
                          				if ( dataloaded == 0 )
                          				{		
                          
                          					//load data	
                          
                          [I]... read the file store in lists....[/I]
                          
                          
                          						dataloaded = 1; //have data
                          						//Print ( "Dataloaded!" );
                          						indexCount = 0;
                          					}
                          					catch (IOException ex)
                          					{
                          						dataloaded = -1; //no data
                          						indexCount = 0;
                          
                          						Print ( "IOException File Read Error " + ex.ToString() );
                          					}
                          					
                          					catch (Exception ex)
                          					{
                          						dataloaded = -1; //no data
                          						indexCount = 0;
                          
                          						Print ( "Exception General Error " + ex.ToString() );
                          					}
                          				}
                          
                          [I]...then during market replay time, process the lists...
                          [/I]
                          			if (   ToTime(Time[0]) >= ToTime( 09, 00, 00)
                          				&& ToTime(Time[0]) <= ToTime( 16, 10, 00)
                          				&& dataloaded == 1 ) //have data
                          			{
                          
                          [I]..then reset dataLoaded flag[/I]
                          
                          
                          			if ((   ToTime(Time[0]) >= ToTime( 16, 00, 00)
                          				&& ToTime(Time[0]) <= ToTime( 16, 30, 00)) 
                          			
                          			{
                          				dataloaded = 0; //reset to check for data

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by GwFutures1988, Today, 02:48 PM
                          1 response
                          4 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by ScottWalsh, 04-16-2024, 04:29 PM
                          6 responses
                          28 views
                          0 likes
                          Last Post ScottWalsh  
                          Started by frankthearm, Today, 09:08 AM
                          10 responses
                          36 views
                          0 likes
                          Last Post frankthearm  
                          Started by mmenigma, Today, 02:22 PM
                          1 response
                          3 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by NRITV, Today, 01:15 PM
                          2 responses
                          9 views
                          0 likes
                          Last Post NRITV
                          by NRITV
                           
                          Working...
                          X