Gamestudio Links
Zorro Links
Newest Posts
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
5 registered members (Petra, AndrewAMD, Quad, VoroneTZ, 1 invisible), 488 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
Page 2 of 3 1 2 3
Re: Additional testing to be undertaken... [Re: Hredot] #471425
03/03/18 16:10
03/03/18 16:10
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
In case of use of oversampling the graph will plot the distribution of all trades or only of one sample?

Re: Additional testing to be undertaken... [Re: Hredot] #471426
03/03/18 16:20
03/03/18 16:20
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
MAE stands for Maximum Adverse Excursion. It's a nice tool to visually determine if and where to place a stop.

Every trade made by your system is represented by a dot. If the trade was profitable, it is green and above zero. If it was unprofitable, it is red and below zero. So the higher the dot, the better.

The X axis is maximum excursion of a trade, in percentage of the trade's position.

The Y axis is profit/loss of a trade, in percentage of the trade's position.

Say you buy a stock at $100.00, it reaches a low of $99.00, and it sells at $120.00. Your trade will plot at (1.0,20.0). That is, 1% drawdown, 20% profit.

To see visually the effect of adding a percentage-based stop loss, draw a vertical line. Any greens to the right of the line become losses, and any reds become less unprofitable. Thus, it appears to be useful for 1ND1G0 and not for Hredot.

But we have Zorro, so we can easily optimize after using our visual cue.

Hredot: I like your plot, you have some very profitable trades. What I don't understand is why your system isn't profitable when it sees very small drawdowns (<=0.6% per trade). In any case, I don't think you need to add stop losses because it can hurt your profitability.

Re: Additional testing to be undertaken... [Re: MatPed] #471427
03/03/18 16:23
03/03/18 16:23
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: MatPed
In case of use of oversampling the graph will plot the distribution of all trades or only of one sample?
All trades. The code is in your profile.c header, so you can tweak it for your own purposes if necessary.
Code:
void plotMAEPercentGraph(int bars)
{
	if(!is(TESTMODE)) return; 
	g->dwStatus |= PLOTSTATS;
	if(is(EXITRUN))
	{
		if(!bars) bars = 50;
	
		var vMaxMAE = 0;
		for(all_trades) // calculate maximum MAE relative to open
			vMaxMAE = max(vMaxMAE,(100.*TradeMAE/(TradePriceOpen)));
		//printf("nMaxMAE: %.0f",vMaxMAE);
	
		var vStep;
		if(bars < 0) // bucket size in thousandths of percentage points (i.e. 0.001%)
			vStep = (bars * (-1.) / (1000.));
		else
			vStep = max(0.05, roundto((vMaxMAE/bars),0.001));
		printf("  Step: %.3f",vStep);
		
		for(all_trades) 
		{
			var vResult = (100*TradeProfit/(TradeUnits*TradePriceOpen));
			var vMAE = (100.*TradeMAE/(TradePriceOpen))/vStep;
			int n = floor(vMAE);
			plotBar("Profit",n,n*vStep,0,AVG|BARS|LBL2,COLOR_DEV);
			if(vResult > 0)
				plotGraph("Win",vMAE,vResult,DOT,GREEN);
			else
				plotGraph("Loss",vMAE,vResult,DOT,RED);
		}
	}
}


Re: Additional testing to be undertaken... [Re: AndrewAMD] #471428
03/03/18 16:52
03/03/18 16:52
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
Thanks for the explanation!

Btw, that plot was not from a real system. Rather an ideal one that strives to achieve optimal performance by using PEEK. It is actually surprising how hard it is to code an ideal system using only traditional indicators even when it knows the future... The idea is, if an approach does poorly when future is known, there is no chance it will succeed with only present information. A way to discard garbage ideas.

Last edited by Hredot; 03/03/18 16:54.
Re: Additional testing to be undertaken... [Re: AndrewAMD] #471430
03/03/18 17:36
03/03/18 17:36
Joined: Feb 2018
Posts: 25
1
1ND1G0 Offline OP
Newbie
1ND1G0  Offline OP
Newbie
1

Joined: Feb 2018
Posts: 25
Many thanks for this information, Andrew. It's very much appreciated.

In terms of limiting my max drawdown so somewhere around 1%, is it just a case of adding in a line along the lines of Risk = 1; or is there more to it than that?

Re: Additional testing to be undertaken... [Re: 1ND1G0] #471432
03/03/18 18:03
03/03/18 18:03
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I don't think that's how the Risk variable works. Anyways, I would take a different approach using trade management functions.

Slightly modifying the code above, below is your percentage MAE...
Code:
//for a given trade...
var vPercentMAE = 100.*TradeMAE/(TradePriceOpen);

If you close a trade once the above variable reaches 1.0 or higher, you will have drawn a vertical line on your chart at 1.0. See how it affects your chart. And then attempt an optimization of this parameter, such as 0.5 to 1.5 in 0.1 increments, and see what you end up with on the chart.

See also...
(TMF, TradeMAE): http://zorro-project.com/manual/en/trade.htm
(optimize): http://zorro-project.com/manual/en/optimize.htm

EDIT: In retrospect, don't use TMF, use Stop.

Last edited by AndrewAMD; 03/04/18 23:34. Reason: Stop instead of TMF
Re: Additional testing to be undertaken... [Re: AndrewAMD] #471433
03/03/18 18:21
03/03/18 18:21
Joined: Feb 2018
Posts: 25
1
1ND1G0 Offline OP
Newbie
1ND1G0  Offline OP
Newbie
1

Joined: Feb 2018
Posts: 25
Thanks again, Andrew.

I'm probably doing something wrong but it seems to only make things worse when I try and add this type of trade management into the mix.

I added your code to create the var, then the below:

Code:
for(open_trades)
   if(vPercentMAE > 1.0)
   exitTrade(ThisTrade);



Even optimising this parameter does not help.

In any case, this is certainly very good to know and I will certainly use this (i.e. the MAE graph) in future development.

Re: Additional testing to be undertaken... [Re: 1ND1G0] #471434
03/03/18 18:34
03/03/18 18:34
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Did you define the variable inside the for loop?
Code:
for(open_trades) 
{
   // assuming no virtual hedging / pool trading
   var vPercentMAE = 100.*TradeMAE/(TradePriceOpen);   
   if(vPercentMAE > 1.0)
      exitTrade(ThisTrade);
}


Re: Additional testing to be undertaken... [Re: AndrewAMD] #471443
03/04/18 15:42
03/04/18 15:42
Joined: Feb 2018
Posts: 25
1
1ND1G0 Offline OP
Newbie
1ND1G0  Offline OP
Newbie
1

Joined: Feb 2018
Posts: 25
Alas, I have not been able to get this working as expected.

This is however certainly something I will work on figuring out eventually, as now that I can see the results on the graph, it is very clear this will improve my overall performance (for this particular algo).

Thanks again for your insight in this area, Andrew.

Re: Additional testing to be undertaken... [Re: 1ND1G0] #471444
03/04/18 16:01
03/04/18 16:01
Joined: Feb 2018
Posts: 25
1
1ND1G0 Offline OP
Newbie
1ND1G0  Offline OP
Newbie
1

Joined: Feb 2018
Posts: 25
Ah, scratch that - It's not the most elegant solution, but I did the following:

- instead of generating the graph with percentages, I used plotMAEGraph(50); instead, so I could see the actual pip values
- I then set a basic stop at the 120 pip level as that represented the vertical line that Andrew alluded to
- this improved all metrics in the test period

One thing that you can see in the newly generated output, is that even with a stop at 120 pips, there is a number (albeit just a few) losing trades that have a value further right that this level. Which seems strange.

Attached Files 2018-03-04 16_00_12-Chart Viewer - [Algo_One_XXXX_s.png - Image 1 of 1 [100%]].png
Page 2 of 3 1 2 3

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