Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, AndrewAMD, Quad), 733 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Script2015 Trend.c Line 33 Error #464466
02/15/17 23:36
02/15/17 23:36
Joined: Feb 2017
Posts: 1
T
til Offline OP
Guest
til  Offline OP
Guest
T

Joined: Feb 2017
Posts: 1
Hi,

I wasn't able to find anything related to Tutorials from FinancialHacker Script2015 and got an error I'm not able to overcome.

The error where I don't C enough resides in Trend.c - code below Error Msg.

Do you have an idea how to fix it?

Thanks!

TrendALMA compiling.......
Error in 'trend.c' line 33:
Redefined with different type: g
< int Day = 0;
>
Error in 'trend.c' line 33:
syntax error
< int Day = 0;
>.
Copied to Clipboard!

Code:
// Trend Trading Experiment ///////////////////
#include <default.c>

//#define WRC
//#define DO_STATISTIC

#ifdef DO_STATISTIC	
var _getvar(string filename,string name)
{
	if(!file_date(filename)) return 0;
	return strvar(file_content(filename),name,0);
}

void _putvar(string filename,string name,var value)
{
	string line = strf("%s %12.5fn",name,value);
	string s = 0,content = 0;
	if(file_date(filename)) 
		content = file_content(filename);
	if(content)
		s = strstr(content,name);
	if(!s)
		file_append(filename,line);
	else {
		memcpy(s,line,strlen(line));
		file_write(filename,content,0);
	}
}
#endif

int Period;
var Daily[3000];
int Day = 0;

var objective() 
{ 
	if(NumWinTotal < 30 || NumLossTotal < 30) { // not enough trades
		g->bDoStep = 0;	// abort optimization
		return 0; 
	}
	
#ifdef DO_STATISTIC	
// store the result statistic	
	string FileName = "LogTrendStats.txt";
	string NameScript,NameAsset,NameAlgo;
	if(WinTotal > LossTotal) {
		NameScript = strf("%s_Won",Script);
		NameAsset = strf("%s_Won",Asset);
		NameAlgo = strf("%s_Won",Algo);
	} else {
		NameScript = strf("%s_Lost",Script);
		NameAsset = strf("%s_Lost",Asset);
		NameAlgo = strf("%s_Lost",Algo);
	}
	lock();
	var Score = _getvar(FileName,NameScript);
	_putvar(FileName,NameScript,Score+1);
	Score = _getvar(FileName,NameAsset);
	_putvar(FileName,NameAsset,Score+1);
	Score = _getvar(FileName,NameAlgo);
	_putvar(FileName,NameAlgo,Score+1);
	unlock();
#endif	

#ifdef WRC
// store the curves of daily returns
	string FileName = "LogTrendDaily.bin";
	string Name = strf("%s_%s_%s_%i",Script,Asset,Algo,Period);
	int Size = Day*sizeof(var);
	lock();
	file_append(FileName,Name,strlen(Name)+1);
	file_append(FileName,&Size,sizeof(int));
	file_append(FileName,Daily,Size);
	unlock();
#endif
	
	return WinTotal/max(1,LossTotal); // Profit factor
}

var filter(var* Data,int Period);

void run()
{
	set(PARAMETERS|LOGFILE);
	PlotHeight1 = 200;
	PlotScale = 8;
	ColorBars[1] = BLACK; // winning trades
	ColorBars[2] = GREY; // losing trades

#ifdef WRC
	Spread = Commission = RollLong = RollShort = Slippage = 0;
#endif

	StartDate = 2010;
	BarPeriod = 15;
	LookBack = 80*4*24; // ~ 4 months
	
	while(asset(loop("EUR/USD","SPX500","XAG/USD")))
	while(algo(loop("M15","H1","H4")))
	{
		TimeFrame = 1;
		if(Algo == "H1")
			TimeFrame = 4;
		else if(Algo == "H4")
			TimeFrame = 4*4;	

		int Periods[10] = { 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000 };
		Period = Periods[optimize(1,1,10,1)-1];
		
		var *Price = series(price());
		var *Smoothed = series(filter(Price,Period));

		if(valley(Smoothed))
			enterLong();
		else if(peak(Smoothed))
			enterShort();
	} 
	
#ifdef WRC
// story daily result
	static int LastDay = 0;
	if(is(LOOKBACK))
		LastDay = Day = 0;
	else if(LastDay != day()) {
		Daily[Day++] = Balance;
		LastDay = day();
	}
#endif
}



ps

One error I was able to solve is, that Script 2015>TrendXYZ expects Trend.c to be located in ...Script, not in ...Script/Trend

Last edited by til; 02/15/17 23:39.
Re: Script2015 Trend.c Line 33 Error [Re: til] #464502
02/20/17 10:30
02/20/17 10:30
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Change "Day" to a different name. Unlike in 2015, the newer Zorros have an internal variable named "Day".


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1