PDA

View Full Version : ToDay(Time[0])


ATI user
01-26-2010, 11:30 PM
I need to check against a fixed date in both replay and live

1. it is 27 jan....why does ToDay(Time[0]) print 20100126...i.e. which time zone does it use so I can adjust for mine...this works fine for live feed but not in replay
ToDay(Time[0]) 20100126
DateTime.Now 1/27/2010 8:02:44 AM

2. if I use
if ( DateTime.Now.Ticks > Time[0].Ticks )
it does not work for live feed because the ticks are off like this on live feed:

DateTime.Now.Ticks 634001516115070000
Time[0].Ticks 634000950200000000

looks like they will always be off...how can I adjust for 10 mins for instance

NinjaTrader_Josh
01-27-2010, 08:22 AM
ATI user,

Not sure how DateTime.Now is relevant.

ToDay(Time[0]) gives you the date portion of the timestamp of the bar. I am not sure why you feel this is not working in a replay. If your bars are 1/27 then you will get 1/27. Since you are using a replay, they are most likely 1/26 replay bars so that is what you will get then.

ATI user
01-27-2010, 09:47 AM
no...I test back to 4 Jan and the date shown from ToDay(Time[0]) is further back in dec for some reason

please comment re 1 and 2 above...i.e. why is the 26th printing on the 27th...etc...and how to use
DateTime.Now.Ticks 634001516115070000
Time[0].Ticks 634000950200000000
so that they are equal in real time

thanks

NinjaTrader_Josh
01-27-2010, 09:57 AM
ATI user,

Please check your actual bars as seen on the chart. ToDay(Time[0]) simply prints the timestamp of your bars. Nothing fancy and would have no difference between replay/live.

DateTime.Now vs. Time[0] is not suppose to be the same. DateTime.Now is your PC clock time at the very instant it is called. Time[0] is the timestamp of the bar. If your computer processed DateTime.Now a split second beyond Time[0]'s timestamp, it is now a different value. Again, not sure how DateTime.Now is relevant for use in any time checking against bar timestamps.

ATI user
01-27-2010, 03:07 PM
ATI user,

Please check your actual bars as seen on the chart. ToDay(Time[0]) simply prints the timestamp of your bars.
.
I am running on zenfire live

Print ("ToDay(Time[0]) = "+ToDay(Time[0]).ToString( ) );

outputs: ToDay(Time[0]) = 20100121 see pic 1 attached

today is NOT the 21st...see 2nd pic

ATI user
01-27-2010, 03:17 PM
now it is printing the 27th per the pic

all I did in the meantime was stay connected to zen and remove and reload the strat

??????????

NinjaTrader_Josh
01-27-2010, 03:43 PM
Print the bar it is processing for your output line and compare it to that exact bar on the chart. You will find it is accurate.

ATI user
01-28-2010, 06:40 AM
Print the bar it is processing for your output line and compare it to that exact bar on the chart. You will find it is accurate.

forgot to mention that this all takes place on a 20 sec chart...so how could the bar be anything but current?

seems to be working now though

NinjaTrader_Josh
01-28-2010, 08:31 AM
No way for me to speculate on the scenario. All I can say is that if it printed any other dates it simply means somewhere in the bars it is processing there was a bar with that date. It is just a matter of finding where.