Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: AFL Timing functions
Author/Uploader: Herman van den bergen - (email hidden)
Date/Time added: 2005-02-19 11:48:19
Origin:
Keywords:
Level: semi-advanced
Flags: function

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

Tested with AmiBroker 4.69.0 beta. A few Second-timing functions for general use: GetSecondNum(), GetElapesedSeconds and GetBarsSecsLeft. Copy to indicator, Insert, and open the Param window to test the elapsed time function.

Formula:

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

Comments:


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM