The Perceptron is the simplest neural network, here is the code for the single layer version.
To put it simply, here I use a RSI 14 periods smoothed over 5 periods for example, but one could transmit any kind of data to it. By summing the value of the indicator at the instants y1, y2, y3 and y4 and weighted by a different factor for each of these iterations, we obtain an overall weight of the value which must then be interpreted naturally (see attached illustration).
In this version I left the value “raw”, in general one tries to obtain a boolean value by activating the true or false of this value with respect to levels of activation to be defined. In the case of this example on the RSI, this could be “on purchase if perceptron> 70 and on sale if perceptron <30 ..).
The values of the parameters x1 to x4 and y1 to y4 are to be modified at convenience and why not to optimize in Walk Forward mode in the ProBacktest strategy tester.
This code is an example of how the Perceptron is functioning and should be adapted with data arrays of any kind (indicators, prices, …). This leaves a wide area of exploration for those who want to try neural network. Good luck!
//PRC_Perceptron | indicator
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings ---
//weight in % for each neuron
//indicator previous period
// --- end of settings ---
//indicator to be used by the neural network
indi = average(rsi)
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :