Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, howardR, sleakz), 674 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
FPI and Zorro #470509
01/17/18 17:26
01/17/18 17:26
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

I testing FPI with Zorro Machine learning - DTREE.

this is after test the 2017.

source:
Code:
#define _LONG 1
#define _SHORT 2
#define _WRONG -999

//#define _DEBUG_ 
#define _PLOT_
//#genparam

bool Reinvest = true;
bool UseOptimalF = true;

var CalculateMargin(int side)
{
	var value = 0.03 * Capital;
	
	if (Reinvest)
	{
		//value *= sqrt(1+Balance / Capital);
		value *= sqrt(1 + max(0, ProfitClosed/Capital));
	}
	
	if (UseOptimalF)
		value *= ifelse(side == _LONG, OptimalFLong, OptimalFShort);

	return value;
}

void run(){
  	
	BarPeriod = 5;
	TimeFrame = 12;
	LookBack = 1800;
	NumYears = 1;
	TradesPerBar = 12;
	MaxLong = MaxShort = 2;
	
	//NumWFOCycles = 12;
	NumCores = -1;
	//MaxBars = 2400;
  
	if(Train) Hedge = 2;
	set(RULES|TESTNOW|FACTORS);
	#ifdef genparam
	set(PARAMETERS);
	#endif
	#ifdef _DEBUG_
	set(STEPWISE);
	#endif
	#ifdef _PLOT_
	set(PLOTNOW);
	PlotScale = 8;
	//PlotWidth = 400;
	PlotHeight1 = 450;
	PlotHeight2 = 120;
	PlotDate = 20170701; 
	PlotBars = 200;
	ColorEquity = 0;
	#endif
	
	//set(TICKS|FAST);
	
	Capital = 50000;
		
	// -- PREPARE fpi

	asset("EUR/USD");
	#ifdef genparam
	int nLowUS = optimize(800,800,2000);
	#else
	int nLowUS = 1000;
	#endif
	
	vars A = series(LowPass(series( priceClose()),nLowUS));
	
	asset("GBP/USD");
	#ifdef genparam
	int nLowGS = optimize(800,800,2000);
	#else
	int nLowGS = 1000;
	#endif
	
	vars B = series(LowPass(series( priceClose()),nLowGS));
	
	asset("EUR/GBP");
	#ifdef genparam
	int nLowEG = optimize(800,800,2000);
	#else
	int nLowEG = 1000;
	#endif
	
	vars C = series(LowPass(series( priceClose()),nLowEG));
	
	var pom= (1-C[0]*B[0]/A[0])*100;
	var aTest[2];
	aTest[0]=(scale(pom,100));


	asset("EUR/USD");
		#ifdef genparam
		int nHiUS = optimize(400,400,1200);
		int nTP = optimize(2,2,10);
		#else
		int nHiUS = 800;
		int nTP = 2;
		#endif
		
		aTest[1]= 100*HighPass(A,nHiUS);
		#ifdef _PLOT_
		plot("FPI",series(aTest[0]),NEW|BARS,BLUE);
		plot("HP",series(aTest[1]),NEW|BARS,BLUE);
		#endif
		
		Stop = 5*ATR(100); 
		TakeProfit = nTP*ATR(100);

		if(adviseLong(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_LONG);
			enterLong();
			#ifdef _PLOT_
			plot("LONG",priceClose(),MAIN|CROSS,GREEN);
			#endif
		}
		if(adviseShort(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_SHORT);
			enterShort();
			#ifdef _PLOT_
			plot("SHORT",priceClose(),MAIN|CROSS,RED);
			#endif
		}

	asset("GBP/USD");
	
		#ifdef genparam
		int nHiGS = optimize(400,400,1200);
		int nTPGS = optimize(2,2,10);
		#else
		int nHiGS = 800;
		int nTPGS = 2;
		#endif
		
		aTest[1]= 100*HighPass(B,nHiGS);
		Stop = 5*ATR(100); 
		TakeProfit = nTPGS*ATR(100);

		if(adviseLong(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_LONG);
			enterLong();
		}
		if(adviseShort(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_SHORT);
			enterShort();
		}
		
	asset("EUR/GBP");
	
		#ifdef genparam
		int nHiEG = optimize(400,400,1200);
		int nTPEG = optimize(2,2,10);
		#else
		int nHiEG = 800;
		int nTPEG = 2;
		#endif

		aTest[1]= 100*HighPass(C,nHiEG);
		Stop = 5*ATR(100); 
		TakeProfit = nTPEG*ATR(100);

		if(adviseLong(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_LONG);
			enterLong();
		}
		if(adviseShort(DTREE,0,aTest,2) > 0){
			Margin=CalculateMargin(_SHORT);
			enterShort();
		}

}



But I don't know, howto optimize PARAMTERS with FACTOR. Is no working.

Attached Files
5xcor_dtree3_EURGBP.png (24 downloads)
Re: FPI and Zorro [Re: Grat] #470513
01/17/18 21:18
01/17/18 21:18
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
... Continue..

Set (RULES)... Working OK,
But I also need the optimizing parameters.

RULES x PARAMETERS aren't working together for

adviseLong (DTREE)

Attached Files
Re: FPI and Zorro [Re: Grat] #470518
01/18/18 06:47
01/18/18 06:47
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Read here: http://zorro-project.com/manual/en/training.htm
Specifically the section named "Combining rules and parameters"

Re: FPI and Zorro [Re: Dalla] #470521
01/18/18 13:13
01/18/18 13:13
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Thank's

but after I trying I get parameters in the .par file only for 1 asset:

Quote:
EUR/GBP 975 974 968 785 2.43 785 2.43 785 3.24=> 1.511


for other 2 (EUR/USD, GBP/USD) no
( version 1.745 S)

I thinking if have this:
Code:
asset("EUR/USD");
       nE=optimize(...);

	asset("EUR/NZD");
       nN=optimize(...);

	asset("EUR/JPY");
       nY=optimize(...);

...
...

	asset("EUR/USD");
       nE2=optimize(...);

	asset("EUR/NZD");
       nN2=optimize(...);

	asset("EUR/JPY");
       nY2=optimize(...);



save PARAMETERS only for last Asset -> "EUR/JPY"
only for nY and nY2



Last edited by Grat; 01/18/18 21:14.

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1