Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Quad, Ayumi, AndrewAMD), 1,092 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 4 1 2 3 4
Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485550
03/22/22 18:12
03/22/22 18:12
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
I'm not sure I understand what you mean.

I have previously trained both models as single strategies. I first have trained DeeplearnKeras1 and as another strategy I have trained DeeplearnKeras2.

So individually I can test and trade them. Both open trades, etc... work fine. But individually.

Now I want to test ( and If It works fine, trade) a single strategy using both models at the same time. So if both Vlong's are bigger than Threshold then EnterLong.

I mean, running two advise functions at the same time.

That's why I tried with algo(loop), justo trying to run two advise to get Vlong1 and Vlong2 in the same script.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485551
03/23/22 07:15
03/23/22 07:15
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
If youre still stuck you can always ask support for help, they help fix the bugs and make your script work.

I have not much ml experience but i know that you need a training target. If you use trades for a target and your script does not trade, it cannot train.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485552
03/23/22 08:29
03/23/22 08:29
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Hello, I have already trained both models.

I will try wtih support but wanted to use the forum so probably more people can get the idea and may be useful for future questions.

I don´t want to train two models again. What I´m trying is to "ensemble" or use both models at the same time for Test/Trade. No more training is needed. If I test/trade each single strategy with its model, works fine. The problem is to have two different Long signals to enter/not enter the trade.

I´m not sure if I´m explaining well what I´m looking for.

Quote
vLong = adviseLong(NEURAL+BALANCED,0,
change(1),change(2),change(3),change(4),
range(1),range(2),range(3),range(4));

Retuns a "var" value.

Quote

vLong1= adviseLong(NEURAL+BALANCED,0,
change(1),change(2),change(3),change(4),
range(1),range(2),range(3),range(4));

Retunrs the same "var" value if I use the same model (.ml file) but if I use a different model (different .ml file) is a different value

So I want to use those different values (vLong and Vlong1) to enter or not a trade.

¿Have I explain well what I´m trying to do?


Thank you for your help.


Last edited by tomaslolo; 03/23/22 08:30.
Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485561
03/24/22 07:42
03/24/22 07:42
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
If you have already trained the 4 models, you need no trades for training, but still need to fix the other bugs.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485563
03/24/22 09:51
03/24/22 09:51
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Yes, that´s why I ask for help.

I don´t find the way to call two different advise functiones, to load both models in the same script.

I have tried dozens of alternatives. Always loads one model or the other, but no both.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485565
03/25/22 06:48
03/25/22 06:48
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Two models are always available. adviseLong/Short can train and use totally different models. For more than 2, just have multiple algos. Check out workshop 6. It's for optimizing, but would work in the same way for machine learning. If you're not making any progress, subscribe a support ticket and get help.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485566
03/25/22 08:48
03/25/22 08:48
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Ok, I tried different approaches, including workshop 6.

I´ll reset and restart again.

Probably will be back here.... ;-)

Thank you!!

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485567
03/25/22 10:04
03/25/22 10:04
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Hello again, I´m back!

Script adapted to what I´m trying:

Code
// WDL6 trying to make it work ///////////////////


var change(int n)
{
	return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}

var range(int n)
{
	return scale((HH(n) - LL(n))/priceClose(0),100)/100;
}
	

function tradeUNO()
{
	if(Init) print(TO_WINDOW,"\nR and Keras required"); 
	Script = "DeepLearnKeras1";
	
	bool sube1=false;
	bool baja1=false;
	var Threshold1 = 0.5;
	var vLong1,vShort1;
	
	
	if (vLong1 = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold1)
		return  sube1=true;
	
	
	
	if (vShort1 = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold1)
		
		return  baja1=true;

}

function tradeDOS()
{
	if(Init) print(TO_WINDOW,"\nR and Keras required"); 
	Script = "DeepLearnKeras2";
	
	bool sube2=false;
	bool baja2=false;
	var Threshold2 = 0.5;
	var vLong2,vShort2;
	
	
	if (vLong2 = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold2)
		return sube2=true;
	
	
	if (vShort2 = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold2)
		
		return baja2=true;
}

function run()
{
	NumCores = -2;		// use multiple cores (Zorro S only)
	StartDate = 20170101;
	EndDate= 20190101;
	BarPeriod = 1440;	// 1 hour
	LookBack = 100;

	assetList("AssetsDarwinexFMB");
	asset("EUR/USD");
	set(RULES);
	LifeTime=3;

	while(algo(loop("TRND","CNTR")))
	{

		if(Algo == "TRND") 
			tradeUNO();
		else if(Algo == "CNTR") 
			tradeDOS();

	}
	
		
	if(sube1 and sube2)  // <<<----- THIS IS LINE 96
		enterLong();
	
	if(baja1 and baja2)
		enterShort();
	
	
	PlotWidth = 600;
	PlotHeight1 = 300;
}


As you may see, I want to enterLong if both conditions "sube1" and "sube2" are true. Same for enterShort with "baja1" and "baja2"

Problems:

1.- I´m not sure how "sube1, sube2, baja1 and baja2" returned values (true/false) can be red inside run() function.

Quote
WDL6 compiling........
Error in 'line 96:
'sube1' undeclared identifier
< if(sube1 and sube2)>.




Last edited by tomaslolo; 03/25/22 11:23.
Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485568
03/25/22 10:23
03/25/22 10:23
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
If I "declare" bool sube1, sube2, sube3 and sube4 if solves previous issue but then:

Problem 2: Can't go to FALSEGOTO:DOUBLE:: ---> Why is this error? I´m trying to obtain a true statement if a condition is true.

Quote
WDL6 compiling.........
Error in 'line 29:
Syntax error: Can't go to FALSEGOTO:DOUBLE::.
< range(1),range(2),range(3),range(4))>Threshold1) // line 28
>



This is same script with sube1, sube2, baja1 and baja2 declared:


Code
// WDL6 trying to make it work ///////////////////


var change(int n)
{
	return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}

var range(int n)
{
	return scale((HH(n) - LL(n))/priceClose(0),100)/100;
}
	

function tradeUNO()
{
	if(Init) print(TO_WINDOW,"\nR and Keras required"); 
	Script = "DeepLearnKeras1";
	
	bool sube1=false;
	bool baja1=false;
	var Threshold1 = 0.5;
	var vLong1,vShort1;
	
	
	if (vLong1 = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold1)  // line 28
							// line 29
		return sube1=true;		// line 30
	
	if (vShort1 = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold1)
		
		return  baja1=true;

}

function tradeDOS()
{
	if(Init) print(TO_WINDOW,"\nR and Keras required"); 
	Script = "DeepLearnKeras2";

	bool sube2=false;
	bool baja2=false;
	var Threshold2 = 0.5;
	var vLong2,vShort2;
	
	
	if (vLong2 = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold2)

		return sube2=true;
	
	if (vShort2 = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4))>Threshold2)

		return baja2=true;
}

function run()
{
	NumCores = -2;		// use multiple cores (Zorro S only)
	StartDate = 20170101;
	EndDate= 20190101;
	BarPeriod = 1440;	// 1 hour
	LookBack = 100;

	assetList("AssetsDarwinexFMB");
	asset("EUR/USD");
	set(RULES);
	LifeTime=3;
	
	bool sube1=false;  [color:#FF0000]//  DECLARED HERE TOO SO THERE´S NO ERROR MESSAGE[/color]
	bool baja1=false;
	bool sube2=false;
	bool baja2=false;
	
	while(algo(loop("TRND","CNTR")))
	{
		if(Algo == "TRND") 
			tradeUNO();
		else if(Algo == "CNTR") 
			tradeDOS();
	}
	
	if(sube1 and sube2)
		enterLong();
	
	if(baja1 and baja2)
		enterShort();
	

	PlotWidth = 600;
	PlotHeight1 = 300;
}



Thank you

Last edited by tomaslolo; 03/25/22 11:23.
Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485569
03/25/22 11:31
03/25/22 11:31
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Why are you using vLong1 & vShort2? (which should be '==' in an if-statement if that was needed).

if(x == y > z) makes no logical sense

Check the condition example on https://zorro-project.com/manual/en/advisor.htm

Last edited by Grant; 03/25/22 11:54.
Page 3 of 4 1 2 3 4

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1