#property copyright "Julien Loutre" #property link "http://fann4mt.thetradingtheory.com" /* Please read the tutorial and documentation on the fann4mt website: http://fann4mt.thetradingtheory.com */ #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 LightBlue #property indicator_width1 1 #property indicator_maximum 100 #property indicator_minimum 0 #property indicator_level1 20 #property indicator_level2 80 #include double buffer[]; // display buffer double outputArray[][1]; string annFilename = "c:\\nn\\proto_RSI_RVI_STO.net"; int deinit() { nn_destroy_all(); } int init() { SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,buffer); SetIndexLabel(0,"Predicted values"); SetIndexShift(0,0); int i; nn_setDebugChannel("msg"); nn_debug("msg","","***************************************************"); // All our data, input and output, are going to be in the [0;100] range nn_set_dataRange(0,100); // try to load the ANN from a file, or create it if the file is not found // 3 inputs, 2 hidden layers of 12 and 8 neurons, and one output. int annID = nn_loadOrCreateNetwork(annFilename,3,12,8,1); // train only if the ANN has just been created. if (nn_isLoaded(annID) == 0) { // Creating the training set double trainingData[][4]; for (i=0;i<=1000;i++) { createData(trainingData,i,true); } nn_scaleDataRange(trainingData,4); // Scale the dataset from our data range ([0;100]) to the ANN working range ([0;1]) nn_set_max_MSE(0.005); nn_set_epoch(1000); nn_debug("msg","","Starting the training"); nn_train(annID, trainingData); } // Creating the test dataset (not including the desired output this time of course) double liveData[][3]; for (i=0;i<=600;i++) { createData(liveData,i,false); } nn_scaleDataRange(liveData,3); // scale the data on the [0;1] range nn_debug("msg","","Starting the test"); nn_computeScaledBatch(annID, liveData, outputArray); // Compute the dataset, and de-scale the output values back to our range [0;100] nn_saveNetwork(annID, annFilename); // Save the ANN to use for next time return(0); } int start() { int i; // display the computed results for (i=0;imax) max = tmpdiff; if (tmpdiff pips && max>0-min) { signal = 100; } if (min < 0-pips && max<0-min) { signal = 0; } cArray_push(buffer,signal); } cArray_commit(dataset,buffer); } double cap(double value, int min, int max) { if (value>max) value=max; if (valuetop) tmp=1; if (value