### Harmony Search Algorithm

Posted:

**Tue Jan 18, 2011 12:10 pm**In the Feature Requests forum, Bobsyd recntly requested some intelligence on the part of TBB in optimizing system parameters. This got me researching search algorithms.

I have successfully implemented a genetic search algorithm called the Hamony Search Algorithm in TBB. I would like to share it with the community, but it is not a simple matter of downloading a blox adding it and away you go! Only users with TBB could implement it as modification of the blox is required. It also requires a fair amount of effort and de-bugging. I have used it on three systems. The example here is a simple system and took over an hour to configure, so I am not sure how much interest there would be - hence this introductory post.

I have worked up step-by-step instructions - 6 pages including example code using the algorithm with the ATR Channel Breakout system. I would need to upload the HS Blox itself plus the instructions plus the example system (made up of a PM, MM, 1 Entry/Exit, 1 Exit blox plus the Harmony Search Auxiliary blox). I would think this is enough for some determined persons to emulate the method for their own systems. Can I upload an entire system, or do I have to upload it in bits for you to assemble? Maybe I should zip it all together into 1 file.

To see the benefits of using such a methodology, consider the chart of a 5000 cycle search using MAR as the objective function shown below.

This search space involved 6 parameters: atrDays (1 - 100 x units of 1), closeAverageDays (1 - 600 x units of 1), entryThreshold and exitThreshold (0 - 5 continuous values), riskPerTrade (0.1% - 2% continuous), tradeDirection (0, 1, 2). If I were to try to step search simultaneously, this amounts to 100 x 600 x inf x inf x inf x 3 = a lot. More reasonably let's call it 20 x 24 x 20 x 20 x 20 x 3 = 11.52 x 10^6 combinations = a bit less than a lot but still too many to do on my machine! I think the search algorithm does a pretty good job in 5000 tests.

I wrote a couple of detailed blogs on the subject. My first was a general introduction to the topic. The second was more about the mechanics. Let me know if there is interest in this and how best to share the work.

I have successfully implemented a genetic search algorithm called the Hamony Search Algorithm in TBB. I would like to share it with the community, but it is not a simple matter of downloading a blox adding it and away you go! Only users with TBB could implement it as modification of the blox is required. It also requires a fair amount of effort and de-bugging. I have used it on three systems. The example here is a simple system and took over an hour to configure, so I am not sure how much interest there would be - hence this introductory post.

I have worked up step-by-step instructions - 6 pages including example code using the algorithm with the ATR Channel Breakout system. I would need to upload the HS Blox itself plus the instructions plus the example system (made up of a PM, MM, 1 Entry/Exit, 1 Exit blox plus the Harmony Search Auxiliary blox). I would think this is enough for some determined persons to emulate the method for their own systems. Can I upload an entire system, or do I have to upload it in bits for you to assemble? Maybe I should zip it all together into 1 file.

To see the benefits of using such a methodology, consider the chart of a 5000 cycle search using MAR as the objective function shown below.

This search space involved 6 parameters: atrDays (1 - 100 x units of 1), closeAverageDays (1 - 600 x units of 1), entryThreshold and exitThreshold (0 - 5 continuous values), riskPerTrade (0.1% - 2% continuous), tradeDirection (0, 1, 2). If I were to try to step search simultaneously, this amounts to 100 x 600 x inf x inf x inf x 3 = a lot. More reasonably let's call it 20 x 24 x 20 x 20 x 20 x 3 = 11.52 x 10^6 combinations = a bit less than a lot but still too many to do on my machine! I think the search algorithm does a pretty good job in 5000 tests.

I wrote a couple of detailed blogs on the subject. My first was a general introduction to the topic. The second was more about the mechanics. Let me know if there is interest in this and how best to share the work.