here is the simple program to display time in real time.
Us 5 s time frame for any chart.
for each new bar you will see time changing two times.
first it increases by 9 sec and then decreases by 4 sec.
Your code is wrong. It does not display time.
It displays timestamp of the BAR. That is not current time. Timestamp depends on settings and by default it shows the beginning of current bar.
Earlier I was using bar end time in chart settings, if I chang bar time to the start time of bar, it still shows two time for a bar. eg for bar starting at 15 sec , first it shows 15 and then it shows 16.
your data source (that you did not specify in your post) is working correctly
You should NOT change the default settings, if you don't know what they are doing (i.e. if you did not read the manual).
The default value for time stamp is "START TIME OF INTERVAL (recommended)".
Just keep the setting at the default http://www.amibroker.com/guide/w_preferences.html
Before anything else YOU MUST SAY what DATA SOURCE you are using.
thanks for reply and apologies fro not providing complete information.
But problem is not solved.
I am using live data from Interactive broker.
and setings are
For database, I am getting tick data.
Now look at following two scree capture: at 4:31:01, bar time is 4:31:00
at 4:31:02, bar time changed to 4:31:01
not only this all bars are not formed at 1 min time gap, look at this at 4:36, bar is formed at 4:36:06 ( delayed by 5 sec)
I am using following code to get these timings on chart
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Buy =1;
RequestTimedRefresh( 1 );
//ibc = GetTradingInterface("IB");
//BuyOrderID= ibc.PlaceOrder( "MSFT", "Buy", 100, "MKT", 0, 0, "Day", True );
Title = "\n"+
//"buyorder"+BuyOrderID+"\n"+
"Time : "+(LastValue(TimeNum()))+"\n"+
Now();
//"Funds AVailable CAD: "+ibc.GetAccountValue("[CAD]AvailableFunds")+"\n"+
_SECTION_END();
thanks to let me know why bar timing changes and also why bars are not formed exactly at gap of 1 min.