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

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


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Re: Timer function which displya time on the chart itself. Refresh 60 sec?
  • From: "Herman van den Bergen" <psytek@xxxxxxxx>
  • Date: Fri, 18 Feb 2005 05:18:46 -0500

PureBytes Links

Trading Reference Links

Here are some timer functions to give you ideas:

Reset = ParamTrigger("Static Variables","Click to Reset");

function GetSecondNum()
	{
	Time 		= Now(4);
	Seconds 	= int(Time%100);
	Minutes 	= int(Time/100%100);
	Hours 	= int(Time/10000%100);
	SecondNum= int(Hours*60*60+Minutes*60+Seconds);
	return SecondNum;
	}

function GetElapsedSeconds( reset )
	{
	NowSecs 	= GetSecondNum();
	if( Reset ) StaticVarSet("SecondTimer", NowSecs );
	PrevSecs = StaticVarGet("SecondTimer");
	ESecs = NowSecs - PrevSecs;
	return eSecs;
	}

function GetBarSecsLeft()
	{
	BarInterval	= Interval();
	NowSecs 	= GetSecondNum();
	PrevSecs 	= StaticVarGet("SecondTimer");
	ESecs 	= BarInterval - (NowSecs - PrevSecs);
	if( eSecs < 0 ) eSecs = 0;
	else if ( eSecs > 60 ) eSecs = 60;
	return eSecs;
	}

if( IsEmpty(StaticVarGet("IsInitialized")) OR Reset)
	{
	StaticVarSet("PrevBarNum",	BarCount-1);
	StaticVarSet("IsInitialized",1);
	}

Plot(C,"C",1,128);

Title =
"\nUse Param() to reset elapsed seconds..."+
"\nSecond Count:     "+NumToStr(GetSecondNum(),1.0,False)+
"\n20-Second Count:  "+NumToStr(int(GetSecondNum()/20),1.0,False)+
"\nElapsed Seconds:  "+NumToStr(GetElapsedSeconds(Reset),1.0,False)+
"\nBar Seconds left: "+NumToStr(GetBarSecsLeft(),1.0,False);


-----Original Message-----
From: sinhavishal [mailto:sinhavishal@xxxxxxxxxxx]
Sent: Friday, February 18, 2005 4:29 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Timer function which displya time on the chart
itself. Refresh 60 sec?



Any comments on this topic yet?

--- In amibroker@xxxxxxxxxxxxxxx, "sinhavishal" <sinhavishal@xxxx> wrote:
>
> 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





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 the Yahoo! Terms of Service.




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/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/