Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Imhotep, opm), 785 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: jcl] #476151
01/29/19 11:03
01/29/19 11:03
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Quote:
In finance the goal is normally predicting the future price direction or trade result. I suppose that's also the intention of your script.

Exactly, that's what i try. Maybe we understand each other wrong, but I'm talking about the method Objective = 0, which causes every positive trade to count as a signal. I do not understand what an ML-Algo should / can learn if we open randomly a trade on each bar and then use the results as a learning guide -> because in neural.train() in R you're doing this: Y <- ifelse(Y>0,1,0)

So every Trade with profit is learned as GOOD. No matter where in the chart it starts, no matter how big or small it was, what's "the underlying rule / the strategy / the edge" of signals generated in that way? What is the trade based on? Sorry that I ask so much, that's because I would like to understand the approach.

But I am currently on a very different problem cry . This thread was actually about using RULES | PARAMETERS with asset() and algo() in loops(). We have already clarified that this is not possible, which is a pity. The solution was using "custom for loops" and not the loop() function from Zorro.

Code:
string myALGO[2];

int algoList() {

	myALGO[0] = "W4T0";
	myALGO[1] = "W4T1";

	return(2);

}

function W4T() {

	TimeFrame = 1;

	var  op1 = optimize(100,100,200,100);	
	var  op2 = 3;// optimize(1,1,2,1);

	vars dat = series(price());
	vars trd = series(LowPass(dat,op1));
	vars mmi = series(MMI(dat,300));
	vars smo = series(LowPass(mmi,300));
		
	Stop  = op2 * ATR(100);
	Trail = 0;

	if(strstr(Algo,"W4T0")) {
		
		if(valley(trd)) enterLong(); else			
		if(peak(trd))   enterShort();

	} else if(strstr(Algo,"W4T1")) {

		if(falling(smo) && valley(trd)) enterLong(); else			
		if(falling(smo) && peak(trd))   enterShort();

	}

}

function run() {

	set(COMMONSTART|PARAMETERS|OPENEND|LOGFILE);

	StartDate    = 2016;
	EndDate      = 2017;
	BarPeriod    = 60;
	LookBack     = 500;

	DataSplit    = 70;
	NumWFOCycles = 5;
	
        PlotWidth    = 3000;
	PlotHeight1  = 666;	
	Verbose      = 3; // default 1

	int asc = assetList("AssetsFix.csv"); // please edit	
	int alc = algoList();
	
	int i   = 0;
	int j   = 0;	

	for(i=0;i<2;i++) { // test only scan 0 & 1
	
	   asset(Assets[i]);

		for(j=0;j<alc;j++) {
	
			algo(myALGO[j]);			

			Script = strf("%s%s",Asset,Algo);
	
			if(is(INITRUN)) watch("#INITRUN @ Bar",Bar,Asset,Algo,Script);	
	
			if(strstr(Algo,"W4T")) W4T();
	
		}
	
	}

}


I expected Zorro to produce single .par files for each Asset / Algo / WFOCycle, at least after changing the script name. However, only 1 file per WFOCycle is created. It contains 4 parameters, that is wrong or what I have misunderstood here?

Zorro creates the file in EXITRUN? How can i force the creation of separate files inside the for loops?

Last edited by laz; 01/29/19 11:34.
Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: laz] #476154
01/30/19 04:25
01/30/19 04:25
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I do not really understand the randomly opened trade issue. You do not open them randomly, you open them always. Thats just how training works. The more trades, the better the training. The example uses classification, but the method is the same for regression.

Your multi asset optimizing does probably not work because loop() is missing. And Script renaming has no effect until the parameters are stored. They go into a single file. Look up loop() in the manual and check out workshop 6, which you can use as a template. If you want many files for some reason, either train all assets separately, or write a script to split the .par file into many.

Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: jcl] #476218
02/05/19 15:32
02/05/19 15:32
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hi jcl, I soon realized that I had probably misunderstood something.

Quote:
Training rules and parameters at the same time only works with single assets, not with a portfolio system that contains loops with asset or algo calls. If required, train all portfolio components separately (manually) and combine the resulting .c files. The Combine.c script can...

I had thought that you could use several assets and algos + parameter optimization if you run it in a self created loop grin. I'm already using the asset () and algo () loop from W6 again. The parameter optimization is done in R. Fortunately, I found my old "caret" framework and integrated it into Zorro.

Question 1 is solved laugh

Quote:
I do not really understand the randomly opened trade issue. You do not open them randomly, you open them always. Thats just how training works. The more trades, the better the training. The example uses classification, but the method is the same for regression.

And how do you know how you have to apply this later? How do you then determine the targets and the stops of these trades in Testing/Trading?

Quote:
is the same for regression

Is that the hidden hint? crazy ?

Last edited by laz; 02/05/19 15:39.
Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: laz] #476221
02/05/19 17:30
02/05/19 17:30
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Stops and targets are normally not used in training.

Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: jcl] #476224
02/05/19 22:39
02/05/19 22:39
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
I understand that, but the question was:

How do you then determine the targets and the stops of these trades in Testing / Trading?

After you have fitted the model in training...

Last edited by laz; 02/05/19 22:39.
Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: laz] #476225
02/06/19 07:41
02/06/19 07:41
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Normally not at all, since the trained trades have no stop and TP. But often distant stops are still used for preventing rogue trades. The distance is then determined by average volatility.

Of course, if you want, you can optimize stops and TPs with a case 1 combination, after training the ML model.

Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: jcl] #476228
02/06/19 11:36
02/06/19 11:36
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Now it's getting really interesting, thank you very much for sharing your knowledge with us/me. smile

To summarize your explanations:

1.0) Training:
1.1) - you open a new trade on every bar (no TP / SL), Zorro saves the returns of every trade/bar
1.2) - in your examples you convert the trade return results to binary 0/1
1.3) - you train your ml-model with the binary(0/1) signal as target
1.4) - the lifetime of the trade is regulated only by the parameter LifeTime

2.0) Testing / Trading:
2.1) - a far away stop outside of the "normal working area" is used as an emergency anchor
2.2) - the distance (TP/SL/both?) is then determined by average volatility
2.3) - the LifeTime parameter is ...?
2.4) - you close the trade by ...?

Questions:
I am really sorry but some parts of this approach are still unclear, if it is ok - I would like to ask more?

Q-1.2) you convert the trade returns to a binary outcome and train that 0/1 result.
But - in this way, you remove exactly the information as to how successful the predicted trade may be or am I wrong? Why?

Q-2.2) The distance (determined by average volatility) of the target / stop or both?

Q-2.3) The LifeTime parameter is now enabled/disabled in Testing / Trading?

Q-2.4) You close the trade by TP/SL or on opposite signal only?

The most confusing thing is the conversion into a 0/1 signal. If you were going to use different
classes (<= 10Pip || >10Pip/>20Pip...) as a target or make a regression on the trade return - I
would understand that. You already mentioned something similar.

Very interesting to talk about it, thank you!

Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: laz] #476271
02/09/19 10:39
02/09/19 10:39
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Removing unnecessary information can be essential for effective machine learning. You often use 0/1 classification, not regression. Same reason why you normally use only a few signals as inputs, not the whole price curve. Just test it and you'll see what is better in your case.

A frequent trade setup is no TP, distant Stop, and Lifetime the same as in training.

Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: jcl] #476338
02/19/19 17:12
02/19/19 17:12
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
I'm still testing it, but I can not come to a reasonable conclusion. The hit ratio is quite impressive, but the many small trades with little profit do not compensate for the losses? That was also the reason why I wondered, why every trade return > 0 is to be considered as positive. The NN/ANN is trained to execute also the small trades.

If we cast TradeReturns into 1/0 we get the direction but we lose any information about the expected movement?

I have been searching for long time for the topic "trade returns and/or classification machine learning etc.", but I did not find anything that works profitable with this approach. Fitting a classification model on the binary (0/1) trade results makes sense, because you do not need a trainer and your classes are more balanced. But how do I get that profitable? That's why i switched to forecasting/predicting the next x values, before I discovered Zorro.

But this is not the way how Zorro or all of your examples work.

Maybe I was on the wrong track, what did I misunderstand?

Last edited by laz; 02/19/19 18:03.
Re: optimize and PARAMETERS|RULES - in asset() & algo [Re: laz] #476387
02/21/19 23:14
02/21/19 23:14
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
After endless testing and thinking and testing again, I now think I have come to a conclusion. I now understand how it works & why you are not a fan of fixed TP / SL.

Code:
!-- mfe/mea check --------------------------- PIP 0.00010 
!hrz 3 | trade @ bar 6808 | TakeProfit 88.97132 pips | Stop 44.48566 pips 
!hrz 3 | trade @ bar 6808 | 13.40032 pips (mfe) profit | -36.59964 pips (mae) loss 
!-- mfe/mea check --------------------------- PIP 0.00010 
!hrz 3 | trade @ bar 6809 | TakeProfit 89.31737 pips | Stop 44.65868 pips 
!hrz 3 | trade @ bar 6809 | 32.19962 pips (mfe) profit | -6.69956 pips (mae) loss



If you look at those numbers and think about them, you'll notice why every type of fixed SL / TP in training is totally counterproductive.

You just can not impose your will on the market wink ...

MFE & MAE are for the next 3 bars ...

And now I know in which direction I will continue to search, thank you for notifying me JCL and sorry for my lack of clarity.

Page 2 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1