Simple Single Layer Perceptron EA - MetaTrader 4 Expert | MT4 EA Download - MetaTrader 4 Resources




About the Perceptron: Dr. Mark Humphrys Single Layer Neural Network (Perceptron)
I refer to " artificial intelligence " as the logic of perceptrons.
The w1 , w2 , w3 and w4 are weights that set values determined by your optimization.
Input integer x1 = 0 ; // Input integer for weight 1 x2 = 0 ; //Input integer for weight 2 x3 = 0 ; //Input integer for weight 3 x4 = 0 ; //For weight 42.2. Perceptron
For making simple EAs, the threshold is zero. And the output has not changed "Triggered" 1, "Not Triggered" 0.
Double w1 = x1 - 100 ;Double w2 = x2 - 100; Double w3 = x3 - 100 ; Double w4 = x4 - 100 ; //The perceptron before Yi Zhu 2017/03/18
Double a11 = (( RSI ( symbol (), 0 , 12 , PRICE_MEDIAN , 1 ))/ 100 - 0.5 )* 2 ;
Double a21 = (( RSI ( symbol (), 0 , 36 , PRICE_MEDIAN , 1 ))/ 100 - 0.5 )* 2 ; Double a31 = (( RSI ( symbol (), 0 , 108 , PRICE_MEDIAN , 1 ))/ 100 - 0.5 )* 2 ; Doubled a41 = (( RSI ( symbol (), 0 , Chapter 324 , PRICE_MEDIAN , 1 ))/ 100 - 0.5 )* 2 ; Doubled Current_Percptron = (w1 * a11 + w2 * a21 + w3 * a31 + w4 * a41); //Perceptron two bars before 2017/03/18
Double a12 = (( RSI ( symbol (), 0 , 12 , PRICE_MEDIAN , 2 ))/ 100 - 0.5 )* 2 ;
Doubled a22 = (( RSI ( symbol (), 0 , 36 , PRICE_MEDIAN , 2 ))/ 100 - 0.5 )* 2 ; Doubled a32 = (( RSI ( symbol (), 0 , 108 , PRICE_MEDIAN , 2 ))/ 100 - 0.5 )* 2 ; Doubled a42 = (( RSI ( symbol (), 0 , Chapter 324 , PRICE_MEDIAN , 2 ))/ 100 - 0.5 )* 2 ; Doubled Pre_Percptron = (w1 * a12 + w2 * a22 + w3 * a32 + w4 * a42);
I'm using RSI in this EA, but I think other oscillators will work too. RCI, W%R, etc.
2.3. Order opening and closing
When the previous perceptron is below 0 and the current perceptron is above 0, if there is a short position, it is closed.
The EA sends a long order.
if (Pre_Percptron < 0 && Current_Percptron > 0 ) // long signal { //If there is a short position, send a closing order if (position < 0 ) { Fallback = order close (ticket, order batch (), order closing price (), 0 ); if (return) position = 0 ; //If the position is closed successfully, the position status is zero } //If there is no position, send multiple orders if (position == 0 ) tickets = order sent ( _symbol , //symbol OP_buy , // operation a lot, // volume question , // price 0 , // slippage 0 , // stop loss 0 , // take profit trade_comment, // comment magic number, // magic number 0 , // pending order expiry green // color ); }On the contrary, when the current perceptron is below 0 and the previous perceptron is above 0, if there is a long position, the position will be closed.
The EA sent an empty order.
Load "Slime_Mold_RSI_template.set" and select "Only Opening Prices" for the model.
I set Magic Number as the duration for optimization and the EA uses Magic Number in the comments.
String Trading Comments = Integer to String (Magic Number, 5 , '' ) + "Number of Days Optimization" ;
https://qiita.com/Kei-Sanada/items/cd6b8d9c02bc9eea1e01
Attachment download
📎 slime_mold_rsi_template.set (0.32 KB)
📎slime_mold_rsi_v1.1.mq4 (10.09 KB)
Source: MQL5 #18987
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •