adviseLong returns 0 with custom Objective

Posted By: Dalla

adviseLong returns 0 with custom Objective - 01/11/18 09:07

Hi,

I'm trying to use a custom Objective for my advise functions, but right now my adviseLong always returns zero.

My Zorro code looks like this
Code:
var params[10];
params[0] = cubicDev10N[0];
params[1] = deltaPVR5N[0]; 
params[2] = deltabWidth3N[0]; 
params[3] = MMIFasterN[0]; 
params[4] = deltaMMIFastest10N[0]; 
params[5] = HurstFast[0]; 
params[6] = HurstFaster[0];
params[7] = ibsOneN[0];
params[8] = ATRSlowN[0];
params[9] = marketVolNorm[0];


	set(RULES);
	var myObje = ifelse(priceClose(-1) - priceClose(0) > 20,1,-1);
	LifeTime = 1;
	MaxLong = 1;


	if(Train) 
	{
		Hedge = 2;
		set(PEEK);
		adviseLong(NEURAL+BALANCED, myObje, params,10);
	}
	
	if(!Train)
	{
		var LongPrediction = adviseLong(NEURAL, myObje, params,10);
		printf("nPred for long is %f", LongPrediction);
		if(LongPrediction > 0.5)
		{				
			enterLong();
		}
	}



If I change my code to use SIGNALS during training, and give the resulting input to my neural.predict function straight from R, the predictions are returned as expected. So I must be doing something wrong on the Zorro side.

I've trying putting enterLong() in the if(Train) block as well, but that doesn't make any difference, and I don’t think it's needed when not using trade results as the target?

Anything obviously wrong with Zorro my code?
Posted By: jcl

Re: adviseLong returns 0 with custom Objective - 01/11/18 11:34

Yes, trades are not needed when Objective != 0. At first glance I see nothing wrong with the Zorro code.

The #1 potential bug in machine learning R code is a neural.predict function that works with matrices, but not with vectors.
Posted By: tomaslolo

Re: adviseLong returns 0 with custom Objective - 04/25/19 21:35

Hi all, I´ve been playing around sometime with advise function. I never get a different value different to zero when customizing my Objective.

As stated in the manual: https://zorro-project.com/manual/en/advisor.htm
"Returns:
In [Train] mode: 0 when Objective != 0, otherwise 100 (so that dependent trades are always executed for training)."

I don´t understand what is meant when saying "Returns". If Objective=0 next trade result is the target and should be the last column of the signals.csv, but if you use "var myObje = ifelse(priceClose(-1) - priceClose(0) > 20,1,-1);" as Dalla exposed or any other the last column of the signals.csv files is always 0.00000 or -0.00000.

Is this the expected behaviour? if so How can we customize the Objective value for predict other than next trade result?

Thank you
Posted By: jcl

Re: adviseLong returns 0 with custom Objective - 04/26/19 06:27

It returns 0 in training because otherwise it would enter a trade depending on your code. I can't tell why your csv contains wrong values, so check your script.

There are lots of examples of the advise function, with or without custom objective.The current beta version has also two more advise scripts. It should be no problem to modify one of the examples for your needs.
© 2024 lite-C Forums