adviseLong/Short

Posted By: PriNova

adviseLong/Short - 11/06/12 08:03

Hi zorro's

i read the manual about the adviseLong/-short command, but there are no examples in it? are their any here?

this is my code i used how i understand this command:

Code:
function run()
{
	set(TICKS|RULES);
	StartDate = 20100101;
	
	
	var lv = 20;
	var hv = 80;
	int tradeL, tradeS;
	
	var *stochs = series(Stoch(5,3,MAType_SMA,5,MAType_SMA),20);
	tradeL = adviseLong(DTREE, 0, lv,hv, stochs[0],stochs[1]);
	tradeS = adviseShort(DTREE, 0, lv,hv, stochs[0],stochs[1]);
	Stop = 2*ATR(100);
	if( tradeL > 0)
	{
		exitShort();
		if(numLong() ==0) enterLong();
	} 
	if( tradeS > 0) 
	{
		exitLong();
		if(numShort() ==0) enterShort();
	}
}



and the prediction after training ist 0%

the .rul file looks like:

Code:
// Prediction rules generated by Zorro

int EURUSD_L(float* sig)
{ return -100; }

int EURUSD_S(float* sig)
{ return -100; }

// Prediction accuracy: 0%



did i something wrong here?
Posted By: jcl

Re: adviseLong/Short - 11/06/12 12:36

Yes, you must set HEDGING here in Train mode. Otherwise your second trade immediately closes the first and the advise function can not get any useful result.

The prediction accuracy can also be 0 when the parameters are totally uncorrelated to the trade result.

This is a test script:

Code:
var signal(var val1,var val2)
{
	return (val2-val1)/PIP;
}

void run()
{
	BarPeriod = 1440;
	set(RULES|HEDGING);
	asset("SPX500");
	
	var *Close = series(priceClose()),
		*High = series(priceHigh()), 
		*Low = series(priceLow()); 
	
	var LPH = LowPass(High,100),
		LPL = LowPass(Low,100);

	Stop = 50*PIP; 
	TakeProfit = 50*PIP;

	var S1 = signal(*Close,LPH),
		S2 = signal(*Close,LPL),
		S3 = signal(*Close,*High),
		S4 = signal(*Close,*Low),
		S5 = signal(LPH,LPL);
			
	if(adviseLong(DTREE,0,S1,S2,S3,S4,S5) > 0)
		enterLong();
	if(adviseShort(DTREE,0,S1,S2,S3,S4,S5) > 0)
		enterShort();
}


Posted By: PriNova

Re: adviseLong/Short - 11/06/12 13:32

Thank you. now it works even if the results are bad. hehe

But if i use your script with another asset like EUR/USD he says in the middle of training: too many trades.

is there a way to extend the number of trades?
Posted By: Guiom

Re: adviseLong/Short - 11/06/12 17:28

Hi jcl,
Just being curious, do the Z1 and Z2 strategies use these functions?
Thanks
Guiom
Posted By: jcl

Re: adviseLong/Short - 11/06/12 20:08

PriNova: The reason is that this script places two trades on every bar. There's a memory limit for the number of trades, so better reduce the number of simultaneously open trades, as you did in your first script.

Guiom: No, Z1 and Z2 do not use yet artificial intelligence functions. In fact we have not yet found a strategy that would really improve by AI, but we have also not yet systematically looked for it.
© 2024 lite-C Forums