Gamestudio Links
Zorro Links
Newest Posts
Camera always moves upwards?
by clonman. 11/13/25 14:04
brokerCommand PLOT_HLINE parameters
by M_D. 11/13/25 10:42
ZorroGPT
by TipmyPip. 11/10/25 11:04
Training with the R bridge does not work
by frutza. 11/05/25 00:46
Zorro 2.70
by opm. 10/24/25 03:44
Alpaca Plugin v1.4.0
by TipmyPip. 10/20/25 18:04
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 21,112 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sheliepaley, Blueguy, blobplayintennis, someone2, NotEBspark
19177 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
tock() in Test Mode #478838
12/30/19 14:07
12/30/19 14:07
Joined: Dec 2019
Posts: 54
ozgur Online OP
Junior Member
ozgur  Online OP
Junior Member

Joined: Dec 2019
Posts: 54
Hi,

I am testing tick() and tock() functions which both work well in Trade Mode. Tick() works in Test Mode as well however I couldn't make tock() work.

According to the manual, tock() should be triggered every bar without TICKS flag.
Quote

In [Test] or [Train] mode or in the lookback period, the tick and tock functions are normally called only once per bar. When the TICKS flag is set, the tick function is called at any new price quote in the historical data.


I modified Workshop4a.c to include tick() and tock() functions.
Logfile shows Tick() functions working but not Tock(). I can't see any errors either. How can I make tock() functional in Test Mode?

Thanks.

Code
// Indicator implementation example //////////////////////////////////
// Formula: Out[0] = (a-a^2/4) * In[0] + a^2/2 * In[1] - (a-3a^2/4) * In[2] + (2-2a) * Out[1] - (1-a)^2 * Out[2]

var lowpass(vars In,int Period)
{
	var a = 1./(1+Period);
	vars Out = series(In[0],3);
	return Out[0] = (a-0.25*a*a)*In[0]
		+ 0.5*a*a*In[1]
		- (a-0.75*a*a)*In[2]
		+ (2-2*a)*Out[1]
		- (1-a)*(1-a)*Out[2];
}

function tick()
{
	if(!is(LOOKBACK))
		print(TO_FILE," This is tick @ %s",datetime());
}

function tock()
{
	if(!is(LOOKBACK))
		print(TO_FILE," This is tock @ %s",datetime());
}

function run() // for testing
{
	set(LOGFILE,PLOTNOW); // ,TICKS
	
	Verbose = 3;
	NumYears = 1;
	
	plot("lowpass",lowpass(series(price()),10),LINE,RED);
}

Re: tock() in Test Mode [Re: ozgur] #478841
12/31/19 10:03
12/31/19 10:03
Joined: Jul 2000
Posts: 28,029
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,029
Frankfurt
A tock() function makes probably not much sense in backtesting, since it is time triggered. But it works in test mode, so I can't tell how and why it does not work for you. Maybe you looked in the wrong file or something like that.

Re: tock() in Test Mode [Re: ozgur] #478847
12/31/19 14:40
12/31/19 14:40
Joined: Dec 2019
Posts: 54
ozgur Online OP
Junior Member
ozgur  Online OP
Junior Member

Joined: Dec 2019
Posts: 54
Hi jcl,

I tried couple of things and found a way to make it work: calling asset() in run(). Without asset(), tock() is not triggered in Test Mode. Maybe worth mentioning in the Manual.

I noticed another strange behaviour of tock() in Trade Mode, it only works after a bar close. For example, if BarMode=60 and current time is 14:38 then tock() won't be triggered another 22 minutes(+TockTime). Is this intended?

Thanks

Re: tock() in Test Mode [Re: ozgur] #478850
01/01/20 17:49
01/01/20 17:49
Joined: Jul 2000
Posts: 28,029
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,029
Frankfurt
No, that's still not the reason of your problem. tock() has nothing to do with asset() or bar close, so continue testing. Of course, since tock() is time triggered, it depends on ticks, bar periods, and time settings when and how often it is triggered in the backtest.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1