此资源为星钻会员专享,每日更新,收录于《大白EA宝库:星钻会员专属合集》。
这是一个均线金叉/死叉进场的示例 EA,教学用源码。本帖文件为 MT4 源码,打包成 zip 下载,解压后在 MetaEditor 里编译使用,参数与文件开头见下方源码预览。
源码预览(先看代码,再决定下不下)
本帖是源码 EA:Using_Moving_Averages_with_an_EA_Sample_Source_Code.mq4,全文共 173 行。下面是它的全部可调参数与文件开头,完整源码在上方下载区,星钻会员可见。
可调参数(5 个)
int FasterMA = 21;(Medium Moving Average period)int MediumMA = 84;(Slow Moving Average period)int Spread = 20;(Alow max spread in points)double Lots = 0.01;(Fixed Lots)int Stoploss = 60;(Stop loss in points)
//+------------------------------------------------------------------+
//| Moving Average.mq4 |
//| Copyright 2023, MetaQuotes Ltd. |
//| https://www.b123.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, Los Group"
#property link "https://www.b123.com/"
#property version "1.00"
#property strict
input int FasterMA = 21; // Medium Moving Average period
input int MediumMA = 84; // Slow Moving Average period
input int Spread = 20; // Alow max spread in points
input double Lots = 0.01; // Fixed Lots
input int Stoploss = 60; // Stop loss in points
int MAShift = 0;
int MAMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma
double Lotsize=0.01;
datetime prevtime;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit() {
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
}
//+------------------------------------------------------------------+
//| Expert tick function |
风险提示:EA 交易有风险,过往与参数表现不代表未来。正式使用前先在模拟盘跑够样本,确认在自己的点差、滑点环境下仍符合预期,再决定是否上实盘。
版本说明:资源随 MT4/MT5 版本迭代可能失效,如遇失效请在本帖留言反馈。

