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:ny(loop,:)=test_decision(DI_P(loop), DI_N(loop), ADX(loop)); endP=[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.
Best Answer