[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Timer function which displya time on the chart itself. Refresh 60 sec?



PureBytes Links

Trading Reference Links


Please comment on this code for any bugs or enhancements.
Thisdisplays time left for the current bar  to print on the chart itself.

I have a problem in this code. The chart only refreshes at 60 seconds
interval and timer too. I would liek the timer to refresh every 20
seconds.

I am using IB live data via the plugin. Database is setup for 15
seconds base interval and preferences to refresh the chart every 3
secs interval.

Any help is ppreciated. Is this NOW(4) function refreshes only every 1
min??

====================
function TimeNumtoSec(hhmmss)
{
HHt = StrToNum(StrLeft(hhmmss,2));
MMt = StrToNum(StrMid(hhmmss,2,2));
SSt = StrToNum(StrRight(hhmmss,2)); 

result = HHt*3600 + MMt*60 + SSt;
return result;
}

z = CCI(14);
LSMA = LinearReg(C, 25 ); 
EMA34 = EMA(C,34);

LastBarTime = TimeNumtoSec( NumToStr(Ref(TimeNum(),1)) ); //last
printed bar time in seconds
current = TimeNumtoSec( NumToStr(Now(4)) ); //current time in seconds
sofar = current - LastBarTime; //seconds elapsed since last printed bar
SecondstoGo =  Interval() - 
               ( sofar/Interval() - floor(sofar/Interval())
               )*Interval(); //seconds left for printing next interval bar

TimeColor = IIf ( SecondstoGo > 21, colorLime,       
	   IIf ( SecondstoGo < 19, colorRed, colorBlack) );

Title = Interval(2) + EncodeColor(colorOrange) + " " +
			"CCI 14=" + round(z) + ", " + EncodeColor(colorLightBlue) + 
			"CCI 6=" + round(CCI(6)) +           
			 EncodeColor(colorPink) + "\nPrice=" + H + ", " + L + ", " + C +
			 EncodeColor(colorWhite) + "\n" + Date() + " " +
EncodeColor(TimeColor) + int(SecondstoGo) + " S";
==============================

Thanks
Choco





------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/