2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
NorbertSz
Junior Member
|
Junior Member
Joined: Jan 2022
Posts: 58
|
|
|
|
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: 69
tomaslolo
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2018
Posts: 69
|
Yes, that is. But I thought there was an easier way. Something like: 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
NorbertSz
Junior Member
|
Junior Member
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+cBefore I found Zorro, I made MT4 EAs, and here's the library I used for the interprocess communication: https://www.fxblue.com/appstore/9/quickchannelBut 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: 69
tomaslolo
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2018
Posts: 69
|
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: / 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]
#485512
03/18/22 17:44
03/18/22 17:44
|
Joined: Feb 2018
Posts: 69
tomaslolo
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2018
Posts: 69
|
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: if(vLongb>threshold and vLongc>threshold)
enterLong(); or similar logic. As stated in the manual: https://zorro-project.com/manual/en/advisor.htmHowever, 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]
#485537
03/21/22 18:25
03/21/22 18:25
|
Joined: Feb 2018
Posts: 69
tomaslolo
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2018
Posts: 69
|
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. // 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!
|
|
|
|