Binary Options Bugs

Posted By: trenki2

Binary Options Bugs - 10/29/16 12:10

I have experimented with the binary options script from the financial hacker blog. Below is the code that I use:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}

function run()
{
	//assetList("AssetsFix.csv");
	//assetList("AssetsBinary.csv");
	
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	WinPayout = 75;
	LossPayout = 0;

	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));
	
	while (asset(loop("EUR/USD")))
	{
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



When training and running it on EUR/USD with the provided Zorro 1.5 t6 history I get a total loss while the blog reports an AR of about 180%.

When training and running it on .bar history with Dukascopy data i got a different result. There I was profitable with a SR of 0.77. But doing multiple training runs did not always produce the same results! Once I only got a SR of 0.20!

Since the broker symbol is actually EUR/USD.bo i needed to create a different Assets file by copying the AssetsFix.csv file and changing the symbol names. I did that and noticed totally different results again.

Even uncommenting the line assetList("AssetsFix.csv"); after training changes the testing result substantially. And when training with the AssetsFix.csv the results are different once more. I thought the AssetsFix.csv is the default, so adding this line should not change the results.

I think also the while(asset(loop())) construct causes some problems. This is the only difference between the original code from the blog and the blog code gives different results when backtested.
Posted By: jcl

Re: Binary Options Bugs - 10/31/16 11:58

The data format has no effect on the strategy. But the asset settings can affect the displayed "Annual Return" percentage, which is is the annual profit divided by the sum of drawdown and margin. Since there is no margin for binary options, the "annual return" is not a very useful parameter for a binary strategy. Useful parameters are the profit factor, sharpe ratio, or CAGR.

You must get no loss and no different results with different training runs, or something is wrong with your data or setup. Check your equity curve - it must look as in the attachment:



Attached picture Binary_EURUSD.png
Posted By: trenki2

Re: Binary Options Bugs - 10/31/16 17:03

I uninstalled Zorro S 1.50.6 and reinstalled it and took the history from the download page.

When i take the code from the financial hacker blog an train and test it I can confirm, that I get the same result as you posted in your screenshot.

But when I modify that script and add the while(asset(loop("EUR/USD"))) construct, train and test I get a different result! This behavior is reproducible:

This code
Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	WinPayout = 75;
	LossPayout = 0;

	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	while (asset(loop("EUR/USD")))
	{
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



gives this result:

Code:
Walk-Forward Test: Test8 EUR/USD 2011..2016
[...]
Profit -5$  MI -0$  DD 16$  Capital 23$
Trades 493  Win 56.6%  Avg -0.1p  Bars 1
AR -5%  PF 0.98  SR -0.10  UI 74%  R2 0.00





When i now add the line assetList("AssetsFix.csv"); to the script and test again without training i get this code:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	assetList("AssetsFix.csv");
	
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	WinPayout = 75;
	LossPayout = 0;

	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	while (asset(loop("EUR/USD")))
	{
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



With the following result:

Code:
Walk-Forward Test: Test8 EUR/USD 2011..2016
Account AssetsFix.csv 
[...]
Profit -103$  MI -2$  DD 104$  Capital 96$
Trades 493  Win 45.2%  Avg -2.4p  Bars 1
AR -24%  PF 0.62  SR -2.10  UI 100%  R2 0.87






I have described the steps to reproduce this behavior in detail. You should be able to copy the exact above code and reproduce it yourself.

Zorro is freshly installed and the history comes directly from the Zorro homepage so that can't be the issue here.
Posted By: trenki2

Re: Binary Options Bugs - 11/03/16 16:35

Can someone test this and report their results?
Posted By: pcz

Re: Binary Options Bugs - 11/03/16 18:37

Originally Posted By: trenki2
Can someone test this and report their results?


Just tried it very quicky and I get similar results to yours.
Posted By: jcl

Re: Binary Options Bugs - 11/04/16 10:07

Reinstalling Zorro normally won't help when something does not work. When you get different results, compare the logs. Then you'll normally quickly see the reason.

I suspect several reasons. First, you did not train the system. Since a portfolio strategy has different parameter files than a single-asset strategy, you must train it again when you made such a modification. Second, you did not trade with payout. The "AssetsFix" file is set up for normal trading with spread and commmission, so you must alter asset parameters for binary trading when you explicitly load it. And select the asset before modifying them, like this:

while (asset(loop("EUR/USD")))
{
...
WinPayout = 75;
LossPayout = 0;
Spread = Commission = 0;
...

I don't know if this is the whole problem, but anyway if this does not help, please post again and I'll look into it.
Posted By: trenki2

Re: Binary Options Bugs - 11/04/16 11:46

Hi jcl,

I actually did train the system and got the results that i posted. I did exactly as I described above.

I now also tried to move the WinPayout and LossPayout variabeles inside the while loop as that makes sense but I still get the same result as in my previous post:


This code:
Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	//assetList("AssetsFix.csv");
	
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	while (asset(loop("EUR/USD")))
	{
		WinPayout = 75;
		LossPayout = 0;
		
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



Gives this result:
Code:
Walk-Forward Test: Binary EUR/USD 2011..2016
Profit -5$  MI -0$  DD 16$  Capital 23$
Trades 493  Win 56.6%  Avg -0.1p  Bars 1
AR -5%  PF 0.98  SR -0.10  UI 74%  R2 0.00



And there is still the weird issue when I uncomment and test with the assetList line, that the results become different again.

I then get these results:

Code:
Walk-Forward Test: Binary EUR/USD 2011..2016
Account AssetsFix.csv 
Profit -103$  MI -2$  DD 104$  Capital 96$
Trades 493  Win 45.2%  Avg -2.4p  Bars 1
AR -24%  PF 0.62  SR -2.10  UI 100%  R2 0.87

Posted By: jcl

Re: Binary Options Bugs - 11/04/16 11:49

Ok, I've just tried it, but found no problem after training it separately. I get always the equity curve that I posted above. But when explicitely loading "AssetFix" you must also set the spread and commission to zero:

Spread = Commission = 0;

Otherwise you're trading with the default spread and commission from "AssetsFix".
Posted By: trenki2

Re: Binary Options Bugs - 11/04/16 12:32

I have tested it on two different computers and get the same results. pcz was also getting similar results to me.

What are you doing differently?

I can copy paste the above code into a new script, hit the train button and then the test button and get my wrong results.

I can even make you a screen capture video showing it if you really want.
Posted By: jcl

Re: Binary Options Bugs - 11/04/16 14:56

Testing on different computers will not help either - if something doesn't work, switching the computer won't fix it. So let's find out systematically what's different between your test and mine. First, compare the logs between the working and the not working version. Which differences do they have?
Posted By: trenki2

Re: Binary Options Bugs - 11/04/16 15:50

Ok, I have run the version from the financial hacker blog and also the last one posted here where the WinPayout and LossPayout variables are set inside the loop.

I did set(LOGFILE) so that log files are beeing produced.

I have uploaded the full log files here: Log.zip

I have compared the train logs. They are identical. I have compared a few generated parameter files. They are identical.

I made a file compare with the Windows utility program FC file1 file2 between the test logs as they are different and attached the result to this post.

The working test log has a filesize of 17 287 150 bytes while the buggy version log file has a size of 17 096 468 bytes.

There are a lot of price differences like so:

Code:
***** BinaryBugtest.log
[98749: Tue 08.05.12 20:35] (1.30068)
[EUR/USD::L4901] Long 1@1.30064  at 20:35:00

***** BINARYWORKINGTEST.LOG
[98749: Tue 08.05.12 20:35] (1.30068)
[EUR/USD::L4901] Long 1@1.30063  at 20:35:00

*****

***** BinaryBugtest.log
[98750: Tue 08.05.12 20:40] +0 +1 1/0  (1.30064)
[EUR/USD::L4901] Sell 1@1.30063: -1.00 at 20:40:00

***** BINARYWORKINGTEST.LOG
[98750: Tue 08.05.12 20:40] +0 +1 1/0  (1.30064)
[EUR/USD::L4901] Sell 1@1.30059: -1.00 at 20:40:00



And maybe some other differences but there were too many of them so the tool did not show all of them.

Attached File
diff.txt  (2 downloads)
Posted By: jcl

Re: Binary Options Bugs - 11/04/16 17:15

Ok, obviously the entry and exit prices in your logs don't match. This explains the problem. Correct are only the prices in your "BINARYWORKINGTEST.LOG" version. That's the prices that I get.

The next question is how you got the wrong prices? Is it the same historical data in both cases? And have you really set the spread to zero?
Posted By: trenki2

Re: Binary Options Bugs - 11/04/16 17:37

I use the same data in both cases! The training run seems to not be affected as the training log files are the same, only when testing the strategy there are differences.

I have tested the script from my last post and I also tried whether setting Spread = 0 inside and outside of the while loop would make any difference but it does not.
Posted By: jcl

Re: Binary Options Bugs - 11/07/16 09:30

Hmm, I would normally give up at this point and forward you to Zorro support, who are specialized in finding out what your script is doing. But a last attempt: Can you post here the complete script that enters at wrong prices?
Posted By: trenki2

Re: Binary Options Bugs - 11/07/16 16:28

I basically have posted the script already above but here it is again:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	set(LOGFILE);
	
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	while (asset(loop("EUR/USD")))
	{
		WinPayout = 75;
		LossPayout = 0;
		//Spread = 0;
		
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



You can also uncomment the line with the Spread = 0 but the result is the same:

Code:
Walk-Forward Test: BinaryBug EUR/USD 2011..2016
[...]
Profit -5$  MI -0$  DD 16$  Capital 23$
Trades 493  Win 56.6%  Avg -0.1p  Bars 1
AR -5%  PF 0.98  SR -0.10  UI 74%  R2 0.00

Posted By: jcl

Re: Binary Options Bugs - 11/08/16 12:21

Spread or not makes a HUGE difference, in fact I get the same wrong prices above when I run that script. You must set spread to zero for binary portfolio trading, and also commission:

Spread = Commission = 0;

Train again afterwards. Just commenting-in the line is not enough when you still trained with the wrong script.
Posted By: trenki2

Re: Binary Options Bugs - 11/08/16 14:24

Its interesting that you now also get the wrong results. I posted that same script earlier and then you said you got the right results! So it seems you are not getting the same results every time?

And Spread and Commission does NOT MAKE ANY difference for me. I have trained and tested with both!!! Like so:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	set(LOGFILE);
	
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	while (asset(loop("EUR/USD")))
	{
		WinPayout = 75;
		LossPayout = 0;
		Spread = Commission = 0;
		
		if(NumOpenLong+NumOpenShort == 0) 
		{
			LifeTime = 1;
			if(HH(TimePeriod) - priceClose() < Threshold)
				enterShort();
			else if(priceClose() - LL(TimePeriod) < Threshold)
				enterLong();
		}
	}
}



I get the wrong results as I already posted!

Could you post the full script with a working asset loop that produces the correct results for you?
Posted By: jcl

Re: Binary Options Bugs - 11/09/16 14:20

I get the wrong results with the wrong script and the right results with the right script. Here is it:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	assetList("AssetsFix.csv");
	set(PARAMETERS|LOGFILE|TESTNOW);
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -2;
	PlotHeight1 = 340;
	PlotWidth = 800;
	
	set(BINARY);
	
while (asset(loop("EUR/USD")))
{	
	WinPayout = 75;
	LossPayout = 0;
	Spread = Commission = 0;
	LifeTime = 1;
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	if(NumOpenLong+NumOpenShort == 0) 
	{
		if(HH(TimePeriod) - priceClose() < Threshold)
			enterShort();
		else if(priceClose() - LL(TimePeriod) < Threshold)
			enterLong();
	}
}
}

Posted By: trenki2

Re: Binary Options Bugs - 11/09/16 17:08

Just tested it. Copy pasted it into a new script, hit train and let it run.

Got the WRONG RESULTS:

Code:
Parameters stored in Test5_19.par

Run Test5..
Assets..
Walk-Forward Test: Test5 portfolio 2011..2016
Account AssetsFix.csv 
Read Test5_1.par Test5_2.par Test5_3.par Test5_4.par Test5_5.par Test5_6.par Test5_7.par Test5_8.par Test5_9.par Test5_10.par Test5_11.par Test5_12.par Test5_13.par Test5_14.par Test5_15.par Test5_16.par Test5_17.par Test5_18.par Test5_19.par
Profit -5$  MI -0$  DD 16$  Capital 23$
Trades 493  Win 56.6%  Avg -0.1p  Bars 1
AR -5%  PF 0.98  SR -0.10  UI 74%  R2 0.00
Time 00:02:15



I don't know how you can get the right results then, but I think I will have to go to zorro support then.

If you want I can upload you a VirtualBox Image with a freshly installed Zorro that shows the problematic behaviour!
Posted By: trenki2

Re: Binary Options Bugs - 12/05/16 10:34

The support suggested to always set the EXTRADATA flag and Slippage = 0. When I do this I get the same result for both scripts. But now the strategy is not really profitable any more.
© 2024 lite-C Forums