フィルターのクリア

Stock market prediction using Neural Networks.

1 回表示 (過去 30 日間)
Vineet
Vineet 2013 年 4 月 23 日
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.

採用された回答

Greg Heath
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
  1 件のコメント
Vineet
Vineet 2013 年 4 月 24 日
I changed the code as follows: net=newff(P,T, [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
[net1 tr Y E]=train(net , P, T);
tr=tr;
% P0=get_test_data();
z=sim(net, P);
figure();
plot(z, 'r');
hold all
plot(Y);
d=(T-Y).^2;
mse=mean(d);
disp('MSE = ');
figure();
plot(mse);
disp(mse);
Now, plotting z and Y on a graph gives me a number of lines, but I want only two. That is, I want only TWO lines that plot the actual output and the neural network trained output. Please help. Btw, I didn't understand what 'tr' does. Kindly elaborate.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by