Stock market prediction using Neural Networks.
2 次查看(过去 30 天)
显示 更早的评论
I'm using a neural network under supervised learning mode and I aim to predict the Buy, Sell or Hold Signals for future values.
The inputs to the output function are Positive Directional Index, Negative Directional Index and Average Directional Index defined here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:average_directional_index_adx
The output function is as follows:
function Y=test_decision(DIP, DIN, ADI)
if (DIP>DIN)&&(ADI>25)%+ve DI greater than -ve DI and ADX>25
buy=(abs(DIP-DIN))/ADI;
ratio=DIP/DIN;
if(ratio>=1)
ratio=1/ratio;
end
sell=(1-buy)*ratio;
hold=1-buy-sell;
Y=[buy sell hold];
elseif (DIN>DIP)&&(ADI>25)%-ve DI greater than +ve DI and ADX>25
sell=(abs(DIP-DIN))/ADI;
ratio=DIP/DIN;
if(ratio>=1)
ratio=1/ratio;
end
buy=(1-sell)*ratio;
hold=1-sell-buy;
Y=[buy sell hold];
else
ratio=(abs(DIP-DIN)/ADI);
if ratio>1
ratio=1/ratio;
end
hold=1-ratio;
ratio1=DIP/DIN;
if ratio1>1
ratio1=1/ratio1;
buy=(1-hold)*ratio1;
sell=1-hold-buy;
else
sell=(1-hold)*ratio1;
buy=1-hold-sell;
end
Y=[buy sell hold];
end
Now, the output of this function is a nx3 array, where n is the number of input data and 3 values in each data element, which are (DIP, DIN, ADI)- Positive Directional Index, Negative Directional Index and Average Directional Index, respectively.
I'm using the following code to define and train the neural network:
for loop=1:n
y(loop,:)=test_decision(DI_P(loop), DI_N(loop), ADX(loop));
end
P=[DI_P DI_N ADX];
T=y;
net=newff(P,T, [10 10], {'tansig', 'purelin'},'trainlm', 'learngdm');
net.trainParam.show = 10; %showing results after every 10 iterations
net.trainParam.lr = 0.01; %learning rate
net.trainParam.epochs = 50; %no. of iterations
net.trainParam.goal = 0.0001; % percentage error goal
net1 = train(net, P, T);%training the network
Am I training using the right values? Am I using the right parameters for prediction of stock market decision? If yes, I need to plot the output values and the predicted values and find out the mean square error.
0 个评论
采纳的回答
Greg Heath
2013-4-23
Why don't you use all of the defaults you can?
You have specified two hidden layers. One is sufficient.
You have not specified enough transfer functions for 2 hidden and 1 output layer.
You have not included the VERY IMPORTANT training history structure, tr:
[ net1 tr Y E ] = train(net, P, T);% output Y, error E = T-Y
tr = tr % Will reveal more than you want to know.
Hope this helps.
Thank you for formally accepting my answer
Greg
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!