Você está na página 1de 3

Neural Networks for Amibroker (AFL)

1 of 3

Home

Forum

Contact Us

http://www.wisetradertoolbox.com/neural-networks.html

Release Log

Main Menu
Home
Neural Networks
Neural Network Wizard

Downloads

About Us

Buy Now!

Buy Neural Network Wizard Now! *Addon*

Neural Networks for Amibroker (AFL)


Written by Administrator

The WiseTrader toolbox adds advanced neural network predictive technology to the Amibroker
platform. Coupled with Amibroker's powerful formula language you can now create intelligent
trading systems powered by advanced neural networks.

Adaptive Indicators 1
Adaptive Indicators 2
Trendline Scanner
MAMA
Instant Trendline
Automatic Support Indicator
Hilbert Oscillator
Sine Wave

The WiseTrader toolbox adds two different kinds of neural networks to the Amibroker platform: 1.
The traditional neural networks that are trained on a fixed number of bars 2. The adaptive
walk-forward version which retrains on each new bar. The WiseTrader toolbox also comes with two
different learning algorithms: standard momentum back-propagation and a more advanced adaptive
quick-propagation learning algorithm with faster convergence. The neural networks are accessible
via some simple AFL function calls and come with complete documentation to get you started.
With the WiseTrader toolbox you can easily turn lagging indicators into smooth leading indicators.
Download the following example of a leading RSI indicator created with the toolbox and try it out for
yourself:

Cyber Cycle

Dowload 1 or Dowload 2

Double Top & Bottom Pattern


Finder

Adaptive Walk-Forward Neural Networks

Triangle Pattern Scanner

The following AFL demonstrates how the adaptive neural networks can be used to predict the
closing price of a stock one bar ahead. Note that this is a simple example meant only to

System Rotation

demonstrate how the adaptive neural networks work. A better prediction would use other market

Fibonacci Retracement Finder

indices and maybe economic data to get a more accurate prediction.

Head and Shoulders Pattern Finder

//Use all bars

Polynomial Interpolation
Adaptive Goertzel N-Cycle

SetBarsRequired(99999, 99999);
//Use the adaptive learning algorithm
SetLearningAlgorithm(1);

End Point FFT


//Set our inputs
i1 = C;
i2 = Ref(C, -1);
i3 = Ref(C, -2);
i4 = Ref(C, -3);
i5 = Ref(C, -4);
i6 = Ref(C, -5);
i7 = Ref(C, -6);
i8 = Ref(C, -7);
//Set our desired output (One bar into the future)
O1 = Ref(C, 1);
//Train and compute an adaptive neural network
res = NeuralNetworkIndicator9(i1, i2, i3, i4, i5, i6, i7, i8, O1,
FullName(), 100, 1);
Plot(res, _DEFAULT_NAME(), colorRed, styleLine);
//Calculate accuracy for the recent 100 bars
Title = "Accuracy: " + (Sum(IIf((Ref(C, 1) > C) == (res > Ref(res, -1)), 1,
0), 100));
//Clean up
EnableProgress();
RestoreDefaults();
ClearNeuralNetworkInputs();
When the above formula begins training you should see the following progress dialog box to tell you
the progress of the computation:

12/16/2015 2:38 PM

Neural Networks for Amibroker (AFL)

2 of 3

http://www.wisetradertoolbox.com/neural-networks.html

You can stop and resume training at any moment because all adaptive neural network calculations
are stored in the plugin's internal memory and only compute as much as is needed so it can be used
in your real-time trading as the neural network will only train and predict on the latest bar.
General Neural Networks
The other neural network functions allow you to train a neural network and save it to a file to run
later or even generate AFL code directly. The ability to convert a trained neural network to AFL code
is the first of its kind not available anywhere else. The next formula is a simple example of creating
a trend detection indicator using neural networks.
//Use all available data for training
SetBarsRequired(99999, 99999);
//Set the seed value of the neural network
//The same seed value will produce the same neural network each time
SetSeed(20);
//Use the adaptive learning algorithm
SetLearningAlgorithm(1);
//Train the neural network for 2000 iterations
SetMaximumEpochs(2000);
//Set the number of hidden layers in the neural network
SetNetworkLayer2(20, 20);
//Trend detection (looks into the future). This is what we want to predict.
//You can set whatever you desire here. Anything you can imagine you can
use here
//because the trained neural network won't look into the future.
Out1 = Ref(Zig(C, 10), -1) < Zig(C, 10);
//Add the inputs for the neural network. Using this method you can add
//as many neural network inputs as you want
for(i = 5; i < 20; i++)
{
AddNeuralNetworkInput(VariablePeriodRSI(C, i));
AddNeuralNetworkInput(VariablePeriodRSI(Ref(C, -1), i));
AddNeuralNetworkInput(VariablePeriodRSI(Ref(C, -2), i));
}
//Last input added is our desired output or the trend
AddNeuralNetworkInput(Out1);
//Delete neural network if there is already another
fdelete("WiseTraderToolbox\\NeuralNetwork\\Trend_Detection");
//Begin training the neural network
TrainMultiInputNeuralNetwork("Trend_Detection");
//Clean up the added inputs and restore default values
EnableProgress();
RestoreDefaults();
ClearNeuralNetworkInputs();

12/16/2015 2:38 PM

Neural Networks for Amibroker (AFL)

3 of 3

http://www.wisetradertoolbox.com/neural-networks.html

When you run the above formula you should see a training progress dialog box. When the above
formula finishes executing you can use the generated AFL version of the indicator to run the neural
network or just run the neural network from file. The next example will execute the neural network
from file because the generated formula is too big to post here.
//Add the neural network inputs
for(i = 5; i < 20; i++)
{
AddNeuralNetworkInput(VariablePeriodRSI(C, i));
AddNeuralNetworkInput(VariablePeriodRSI(Ref(C, -1), i));
AddNeuralNetworkInput(VariablePeriodRSI(Ref(C, -2), i));
}
//Run the neural network from file
res = RunMultiInputNeuralNetwork("Trend_Detection");
//Plot the neural network result.
Plot(res, _DEFAULT_NAME(), colorRed, styleLine);
Conclusion
The above are very simple examples of how the neural networks can be used. With the Amibroker
platform and WiseTrader toolbox almost everything other neural network platforms can do can be
done and more. For example, it is simple to use the optimizer to grow neural networks and find the
best performing architecture. You can also try and create zero lag indicators by shifting them
forward and trying to predict the result.

Copyright 2015 WiseTrader Toolbox. All Rights Reserved.


Joomla! is Free Software released under the GNU/GPL License.
Contact Us
Privacy Policy
Disclaimer
Order Terms and Conditions
Joomla Templates By Joomladesigns.co.uk

12/16/2015 2:38 PM