Wrong user code

Hello,

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.

This should not be the expected behavior.

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

Title = "\n"+ 
"Time : "+NumToStr(LastValue(TimeNum()))+"\n"+ 

_SECTION_END();	

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.

To display current time use Now() function.

Do yourself a favor and study the manual carefully
http://www.amibroker.com/guide/

http://www.amibroker.com/f?now

http://www.amibroker.com/guide/w_preferences.html

1 Like

Ok got it , its time stamp, but then why it changes?

First it shows higher value and then lower value within same time 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.

It won't change if:

  • you left the default settings untouched
  • 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.

HI Tomasz,

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 seting

For database, I am getting tick data.

Now look at following two scree capture: at 4:31:01, bar time is 4:31:00
1

at 4:31:02, bar time changed to 4:31:01
2

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)
3

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. 

Any replies please to above issue