Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
adviseLong(PERCEPTRON produces .c file with syntax error. #429051
09/07/13 21:33
09/07/13 21:33
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
When adviseLong(PERCEPTRON, ...) produces a perceptron where the weight of the first signal is >0, it produces a c file with a syntax error.
The line with the syntax error starts with
if(+37.34

This does not happen if the first signal has a negative weight.

I'll post an example in a bit if you are not able to reproduce it yourself. But I suspect you will understand this bug from this description alone.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429053
09/07/13 22:11
09/07/13 22:11
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
For example
Code:
function DChannel_Up(int TimePeriod) {
	DChannel(TimePeriod);
	return rRealUpperBand;
}

function run()
{
	NumYears = 1;
	AssetList = "AssetsUS.dta";
	LookBack = 440;
	set(RULES+TESTNOW+HEDGING);
	ExitTime = 10;	
	NumWFOCycles = 5;
	BarPeriod = 1;	
	vars dc1 = series(DChannel_Up(70));
	vars mdm1 = series(MinusDM(34));
	
	if(adviseLong(PERCEPTRON, 0, dc1[0], mdm1[0]) > 0) {
		reverseLong(1);
	}
	if(adviseShort() > 0){
		reverseShort(1);
	}
}


Train.
Produces a EURUSD_1.c like this
Code:
// Prediction rules generated by Zorro

int EURUSD_L(float* sig)
{
  if(+335.88*sig[1] > -0.50)
    return 32;
  else
    return -32;
}

int EURUSD_S(float* sig)
{
  if(-1.00*sig[0]-312.86*sig[1] > 0.50)
    return 68;
  else
    return -68;
}

// Prediction accuracy: 50%


Last edited by GPEngine; 09/07/13 22:33. Reason: Better example.
Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429058
09/08/13 02:56
09/08/13 02:56
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
This slightly different code does not produce the same error. Can you explain how this code changes anything?

Code:
function DChannel_Up(int TimePeriod) {
	DChannel(TimePeriod);
	return series(rRealUpperBand);
}


Code:
vars aroon1 = DChannel_Up(70);


Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429074
09/08/13 17:17
09/08/13 17:17
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The weight of the first signal is not the problem. Your DChannel_Up functions are both wrong, but in a different way. The first one is almost correct. You just need to declare it with "var" because you want to return a var. "function" defaults to int and thus passes nonsense values to the perceptron.

We'll change that in the next update so that you then won't get a syntax error anymore, but a better understandable error message.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: jcl] #429079
09/08/13 19:20
09/08/13 19:20
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
I see. Thanks!

Is the second one almost correct, too? I mean, is the following snippet valid and likely to do what I'm intending?

Code:
vars sDChannel_RealUpperBand(int TimePeriod) {
  DChannel(TimePeriod);
  return series(rRealUpperBand);
}

function run() {
  vars v00 = sDChannel_RealUpperBand(100);
  plot("v00", v00[0], NEW, BLUE);
}


Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429134
09/09/13 12:08
09/09/13 12:08
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, this snippet looks correct.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: jcl] #429270
09/10/13 15:48
09/10/13 15:48
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Thanks for taking a close look and helping me with my education.

In the final run, if no inputs are useful, Train will produce a prediction rule .c file like this
Html:
int EURUSD_L(float* sig)
{
  if( > 0.50)
    return 64;
  else
    return -64;
}


This is also a syntax error.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429332
09/11/13 14:10
09/11/13 14:10
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
I'll try to produce a crisp example of this.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429334
09/11/13 14:24
09/11/13 14:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Not necessary. This is the same problem as the first.

The next Zorro update will give you a signal error message here, instead of a syntax error.

Re: adviseLong(PERCEPTRON produces .c file with syntax error. [Re: GPEngine] #429336
09/11/13 14:31
09/11/13 14:31
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
This isn't exactly what I was aiming for, but this is another example you may be interested in.

In Train against EURUSD, this script produces an intermediate .c file with a syntax error.
Code:
vars sCDLOnNeck() {
  return series((var)CDLOnNeck());
}

vars sAroon_AroonDown(int TimePeriod) {
  Aroon(TimePeriod);
  return series(rAroonDown);
}

vars sCDLShootingStar() {
  return series((var)CDLShootingStar());
}

vars sCDLHaramiCross() {
  return series((var)CDLHaramiCross());
}

vars sCDLHignWave() {
  return series((var)CDLHignWave());
}

function run() {
  NumYears = 1;
  AssetList = "AssetsUS.dta";
  LookBack = 900;
  BarPeriod = 1;
  TradesPerBar = 2;
  set(RULES+TESTNOW);
  if (Train) {
    set(HEDGING);
    ExitTime = 20;
    NumWFOCycles = 5;
  } else {
    set(NFA);
    Stop = 100*PIP;
    TakeProfit = 100*PIP;
  }

  vars v00 = sCDLOnNeck();
  vars v01 = sAroon_AroonDown(96);
  vars v02 = sCDLShootingStar();
  vars v03 = sCDLHaramiCross();
  vars v04 = sCDLHignWave();

  if(adviseLong(PERCEPTRON, 0, v00[0], v01[0], v02[0], v03[0], v04[0]) > 0) {
    enterLong();
  }
  if(adviseShort() > 0) {
    enterShort();
  }

}


produces a a_EURUSD.c file like
Code:
// Prediction rules generated by Zorro

int EURUSD_L(float* sig)
{
  if(+0.04*sig[1] > 0.50)
    return 38;
  else
    return -38;
}

int EURUSD_S(float* sig)
{
  if(-91.66*sig[1] > 1.50)
    return 74;
  else
    return -74;
}

// Prediction accuracy: 56%


Page 1 of 2 1 2

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