Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Cointoss results in less than 50% win consistently. Why? #467786
08/31/17 16:28
08/31/17 16:28
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Hi. I wrote a script as exercise to perform simple buy/sell for each day with plain Stop and TakeProfit levels over a bit of data. The data is sufficiently large to assume a worthy result. My expectation of the coin toss is around 50% win/loss.

Weirdly though, it consistently yields around 47% wins only. Since Stop and TakeProfit levels are supposedly identical, I assumed the chances that the price hits either one of them balances out over large amounts.

Please find attached image/scripts.

The image shows the total number of cointoss wins/losses for all traded assets.

Also: Is it possible to perform multiple runs in one test session? I wanted to rerun the simulation with new random seeds to get a better picture. I tried setting Bar=0, but that resulted in an error for too many trades.

Attached Files
cointoss.png (16 downloads)
CointossWinLoss.c (15 downloads)
utils.h (8 downloads)
Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467788
08/31/17 20:14
08/31/17 20:14
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
What about commision, slippage and spread? What happens if you add
Code:
Spread = RollLong = RollShort = Commission = Slippage = 0;



Regarding multiple runs; If I understand correctly what you want to do, you should use NumTotalCycles.
http://manual.zorro-trader.com/numtotalcycles.htm

Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467793
09/01/17 08:54
09/01/17 08:54
Joined: Dec 2016
Posts: 71
F
firecrest Offline
Junior Member
firecrest  Offline
Junior Member
F

Joined: Dec 2016
Posts: 71
Maybe need to check the assetfix.csv to understand more.

Re: Cointoss results in less than 50% win consistently. Why? [Re: Dalla] #467794
09/01/17 09:41
09/01/17 09:41
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
Thank you Dalla.

Originally Posted By: Dalla
What about commision, slippage and spread?

I added this behind selecting the asset() but it does not change the win/loss ratio of 47%.

Originally Posted By: Dalla
Regarding multiple runs; If I understand correctly what you want to do, you should use NumTotalCycles.
http://manual.zorro-trader.com/numtotalcycles.htm

That is it. Nice. I adjusted the cointoss script accordingly to run 100 cycles and change the seed() to force different buy/sells but it consistently has more losers than winners. This does not make sense to me. Find attached a new graphic and script that shows the total amount of win/loss per cycle.

Originally Posted By: firecrest
Maybe need to check the assetfix.csv to understand more.

I am not sure what to look out for. I attach that file too. Let's get to the bottom of it tongue

Attached Files
cointoss2.png (14 downloads)
CointossWinLossCycle.c (10 downloads)
AssetsFix.csv (3 downloads)
Last edited by pascalx; 09/01/17 09:41.
Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467806
09/02/17 02:24
09/02/17 02:24
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
Try DETREND.

Re: Cointoss results in less than 50% win consistently. Why? [Re: GPEngine] #467811
09/02/17 08:59
09/02/17 08:59
Joined: Aug 2017
Posts: 40
J
johnnyp Offline
Newbie
johnnyp  Offline
Newbie
J

Joined: Aug 2017
Posts: 40
Why would that help?

The direction of each trade is random, and multiple assets are used, so the price trend can't be influencing the results and there should be an equal number of winners and losers in the long run.

And yet consistently there are fewer winners than losers. Why? What are we missing?

Re: Cointoss results in less than 50% win consistently. Why? [Re: johnnyp] #467814
09/02/17 11:10
09/02/17 11:10
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
I noticed when decreasing the size of Stop and TakeProfit (scaled by ATR value) the difference becomes more apperent. I set it from 0.5 * volatility to 0.2 * volatility and then the win rate becomes something around 27%.

I think the next logical step is to verify that Stop and TakeProfit have the same distance to the trade opening position. If the Stop is tighter than TakeProfit by a few pips, then that would explain the shift in winning %.

Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467818
09/02/17 23:15
09/02/17 23:15
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Perhaps the answer is math?

Let's take a simple example, and assume EUR/USD is trading at 1.00 and you have a TP at plus/minus 0.10.

This means TP and SL at either 1.1 or 0.9. That's a 10% loss or 10% gain, right?

.... well, wait a minute. Let's also consider the exact opposite asset USD/EUR.

0.900 EUR/USD = 1.111 USD/EUR, a 9.1% gain from 1.0 USD/EUR.

1.100 EUR/USD = 0.909 USD/EUR, a 11.1% loss from 1.0 USD/EUR.

To win a long position, you have to gain 10% vs 10%.
To win a short position, you have to gain 9.1% vs 11.1%.

Your scale would be smaller, but it might not be insignificant enough to skew the results in a particular direction.


EDIT: Hmm. If I comment out the enterLong line, I get 47% ish wins, whereas if I comment out the enterShort line, I get about 45% ish wins. I think I'm partially correct, but I'm not sure why they're both under 50%.

Last edited by AndrewAMD; 09/03/17 00:47.
Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467820
09/03/17 08:57
09/03/17 08:57
Joined: Aug 2017
Posts: 58
P
pascalx Offline OP
Junior Member
pascalx  Offline OP
Junior Member
P

Joined: Aug 2017
Posts: 58
I attached an updated version to CointossWinLossCycle.c that will print total win/loss percentage after all accumulated cycles.

I wanted to inspect the TRADE values of a given trade but weirdly it has no correct values. Find attached StopVsProfit.c. Also I was wondering why the TRADE struct stores its values with float precision only. Wouldn't you assume that double is generally preferred? I don't know if there is a practical difference in this case, just thought it is odd because everything else is treated as double.

Code:
void run()
{
	if (Bar == StartBar)
	{
		Stop = 50*PIP;
		TakeProfit = 50*PIP;
		TRADE* pTrade = enterLong();
		
		if (pTrade)
		{			
			printf("nEntryPrice [%.7f]", pTrade->fEntryPrice); // 0.000000
			printf("nStopLimit [%.7f]", pTrade->fStopLimit); // 0.000000
			printf("nProfitLimit [%.7f]", pTrade->fProfitLimit); // 0.000000 why???
		}
	}
}




Code:
typedef struct TRADE
{
	float	fEntryPrice;	// buy price, or premium without multiplicator
	float	fExitPrice;	// sell price per unit, without spread
	float fResult;		// current profit of the trade
	float	fEntryLimit;	// buy entry limit
	float	fProfitLimit;	// profit limit price
	float fTrailLock;	// profit target distance to initial price, positive (long) or negative (short)
	float	fStopLimit;	// stop loss limit price
... Much float. Many wow.
} TRADE;


Attached Files
CointossWinLossCycle.c (8 downloads)
utils.h (5 downloads)
StopVsProfit.c (5 downloads)
Last edited by pascalx; 09/03/17 21:54.
Re: Cointoss results in less than 50% win consistently. Why? [Re: pascalx] #467855
09/04/17 16:40
09/04/17 16:40
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
The tradeoff here is RAM usage.

Page 1 of 2 1 2

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