NAME

Amibroker::AFL::Optimizer - Auto Optimizer framework for ALL Stocks across ALL timeframe in Amibroker.

VERSION

Version 0.01

SYNOPSIS

    use Amibroker::AFL::Optimizer;

    my $obj = Amibroker::AFL::Optimizer->new( {
								dbpath => 'C:/amibroker/dbpath',
								destination_path => 'C:/finalreports/today',
								timeframe => '5-minute',
								optimizer_name => 'EMA',
								afl_template=> 'C:/amibroker/formulas/custom/myema.afl',
								symbol => 'NIFTY-I',
								lot_size => '50',
	});
    $obj->start_optimizer();

new() [constructor]

Minimum 7 mandatory parameters are required for the amibroker optimizer to run.

    my $obj = Amibroker::AFL::Optimizer->new( {
							dbpath => 'amibroker_database_path',
							destination_path => 'final_path_where_afls_will_be_dumped',
							timeframe => 'timeframe',
							optimizer_name => 'Name_for_this_optimization',
							afl_template=> 'afl_template_file_that_requires_optimization',
							symbol => 'symbol',
							lot_size => 'symbol_lot_size',
						});

Required Parameters

dbpath
Amibroker database path
destination_path
Amibroker destination_path is where finally the optimized afls are dumped.
timeframe

You have to specifiy to which timeframe do you want to run the optimizer Default available timeframe with Amibroker. yearly quarterly monthly weekly daily day/night hourly 15-minute 5-minute 1-minute 3-minute 7-minute 10-minute 12-minute 20-minute ALL

ALL - Timeframe is supported, this will optimize the afl for all the above given timeframes
symbol

Accepts any symbols name as present in your amibroker database. CAUTION: Symbol names should exactly match the symbols present in your amibroker database, else this optimization will fail.

afl_template

AFL template file that needs auto optimization, you have give the complete path to that afl_template file.

lot_size

Lot size for that symbol

Optional Parameters

log_path

Path to the logs. If this parameter is not specified, then no logs will be stored. The logs will contain all the results of the amibroker run and the apx file that was sent to the engine, so it helps in verifying the parameters that were passed to the amibroker engine and the output results.

optimizer_name

You can give any name, but it should be relevant to the optimize that you are running. Eg: If you are running for ATR then give the name as optimizer_name => 'ATR' Similarly for EMA, BollingerBands ..etc, it is just user-defined variable, which helps in identifying the optimization run All the AFL files generated will have this optimizer_name appended to your AFL file name, so this helps in easy identification.

min_win_percent

Provide the minimum winning percentage you are expecting from the afl template optimization. Default will be 40%

min_profit_percent

Provide the minimum profit percentage you are expecting from the afl template optimization. Default will be 50%

min_no_of_trades

Provide the minimum number of trades you are expecting from the afl template optimization. Default will be 10

selection_index

The row that you want to pick up in the optimization result. As a normal practise, it is advised not to pick up trades that gives the maximum profit as it will result in curve-fitting. And the optimized values will not behave as expected in the optimized results. So, it is better to give a range from 5 to 15. Default will be 2

profit_from

when lotsize is multiplied with the price then we get the actual profit/loss. profit/loss is in currency. For ease, i will take INR (indian rupees), NOTE: It works for all currencies

During optimization process, we specifiy profit limits, so that our trades gets squared off when the profit limit is reached. Now, we do not know at what profit levels do we get the best profitable results. So, during optimization we want to create files that ranges for different profit levels, so that when we run backtest for that afl, we get to see the actual backtested results.

profit_from specifies the lowest profit limit Default will be 0

profit_to

profit_from specifies the highest profit limit Default will be 20000 (so the maximum profit per trade is 20000 INR in this case)

profit_incr

profit_incr specifies the increment value. Default will be 5000 So, AFL files will be created with trade profit targets for every 5000 INR.

optimize_time

If you want to optimize the AFL for different timeframe then give 'YES', else ignore it. Eg: If your strategy works between 2:00 PM to 3:00 PM, then use this parameter, It will tell you which is the best timeframe during which your afl gave maximum profits.

margin_amt

Margin amount as for that symbol as specified by broker/exchange.

from

From date

to

To date, either specify both from and to dates or none should be specified.

start_optimizer()

$obj->start_optimizer();

Starts the optimizer. It internally calls Amibroker::OLE::Interface to connect to Amibroker engine. Usually every run takes around 1 minute to 5 minute, depending on the size of your amibroker database.

AUTHOR

Babu Prasad HP, <bprasad@cpan.org>

BUGS

Please report any bugs or feature requests to bug-amibroker-afl-optimizer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Amibroker-AFL-Optimizer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Amibroker::AFL::Optimizer

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to Mr.Pannag for helping me in developing this module.

LICENSE AND COPYRIGHT

Copyright 2015 Babu Prasad HP.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.