Amibroker Tutorial Video - Optimization In Amibroker With Non Continuous Optimization Steps

Adrian Reid shows how to optimize parameters in Amibroker using unequally spaced values instead of linear steps. In a breakout system, one input selects time-stop durations of 1, 5, 25, 50, and 100 days, revealing the entry works better over longer periods. Use semantically meaningful buckets rather than evenly spaced ranges across wide parameter spans.
Chapters
The next example I wanted to share about this Amy Broker technique that I use is to run an optimization in amibroker, but using non continuous values for the optimization. So let's say you've got a long term moving average and.
You want to run an optimization on that, but you don't want to test 200 days, 201 days, 202 days, 203 days. Instead you want to test 5, 10, 25, 50, 100, 500. See how they're non continuous values. Usually the optimization function forces you to have equally spaced steps. Now that's not always convenient because.
Going from a value of 10 bars for a moving average to 11 is a 10% increase, but going from a value of 200 bars to 201 bars is a half a percent increase. So sometimes, like if you're optimizing over a big range of values, it doesn't necessarily, well, often doesn't make sense to backtest or to optimize using a equally spaced set of parameters. Now there's a couple of different ways to do this, but because we just talked about the case switch function in a previous video, I'm going to show you how to do it with case switch. So let me just share my screen and I will show you how this one works.
So I'll zoom right in here and what I've got here is just a simple breakout system. It enters on a 200 day high and it's the first 200 day high for 200 days. So the previous 200 days have not been a high. Today is the highest close out of the last 200 days. And what I'm trying to do is test does this entry have an edge over different periods of time? So I'm using the case switch function and what I'm going to do is test the test a time stop that exits one day after the breakout, five days, 25 days, 50 days and 100 days after the breakout. Because I'm interested, I mean the reason for having a set of code like this is to say, okay, well does this entry have an edge over the short term, medium term and long term? It makes no sense to say does this have an edge over 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, all the way up to 100 days? You don't need to know all of that. I just want to know short, medium and long term. So I've got these unequal step sizes and so just like in the the case switch example that I did previously, what I've got is a switch function with A optimization input. And the optimization input is is this function, this parameter called Timestop Opt. I've just defined that. And it goes from one to five in steps of one, and it goes from one to five because I've got five different cases here. And case one is the one day, case two is the five day, case three is the 25 day, case four is the 50, and case five is 100 days. So when I run this back test or run this optimization, this parameter is going to be stepped from one to five and that's going to select a time stop value of 1, 5, 25, 50, 100 and then that time stop value is going to be placed into the apply stop function at the bottom. So that way we can test whether or not this has an entry edge over those different durations. So let's send it to the analysis window and let's run it and see what happens.
So I'll just run optimize.
Okay, so if we look.
Over on the far right, the step this, the step values were 1, 2, 3, 4, 5.
And those 1, 2, 3, 4,. Fives correspond to the values of this time stop opt. So it's case 1, 2, 3, 4, 5 that we're looking at here. And the net profit was negative for a value of one, which is not surprising because often after a breakout there's a little dip. And then for a value of what was it? 5, 25, 25, 50, 100. So you can see the breakout obviously has an edge over the longer term and not much of an edge over the very short term. Now, there's lots of different ways you could use this. I know it's a bit hard to read, I'll just take that off the screen for now. But the key thing is when you're doing optimization, you want to ask yourself, do I need to know every single value or am I really not sure should this be a small, medium or big number? And so therefore I want to have uneven step sizes. If you want to have uneven step sizes to investigate something, then this is a really good way to do it. Another example of where this might be handy is if you've got a mood, let's say you've got a moving average filter for trend in your system and you don't know if it should be a very short term moving average or a very, very long term moving average. You've just got no idea of how that should. That moving average should be set. Then don't optimize it. You know, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, because it's going to give you a whole bunch of information you don't need. Just go short, medium, long term, very long term, and use this uneven step size and you'll get the information you need and then you can zero in and optimize in a more precise way later on.
Sam.











