stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Zigzag Bollinger Band
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3237
Page 6 of 28
Author:  snailbeard [ Fri Jan 17, 2014 7:39 pm ]
Post subject:  Re: Zigzag Bollinger Band

More pitfalls with Empty4, back-testing and custom DLLs

Pitfall 1
Rerunning strategy tester:
DLLs are not automatically unloaded then reloaded:
therefore any global or static data in the DLL does not automatically get reset when you re-run CrappyTester.

Pitfall 2
Having successfully added code to unload your custom DLL
On running a back test more than once you now see something like:

Code: Select all

call from dll  critical error c0000005
This is because the DLL was unloaded, but CrappyTester/Empty4 has to be closed and restarted, or otherwise forced to drop and reload the script, so that the DLL is loaded again.


Here is an example of unloading a DLL

Code: Select all

int deinit()
{
	
   if (IsTesting())
   {
      int HMOD = GetModuleHandleA("GetHighLowBar.dll");
      if (HMOD != 0) FreeLibrary(HMOD);
   }	

	return(0);
}
Author:  snailbeard [ Sat Jan 18, 2014 10:56 am ]
Post subject:  Re: Zigzag Bollinger Band

Mysteries of MetaMisQuotes CrappyTester revealed

Logging the differences between minute by minute tracked minimum bar values of the weekly open bar for 1 month ( January 2010 AAUDUSD ) exposed the following errors:

Code: Select all

20140118.log:104: 09:49:09 2010.01.04 00:00: TF: 10080, Bar Lowest Error: 0.00450, diLowDll: 0.89740, diLowMQ: 0.89290
20140118.log:8369: 09:49:09 2010.01.05 00:00: TF: 10080, Bar Lowest Error: 0.00110, diLowDll: 0.89400, diLowMQ: 0.89290
20140118.log:8443: 09:49:10 2010.01.06 00:00: TF: 10080, Bar Lowest Error: 0.00110, diLowDll: 0.89400, diLowMQ: 0.89290

20140118.log:24018: 09:49:11 2010.01.11 00:00: TF: 10080, Bar Lowest Error: 0.01820, diLowDll: 0.93060, diLowMQ: 0.91240
20140118.log:24049: 09:49:12 2010.01.12 00:00: TF: 10080, Bar Lowest Error: 0.01620, diLowDll: 0.92860, diLowMQ: 0.91240
20140118.log:30818: 09:49:12 2010.01.13 00:00: TF: 10080, Bar Lowest Error: 0.00510, diLowDll: 0.91750, diLowMQ: 0.91240

20140118.log:43602: 09:49:13 2010.01.18 00:00: TF: 10080, Bar Lowest Error: 0.00190, diLowDll: 0.92230, diLowMQ: 0.92040

20140118.log:76123: 09:49:15 2010.01.25 00:00: TF: 10080, Bar Lowest Error: 0.00580, diLowDll: 0.90420, diLowMQ: 0.89840
20140118.log:76193: 09:49:16 2010.01.26 00:00: TF: 10080, Bar Lowest Error: 0.00390, diLowDll: 0.90230, diLowMQ: 0.89840
See the attached chart below.

No discrepancies in the lowest values were found in the other timeframes for this test.
Author:  snailbeard [ Sat Jan 18, 2014 2:05 pm ]
Post subject:  Re: Zigzag Bollinger Band

Over a 12 month back-test about 8000 highest/lowest bar value errors occur:

Code: Select all

Found 5303 matches for "Bar Lowest Error:".

Code: Select all

Found 3118 matches for "Bar Highest Error:".
Although errors occur for all timeframes, the majority of these errors occur for D1 and W1.

Using the custom DLL highest and lowest values instead of CrappyTester values:

Comparing previous simulations with the corrected simulation hopefully gives a more realistic result.
The previous profit factor was about 7.0 and has now reduced to 6.2 with a drawdown just under 3%.

It is a relief that the filters which make use of the open bar values still produce meaningful results :D
This issue can finally be kicked into touch!
Author:  Radar [ Sun Jan 19, 2014 6:56 am ]
Post subject:  Re: Zigzag Bollinger Band

Hey SnailBeard,

You sure as hell are persistent! :)

I've given up on Empty4's slacktester for anything other than finding code errors.

I still try and code in mq"l"4, but the import the code into ProTrader3 for backtesting. I'm also looking at Zorro... My problem is i can't code in C# for PT3, or lite-C for Zorro. They still look like better options than Empty4, though.

It looks like you're going to have a great beastie there after all your hard work! Way to go! :)


Have fun!
Radar =8^)
Author:  SpiderX [ Sun Jan 19, 2014 7:22 am ]
Post subject:  Re: Zigzag Bollinger Band

Hi Snailbeard,

Hope you are using Tickstory or Tickdatasuite for your backtest.
Otherwise the data might be meaningless....

Cheers
Author:  snailbeard [ Sun Jan 19, 2014 9:52 am ]
Post subject:  Re: Zigzag Bollinger Band

Radar » Sun Jan 19, 2014 6:56 am wrote:Hey SnailBeard,

You sure as hell are persistent! :)

I've given up on Empty4's slacktester for anything other than finding code errors.

I still try and code in mq"l"4, but the import the code into ProTrader3 for backtesting. I'm also looking at Zorro... My problem is i can't code in C# for PT3, or lite-C for Zorro. They still look like better options than Empty4, though.

It looks like you're going to have a great beastie there after all your hard work! Way to go! :)


Have fun!
Radar =8^)
Thanks for the heads up on PT3 & C#, not sure about Zorro as I would like to make use of time-saving features of C#. Since C# derives for C/C++ it is not too big a jump from C++. I recently bought a book on C# "Programming .NET Components" by Juval Lowy, which I am very pleased with. Although I have only dipped into it a couple of times. The class attributes are very powerful. For example: the attribute 'serializable' added to a class means without writing lots of file handling code you get a class with built in persistence. It seems there are features to reduce all those hours of typing boilerplate code, which is common in C++ and Java.

I am guessing that it could take a whole year to transfer all the mql4 I have into a modern language especially if 'redesigned' to split it all into reusable components. :(

Anyway, I am definitly going look again at ProTrader3 :)
Author:  snailbeard [ Sun Jan 19, 2014 10:32 am ]
Post subject:  Re: Zigzag Bollinger Band

SpiderX » Sun Jan 19, 2014 7:22 am wrote:Hi Snailbeard,

Hope you are using Tickstory or Tickdatasuite for your backtest.
Otherwise the data might be meaningless....

Cheers
Thanks for mentioning this, since anyone reading this and thinking of writing EA's in MQL and testing them with CrappyTester should STOP and think again. It has been a long and painful road. Eventually I did discover that most sources of data were sabotaged. I have jumped through hoops to download and convert high-quality data from Swiss bank/broker Dukascopy.

CrappyTester is not useless but how far can it be trusted?
CrappyTester has saved me a lot of time, it has shown up logic errors, weakness in trading ideas, serious account killing bugs which only manifest very rarely.
CrappyTester can expose weaknesses in a flawed EA which might not show up for months in forward testiing.

I have run many many EAs through 12 months back-testing and all but two had a long-term decline in to losses.

But if anyone has an opportunity to do it right first time don't start here.

Since I started working with C++ and DLLs I have been able to step through code line by line, examine variables as they change, set breakpoints whereever needed. Although C# and Java might be better choices than C++ nothing feels as good as a proper development platform :D
Author:  SpiderX [ Sun Jan 19, 2014 3:23 pm ]
Post subject:  Re: Zigzag Bollinger Band

Hi Snailbeard,

If you intend to run backtest on Empty4 with dukascopy data, there are a few methods.
One of them gives 90% tick modelling quality.
But from my understanding, the best method using tickstory (Free) or tickdatasuite (Paid) would give you 99.9% quality.
Perhaps it would be wise to consider the latter.

Cheers
Author:  snailbeard [ Mon Jan 20, 2014 10:19 am ]
Post subject:  Re: Zigzag Bollinger Band

I have done some short periods of back-testing in tick mode and compared them to results of the same run using M1 open bars and found the results to be very similar.

The main logic operates on M15, H1, H4 & D1 bars. The Virtual Pending Orders can be triggered by ticks when the price crosses a threshold but usually it would make little difference if the trigger conincided with an M1 bar. Therefore, I back test on M1 rather than tick mode.

Although 99.9% modelling quality would be nice. I believe there are several areas of effort which would have more impact on profits and losses such as locking 20 pips profits if there is a counter momentum line before the target has been reached. It is a tricky area because getting it wrong would spoil longer trades but getting it right would have a big impact on profits. Another, area of improvement is to enter trades when there is a signal pattern based on say Bollinger reentry or other patterns which take time to implement and test. Also since the EA might enter trades or not because of variations in spreads and swap cost it might be more useful to model these more than individual ticks.
Author:  snailbeard [ Tue Jan 21, 2014 2:25 pm ]
Post subject:  Re: Zigzag Bollinger Band

CSS Currency Slope Strength revisited

I have been looking at this again, wondering if it can improve my trading and the EAs trading. It is a very powerful indicator but perhaps using it correctly is harder than it seems. Some members here might even have tried my CPU friendly version of it.

I gave up using it a long time ago: just like BBC News it was telling me over and over again what I already new. Naked traders must find my over croweded charts very amusing but I have not been able to write an EA to trade naked. Although it would be interesting to try and write one that only uses candle patterns. After all everything is derived from the price movement, spread and volume.
Perhaps that could be a ProTrader3 project in a separate thread...

However, back to CSS, this morning I noticed a profitable trade from USDCAD had completed.
1449272 2014.01.20 11:15 buy 0.22 usdcad 1.09524 1.09524 1.10122 2014.01.21 11:52 1.10122 -0.93 0.00 -0.62 72.75
And I thought that this was consistent with the CurrencySlopeStrength reading of high strength

So I decided to look at all USDCAD trades in the history this year and I was surprised to find every single one turned in a profit, no sells only buys:

Code: Select all

:  9: 1093590	2014.01.06 22:03	buy	0.11	usdcad	1.06605	1.06605	1.07174	2014.01.07 12:25	1.06906	-0.46	0.00	-0.32	18.89
: 11: 1157181	2014.01.06 22:03	buy	0.22	usdcad	1.06605	1.06605	1.07174	2014.01.07 15:33	1.07174	-0.93	0.00	-0.63	71.21
: 19: 1179952	2014.01.08 01:00	buy	0.11	usdcad	1.07687	1.07687	1.08231	2014.01.08 07:41	1.08042	-0.46	0.00	0.00	22.03
: 25: 1185825	2014.01.08 01:00	buy	0.22	usdcad	1.07687	1.07687	1.08231	2014.01.08 09:44	1.08231	-0.93	0.00	0.00	67.37
: 33: 1192081	2014.01.08 13:15	buy	0.11	usdcad	1.08158	1.08158	1.08741	2014.01.09 13:54	1.08458	-0.46	0.00	-0.93	18.48
: 53: 1228529	2014.01.08 13:15	buy	0.22	usdcad	1.08158	1.08158	1.08741	2014.01.09 21:00	1.08741	-0.93	0.00	-1.87	71.66
: 57: 1249728	2014.01.10 02:19	buy	0.11	usdcad	1.08526	1.08526	1.09123	2014.01.10 15:27	1.08852	-0.46	0.00	0.00	20.07
: 63: 1260803	2014.01.10 02:19	buy	0.22	usdcad	1.08526	1.08526	1.09123	2014.01.10 15:30	1.09123	-0.93	0.00	0.00	73.31
:113: 1401921	2014.01.17 03:00	buy	0.11	usdcad	1.09325	1.09325	1.09897	2014.01.17 15:05	1.09627	-0.46	0.00	0.00	18.43
:119: 1412907	2014.01.17 03:00	buy	0.22	usdcad	1.09325	1.09325	1.09897	2014.01.17 16:56	1.09491	-0.93	0.00	0.00	20.28
:127: 1419143	2014.01.17 18:31	buy	0.33	usdcad	1.09579	1.09275	1.10175	2014.01.20 07:54	1.09586	-1.39	0.00	-0.92	1.29
:133: 1431189	2014.01.20 11:15	buy	0.11	usdcad	1.09524	1.09524	1.10122	2014.01.21 10:07	1.09823	-0.46	0.00	-0.31	18.25
:139: 1449272	2014.01.20 11:15	buy	0.22	usdcad	1.09524	1.09524	1.10122	2014.01.21 11:52	1.10122	-0.93	0.00	-0.62	72.75
Found 13 matches for "usdcad".
It appears that the dominant swing direction is being correctly calculated from the zig-zag values.

However, I have noticed that some trades are entered too early after a pull back and sometimes hit a stoploss. So would these trades benefit from CSS or are they already entered in the prevaling CSS direction?

So next I looked at the worst pair: GBPUSD

Code: Select all

untitled:7: 1090068	2014.01.06 19:45	  buy	0.33	gbpusd	1.64060	1.63745	1.64645	2014.01.07 17:08	1.63745	-1.39	0.00	0.06	-63.48
untitled:31: 1191137	2014.01.08 12:45	  buy	0.11	gbpusd	1.64166	1.64166	1.64762	2014.01.08 16:09	1.64476	-0.46	0.00	0.00	20.73
untitled:37: 1198406	2014.01.08 12:45  buy	0.22	gbpusd	1.64166	1.64166	1.64762	2014.01.09 09:58	1.64762	-0.93	0.00	0.12	79.58
untitled:49: 1226902	2014.01.09 11:15	  buy	0.33	gbpusd	1.64598	1.64279	1.65179	2014.01.10 11:30	1.64279	-1.39	0.00	0.06	-64.08
untitled:125: 1418319	2014.01.17 18:15	  buy	0.33	gbpusd	1.64425	1.64116	1.65016	2014.01.17 19:51	1.64116	-1.39	0.00	0.00	-62.13
untitled:137: 1432809	2014.01.20 14:15 buy	0.33	gbpusd	1.64375	1.64075	1.64975	2014.01.21 10:05	1.64075	-1.39	0.00	0.06	-60.34
Found 6 matches for "gbpusd".
All are BUY trades, 4 were losers but why?

Does this snapshot of currency slope strength tables answer the question and if so would it be consistently true?
All times are UTC Page 6 of 28