| 1 | //+------------------------------------------------------------------+ |
| 2 | //| MQL4 Trend Following EA | MetaTech Engine | |
| 3 | //+------------------------------------------------------------------+ |
| 4 | #property copyright "MetaTech 2026" |
| 5 | input double Lots = 0.1; // 交易手数 |
| 6 | input int MA_Period = 20; // 均线周期 |
| 7 | input int SL = 30; // 止损点数 |
| 8 | input int TP = 60; // 止盈点数 |
| 9 | |
| 10 | //| Expert tick function | |
| 11 | void OnTick() { |
| 12 | double ma = iMA(_Symbol,_Period,MA_Period,0,0,0,0); |
| 13 | if(Close[0] > ma && !OrderExists("BUY")) |
| 14 | OpenOrder("BUY", Lots, SL, TP); |
| 15 | if(Close[0] < ma && !OrderExists("SELL")) |
| 16 | OpenOrder("SELL", Lots, SL, TP); |
| 17 | TrailingStop(15); // 移动止损 |
| 18 | } |
| 19 | |
| 20 | //-- COMPILATION: SUCCESS ERRORS: 0 WARNINGS: 0 ✓ |