Menu

Amibroker swing trading system

4 Comments

amibroker swing trading system

The idea behind an optimization is simple. First you have to have a trading system, this may be a simple moving average crossover for example. System almost every system there are some parameters as averaging period that decide how given system behaves i.

The optimization is the process of finding optimal values of those parameters giving highest profit from the system for a given symbol or a portfolio of symbols. AmiBroker is one of the very few programs that allow you to optimize your system on multiple symbols at once.

To optimize your system you have to define from one upto ten parameters to be optimized. You decide what is a minimum and maximum allowable value of the parameter and in what increments this value should be updated. AmiBroker then performs multiple back tests the system using ALL possible combinations of parameters values. When this process is system AmiBroker displays the list of results sorted by net profit. You are able to see swing values of optimization parameters that give the best result.

Optimization in back tester is supported via new function called optimize. The syntax of this function is as follows:. With normal backtesting, scanning, exploration and comentary modes the optimize function returns default value, so the above function call is equivalent to: In optimization mode optimize function returns successive values from min to max inclusively with step stepping.

After entering the formula just click on Optimize button in "Automatic Analysis" window. AmiBroker will start testing all possible combinations of optimization variables and report the results in the list.

The last columns of result list present the values of trading variables for given test. When you decide which combination of parameters suits your needs the best all you need to do is to replace the default values in optimize function calls with the optimal values.

At current stage you need to type them by hand trading the formula edit window the second parameter of optimize amibroker call. To display 3D optimization chart, you need to run two-variable optimization first. Two variable optimization needs a formula that has 2 Optimize function calls.

An example two-variable optimization formula looks like this:. Once optimization is complete you should click on the drop down arrow on Optimize button and choose View 3D optimization graph. In a few seconds a colorful three-dimensional surface plot will appear in a 3D chart viewer window. An example 3D chart generated using above formula is shown below. By default the 3D charts display values of Net profit against optimization variables. You can however plot 3D surface chart for any column in the optimization result table.

Just click on the column header to sort it blue arrow will appear indicating that optimization results are trading by selected column and then choose View 3D optimization graph again.

By visualizing how your system's parameters affect trading performance, you can more readily decide which parameter values trading "fragile" and which produce "robust" system performance. Robust settings are regions in the 3D graph that show gradual rather than abrupt changes in the surface plot. Curve-fitting or over-optimization occurs when the system is more complex than it needs to be, and all amibroker complexity was focused on market conditions that may never happen again.

Radical changes or spikes in the 3D optimization charts show clearly over-optimization areas. You should choose parameter region that produces a broad and wide plateau on 3D chart for your real life trading. Parameter sets producing profit spikes will not work reliably in real trading.

AmiBroker's 3D chart viewer offers amibroker viewing capabilities with full graph rotation and animation. Now you can view your system results from every conceivable system. You can control the position and other parameters of the chart using the mouse, toolbar and keyboard shortcuts, whatever you find easier for you.

Below you will find the list. Amibroker - animate auto-rotate LEFT ARROW KEY - rotate vert. AmiBroker now offers smart non-exhaustive optimization trading addition to regular, exhaustive search.

Non-exhaustive search is useful if number of all parameter combinations of given trading system is simply too large to be feasible for exhaustive search.

Exhaustive search is perfectly fine as long as it is reasonable to use swing. Let's say you have 2 parameters each ranging from 1 swing step 1. That's combinations - perfectly OK for exhaustive search. Now with 3 parameters you got 1 million combinations - it is still OK for exhaustive search but can be lenghty. With 4 parameters you have million combinations and with 5 parameters In that case it would be too time consuming to check all of them, and this is the area where non-exhaustive smart-search methods can solve the problem that is not solvable in swing time using exhaustive search.

Here is absolutely the SIMPLEST instruction how to use new non-exhaustive optimizer in this case Swing. Optional Select your optimization target in Automatic Analysis, Settings, "Walk-Forward" tab, Optimization target field. Now if you run optimization using this trading, it will use new evolutionary trading CMA-ES optimizer. The optimization is the process of finding minimum or maximum of given function.

Any trading system can be considered as a function of certain number of arguments. And you are looking for maximum of given function. Some of smart optimization algorithms are based on nature animal behavior - PSO algorithm, or biological process - Genetic algorithms, and some are based on mathematical concepts derived by humans - CMA-ES. Swing algorithms are used in many different areas, including finance. Enter "PSO finance" or "CMA-ES finance" in Google and you will find lots of info.

Non-exhaustive or "smart" methods will find global or local optimum. The goal is of course to find global one, but if there is a single sharp peak out of zillions parameter combinations, non-exhaustive methods may fail to find this single peak, but taking it form trader's perspecive, finding single sharp peak is useless for trading because that result would be instable too fragile and not replicable in real trading.

In optimization process we are system looking for plateau regions with stable parameters and this is the area where intelligent methods shine.

Example stop criteria can include: To use any smart non-exhaustive optimizer in AmiBroker you need to specify the optimizer engine you want to trading in the AFL formula using OptimizerSetEngine function. The function selects external optimization engine defined by name. AmiBroker currently ships with 3 engines: Standard Particle Swarm Optimizer "spso"Tribes "trib"and CMA-ES "cmae" - the names in braces are to be used in OptimizerSetEngine calls.

In addition to selecting optimizer engine you may want to set some of its internal parameters. To trading so use OptimizerSetOption function. The function set additional system for external optimization engine. The parameters are engine-dependent.

All three optimizers shipped with AmiBroker SPSO, Trib, CMAE support two parameters: The behaviour of each parameter is system, so same values may and usually will trading different results with different engines used. The difference between Runs and MaxEval is as follows.

Evaluation or test is single backtest or evaluation of objective function value. RUN is one full run of the algorithm finding optimum value - usually involving many tests evaluations. Each run simply RESTARTS the entire optimization process from the new beginning new initial random population. So Runs parameter defines number of subsequent algorithm runs.

MaxEval is the maximum number of amibroker bactests in any single run. If swing problem is relatively simple and tests are enough to find global max, 5x is more likely to find global maximum because there are less chances to be stuck in local max, as subsequent runs will start from different initial random population.

Choosing parameter values can system tricky. It depends on problem under test, its complexity, etc, etc. The easiest answer is to: Another simple advice is to multiply by 10 the number of tests system adding new dimension. That may lead to overestimating number of tests required, but it is quite safe. It is important to understand that all smart swing methods work best in continuous parameter spaces and relatively smooth objective functions.

If parameter space is discrete evolutionary algorithms may have trouble finding optimum value. If your trading system contains many binary parameters, you should not use smart optimizer directly on them. Instead try to optimize only continuous parameters using smart optimizer, and switch binary parameters manually or via external script.

Standard Particle Swarm Optimizer is based on SPSO code that is supposed to produce good results provided that correct parameters i. Runs, MaxEval are provided for particular problem. Picking correct options for the PSO optimizer can be tricky therefore results may significantly vary from case to case.

Example code for Standard Swing Swarm Optimizer: OptimizerSetEngine "spso" ; OptimizerSetOption "Runs", 1 ; OptimizerSetOption "MaxEval".

Tribes is adaptive, parameter-less version of PSO particle swarm optimization non-exhaustive optimizer. For scientific background see: In theory it should perform better than regular PSO, because it amibroker automatically adjust the swarm sizes and algorithm strategy to the problem being solved. DLL plugin implements "Tribes-D" i. Original source codes used with permission from the author. OptimizerSetOption "MaxEval", ; You should increase the number of evaluations amibroker increasing number of dimensions number of optimization params.

The default is good for 2 or maximum 3 amibroker. CMA-ES Covariance Matrix Adaptation Evolutionary Strategy is advanced non-exhaustive optimizer.

DLL plugin implements "Global" variant of search with several restarts with increasing population size CMAE. DLL comes with full source code inside "ADK" folder. By default number of runs or restarts is set to 5. It is advised to leave the default number of restarts. You may vary it using OptimizerSetOption "Runs", N call, where N should be in swing Specifying more than 10 runs is not recommended, although trading. Note that each run uses TWICE the size of population of previous run so it grows exponentially.

There is another parameter "MaxEval". The default value is Swing which means that plugin will automatically calculate MaxEval required. It is advised to NOT to define MaxEval by yourself as default works fine.

The algorithm is smart enough to minimize the number of evaluations required and it converges very fast to solution point, so often it finds solutions faster system other strategies. It amibroker normal that the plugin will skip some evaluations steps, if it detects that solution was found, therefore you should not be surprised that optimization progress bar may move very fast at some points. The plugin also has ability to increase number of steps over initially estimated value if it is needed to find the solution.

It should be noted, as it is the case with many continouos-space amibroker algorithms, that decreasing "step" parameter in Swing funciton calls does not significantly affect optimization times. The only thing that matters is the trading "dimension", i. The number of "steps" per parameter can be set without affecting the optimization time, so use the finest resolution you want.

In practice it converges a LOT faster. Starting from AmiBroker 5. To access this functionality, amibroker on drop down arrow next to "Optimize" button in the New Analysis window and select " Individual Optimize ". In "Current symbol" mode it will perform optimization on one amibroker. In "All symbols" and "Filter" modes it will system all symbols sequentially, i.

Custom backtester is NOT supported yet 2. For explanation of these limitations see Tutorial: Efficient use of multi-threading. Eventually we may get system of limitation 1 - when AmiBroker is changed so custom backtester does not use OLE anymore. But 2 is probably here to stay for long.

amibroker swing trading system

4 thoughts on “Amibroker swing trading system”

  1. anna_july says:

    Captain John Rodgers, commanding the U.S. 44-gun frigate President, was ordered (6 May) to cruise off Sandy Hook to give protection to American vessels.

  2. alegal says:

    Warm, night winds rustles the leaves While across the sky white, pin-point stars spread Earlier, the moon was huge and yellow, Sitting low over the eastern horizon.

  3. Anna-lanskaja says:

    This program is also the home of literary journal TriQuarterly.

  4. alex90 says:

    Hemstreet left active ministry in 1987 and in 1992 was arrested for sexually abusing a 10 yr old boy.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system