MetaTrader5
AK-47 Scalper EA:MetaTrader 5的高效交易助手
大家好,今天来聊聊一款非常实用的交易助手——AK-47 Scalper EA,它专为MetaTrader 5平台设计,能够帮助我们有效捕捉市场机会。 1. 输入参数 #define ExtBotName "AK-47 EA" // 机器人名称
#define Version "1.00"
// 导入输入类
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
//--- 定义预设变量以便于代码可读性
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)
#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
//--- 输入参数
input string EASettings = "---------------------------------------------"; //-------- <EA设置> --------
input int InpMagicNumber = 124656; //魔术数字
input string MoneySettings = "---------------------------------------------"; //-------- <资金设置> --------
input bool isVolume_Percent = true; //允许按比例计算交易量
input double InpRisk = 3; //风险百分比
input string TradingSettings = "---------------------------------------------"; //-------- <交易设置> --------
input double Inpuser_lot = 0.01; //交易手数
input double InpSL_Pips = 3.5 //止损(点数)
input double InpTP_Pips = 7 //止盈(点数)(0 = 无止盈)
input int InpMax_slippage = 3 //最大允许滑点
input double InpMax_spread = 5 //最大允许点差(0 = 浮动点差)
input string TimeSettings = "---------------------------------------------"; //-------- <交易时间设置> --------
input bool InpTimeFilter = true; //时间过滤器
input int InpStartHour = 2; //开始小时
input int InpStartMinute = 30 //开始分钟
input int InpEndHour = 21 //结束小时
input int InpEndMinute = 0 //结束分钟 2. 本地变量初始化 //--- 变量
int Pips2Points; // 滑点 3点
double Pips2Double; // 止损 15点
bool isOrder = false;
int slippage;
long acSpread;
string strComment = "";
CPositionInfo m_position; // 交易位置对象
CTrade m_trade; // 交易对象
CSymbolInfo m_symbol; // 货币对信息对象
CAccountInfo m_account; // 账户信息包装类
COrderInfo m_order; // 挂单对象 3. 主代码 a/ 专家初始化函数 //+------------------------------------------------------------------+
//| 专家初始化函数 |
//+------------------------------------------------------------------+
int OnInit() {
// 检测3位或5位小数
// 点和点数
if(_Digits % 2 == 1) {
Pips2Double = _Point*10;
Pips2Points =
2023.06.12