Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (AndrewAMD, ozgur, AbrahamR, wdlmaster), 849 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Use 3 zorros, one for trading the other two for calculating #485494
03/17/22 17:41
03/17/22 17:41
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Hello, I keep travelling with zorro and the trading world.

I try many things but can't make It work.

My question: Os there a simple way of using diferentes zorro instantes and comunícate between them. Foto example:
Zorro1 calculates SMA(20)
Zorro2 calculates SMA(100)
Zorro3 recibes Zorro1 SMA(20) and Zorro2 SMA(100) and executes if(crossOver(Zorro1SMA(20), Zorro2SMA(100))
enterLong();

I have ZorroS

I've searched the manual, the control zorro section is difficilt to understand for me, I've seen Zorro control.cpp file un source folder but, even worse!!

I've learned to code Zorro, and I'm used to write scripts, sometimes I do wrong and sometimes fine. But can't imagine how to do this. I think is not very documented in the manual.

Any clues?

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485495
03/17/22 18:03
03/17/22 18:03
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline
Junior Member
NorbertSz  Offline
Junior Member
N

Joined: Jan 2022
Posts: 58
I think you are looking for this feature:
https://zorro-project.com/manual/en/engine.htm

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485497
03/17/22 18:36
03/17/22 18:36
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Yes, that is. But I thought there was an easier way.

Something like:

Code
function run()
{

Script="Zorro1/Strategies/SMA20.c"
//Someway to receive the var or the series generated by Zorro1

Script="Zorro2/Strategies/SMA100.c"
//Someway to receive the var or the series generated by Zorro2

if (crossOver(Zorro1SMA(20), Zorro2SMA(100)) 

enterLong();


Is there a way like this?

Or, is there code samples?

thank you!

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485501
03/18/22 08:00
03/18/22 08:00
Joined: Jan 2022
Posts: 58
N
NorbertSz Offline
Junior Member
NorbertSz  Offline
Junior Member
N

Joined: Jan 2022
Posts: 58
You can't just "import" the process by the source code, because the computer needs to run something for the calculations. So you need to start 3 different softwares (Zorros) in this case.

But are you sure you can't do all these calculations in one script?

The best way for data exchange between processes (softwares) is the "inter-process communication (IPC)". The good news is that you don't need to write it yourself or find a C library, because Zorro has already implement this by "memory mapping", you just need to use the built-in commands - see the manual above. There is no simpler way.

Alternatively you can write&read txt files for data exchange, but I don't recommend it because there are a lot of ways to do it wrong, and it's much slower than IPC. Also, you can check the method called "named pipes", but it's complicated:
https://www.google.com/search?q=named+pipes+example+c
Before I found Zorro, I made MT4 EAs, and here's the library I used for the interprocess communication:
https://www.fxblue.com/appstore/9/quickchannel

But as far as I see, Zorro's built-in method is much better and simpler than these all.

Last edited by NorbertSz; 03/18/22 08:03.
Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485507
03/18/22 14:02
03/18/22 14:02
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Thank you for your reply.

I was trying to do it with algo(loop) but can´t make it work.

I have two deepnet models and want to use them at the same time, but as "advise" function is a little blackbox I don´t finf the way to use the loop. It only loads last .ml file. That´s why I though I could use another zorro instance so I can load both models, evaluate and the third Zorro decides to go long or not. But it´s very difficult. I think it "easy" to start a Zorro instance but can´t imagine how to send var results from Zorro1 and Zorro2 to Zorro3.

This is the loop I was trying to use with one Zorro:

Code
/ Deep Learning Test ///////////////////////////////////////////


///////////////////////////////////////////////////////////////////////
#include <r.h>

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 run()
{
	NumCores = -1;
	Script = "DL3kb";
	Script = "DL3kc";
	
	StartDate = 20190301;
	EndDate = 20200501;
	BarPeriod = 60;	// 1 hour
	LookBack = 100;

	//WFOPeriod = 252*24; // 1 year
	//DataSplit = 90;

	assetList("AssetsFix");
	asset("EUR/USD");
	set(RULES);
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	LifeTime = 3 ; 
	if(Train) Hedge = 2;

	
			////// MIS SEÑALES ///

	var Signals[9];  // hasta 15 sin problema
	Signal[0]=change(1);
	Signal[1]=change(2);
	Signal[2]=change(3);
	Signal[4]=change(4);
	Signal[5]=range(1);
	Signal[6]=range(2);
	Signal[7]=range(3);
	Signal[8]=range(4);
	
	
	var Threshold = 0.9;
	var Threshold1 = 0.1;
	var vLongb,vShortb,vLongc,vShortc;
	
		
	// aqui empiezo a hacer loop
	while(algo(loop("DN1","DN2"))){
	set(LOGFILE|PLOTNOW);
	if(Algo=="DN1"){
		if(Init) print(TO_WINDOW,"\nR DL1 and Deepnet required"); 
	Script = "DL3b";
	
	var vLongb = adviseLong(NEURAL+BALANCED,0,Signals,9);
	var vShortb = adviseShort(NEURAL+BALANCED,0,Signals,9);

	}

	if(Algo=="DN2"){
		if(Init) print(TO_WINDOW,"\nR DL2 and Deepnet required"); 
	Script = "DL3c";
	var vLongc = adviseLong(NEURAL+BALANCED,0,Signals,9);
	var vShortc = adviseShort(NEURAL+BALANCED,0,Signals,9);
	}
	
///////////////////////////////////////////////////////////	
// logic   //////////////////////////////////////////

if(vLongb> Threshold
and vShortb< Threshold1
and vLongc> Threshold
and vShortc < Threshold1
)	
		enterLong();

	if(vShortb> Threshold
and vLongb < Threshold1
and vShortc> Threshold
and vLongc < Threshold1
)	
	enterShort();
	
// plots  /////////////////////

	plot("Longb",vLongb,NEW|LINE,BLACK);
	plot("Longc",vLongc,NEW|LINE,BLUE);

	plot("Shortb",vShortb,NEW|LINE,GREY);
	plot("Shortc",vShortc,NEW|LINE,MAROON);

	}
}

Only loads last ml file, DL3c and plots are all zero. vLongb, vLongc, etc... don´t evaluate. I tried to defien them as "static var", tried different things but no way.

I think is´t something related wih advise function, but I can´t figure it out.

Do you find a way to use loop and evalute two ml models?

Thank you

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485511
03/18/22 17:22
03/18/22 17:22
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
I see many bugs. The "Script" lines make no sense and why do you call advise twice with the same signals? Also variables with the same name are defined multiple times, that is probably not intended.

There is a deepnet example, start from there and then add your own signals.

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485512
03/18/22 17:44
03/18/22 17:44
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Hello Petra!

"Script" lines because I though that way "loads" those r files.

I have two different model files, DL3b.ml and DL3c.ml If I use, for example, Keras I can rename "Script" line in the deeplearn script included in Zorro/Strategy folder

I can run the file to load one model, for example DL3b.ml, but I want to load two models, an evaluate both of them.

vLongb evaluates DL3b.ml and vLongc evaluates DL3c.ml. But I don´t find the way to use both models.

That´s why I wanted to use:

Code
 if(vLongb>threshold and vLongc>threshold) 
enterLong();

or similar logic.

As stated in the manual: https://zorro-project.com/manual/en/advisor.htm
Quote
However, different methods and signals can be used for different assets and algorithm identifiers, so call algo() for combining multiple advise methods in the same script. Ensemble or hybrid methods can also be implemented this way, using different algo identifiers.


But I don´t find the way of doing so. Can I "load" two models in the same script? With keras.

Not sure if I´ve explained well.

Thank you!

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485534
03/20/22 07:54
03/20/22 07:54
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
You can have 1000 models but use different algos for different models. Not "Script".

When you train for trade results you must enter a trade for each result, otherwise it wll obviously not work. Check out the examples.

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

Joined: Feb 2018
Posts: 68
Yes, but I don´t find the way of using different algos with advice function,

I try with a loop, also without loop. For example, code below It´s supposed to load advice function twice but only loads last one.


Code
// Deep Learning Test ///////////////////////////////////////////

//#define DO_SIGNALS  // generate sample set in Train mode
//#define DEEPNET
//#define H2O 
//#define MXNET
#define KERAS

///////////////////////////////////////////////////////////////////////
#include <r.h>

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 run()
{
	NumCores = -1;
	StartDate = 20170101;
	EndDate= 20190101;
	BarPeriod = 1440;	// 1 hour
	LookBack = 100;

	//WFOPeriod = 252*24; // 1 year
	//DataSplit = 90;

	assetList("AssetsDarwinexFMB");
	asset("EUR/USD");
	set(RULES);
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	LifeTime = 3;
	if(Train) Hedge = 2;
	
	var Threshold = 0.5;
	var vLong,vShort,vLong1,vShort1;
///////////////////////////////////////////////////////////	

	SelectWFO = -1; // use the last WFO cycle for calibrating the neural net

	set(LOGFILE|PLOTNOW);
	if(Init) print(TO_WINDOW,"\nR1 and Keras required"); 

	if (Algo = "DeepLearnKeras1"){
	Script = "DeepLearnKeras1";
	vLong = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
		
		vShort = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
	}
		if(Init) print(TO_WINDOW,"\nR and Keras required"); 
	//Script = "DeepLearnKeras1";
	
	if (Algo = "DeepLearnKeras2"){
	
	Script = "DeepLearnKeras2";
		
		vLong1 = adviseLong(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
		
		vShort1 = adviseShort(NEURAL+BALANCED,0,
	change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
	}


		if (vLong > Threshold
		and vLong1 > Threshold )	
		enterLong();

	if(vShort  > Threshold
	and vShort1  > Threshold)
		enterShort();

	plot("Long",vLong,NEW|LINE,BLACK);
	plot("Short",vShort,NEW|LINE,GREY);
		plot("Long1",vLong1,NEW|LINE,BLUE);
	plot("Short1",vShort1,NEW|LINE,RED);
}


I call script because each "script" load different ml files. Don´t know how to call different .ml files with advice function,in the same strategy.

Do I explain well what amI trying to do?

Thank you!

Re: Use 3 zorros, one for trading the other two for calculating [Re: tomaslolo] #485538
03/21/22 21:14
03/21/22 21:14
Joined: Aug 2017
Posts: 295
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 295
Netherlands
Are any of those 2 'if (Algo..' statements ever TRUE? I don't see any algo calls in your code.

https://zorro-project.com/manual/en/algo.htm

Page 1 of 4 1 2 3 4

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1