求一个能用无限制的MT5马丁
求一个能用无限制的MT5马丁,或者有图中的这个也可以,如果是源码可以加钱我有这个 默认参数 跑两位数平台 随便跑 这个月没爆过 200点一下无压力 100本金起泡 //+------------------------------------------------------------------+
//| MartinBollingerEA.mq4 |
//| Copyright 2025, Your Name |
//| https://www.yourwebsite.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Your Name"
#property link "https://www.yourwebsite.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| 输入参数(与截图一一对应) |
//+------------------------------------------------------------------+
input int 魔术号 = 2020888; // 魔术号
input string 开仓方向 = "布林开仓"; // 开仓方向(这里实现布林开仓)
input double 起始手数 = 0.01; // 起始手数
input double 加仓倍数 = 1.667; // 加仓倍数
input double 最大加仓手数 = 50.0; // 最大加仓手数
input double 加仓间隔1 = 30.0; // 加仓间隔1(点)
input int 加仓层数1 = 5; // 加仓层数1
input double 加仓间隔2 = 60.0; // 加仓间隔2(点)
input int 加仓层数2 = 10; // 加仓层数2
input double 加仓间隔3 = 100.0; // 加仓间隔3(点)
input int 最大持仓单数量 = 100; // 最大持仓单数量
input double 综合止盈点数 = 100.0; // 综合止盈点数
input double 第五单后止盈金额 = 3.0; // 第五单后止盈金额(美元)
input bool 是否启用亏损平仓 = false; // 是否启用亏损平仓
input double 亏损平仓百分比 = 20.0; // 亏损平仓百分比
input bool 是否启用时间平仓 = false; // 是否启用时间平仓
input int 持仓小时数 = 48; // 持仓小时数
input bool 是否启用移动止损 = false; // 是否启用移动止损
input double 移动止损启动点数 = 100.0; // 移动止损启动点数
input double 移动止损点数 = 100.0; // 移动止损点数
input double 一分钟不开仓点数 = 200.0; // 一分钟不开仓点数
// STOCH参数
input int STOCHK周期 = 5; // STOCH K周期
input int STOCHD周期 = 3; // STOCH D周期
input int STOCH慢速 = 3; // STOCH慢速
input ENUM_APPLIED_PRICE STOCH价格字段 = PRICE_LOW_HIGH; // STOCH价格字段
input ENUM_MA_METHOD STOCH移动平均 = MODE_SMA; // STOCH移动平均
input double STOCH开空值小于 = 30.0; // STOCH开空值小于
input double STOCH开空值大于 = 70.0; // STOCH开空值大于
// 布林带参数
input int 布林周期 = 20; // 布林周期
input int 布林平移 = 0; // 布林平移
input double 布林偏差 = 2.0; // 布林偏差
input ENUM_APPLIED_PRICE 布林应用于= PRICE_CLOSE; // 布林应用于
//+------------------------------------------------------------------+
//| 全局变量 |
//+------------------------------------------------------------------+
int stochHandle;
int bbHandle;
double pointValue;
//+------------------------------------------------------------------+
//| 初始化函数 |
//+------------------------------------------------------------------+
int OnInit()
{
// 计算点值(XAUUSD需要注意)
pointValue = Point;
if(StringFind(_Symbol,"XAU")>=0) pointValue = Point*10; // 黄金1点=0.1美元波动
// 创建指标句柄
stochHandle = iStochastic(_Symbol, Period(), STOCHK周期, STOCHD周期, STOCH慢速, STOCH移动平均, STOCH价格字段);
if(stochHandle == INVALID_HANDLE)
{
Print("创建STOCH指标失败");
return(INIT_FAILED);
}
bbHandle = iBands(_Symbol, Period(), 布林周期, 布林平移, 布林偏差, 布林应用于);
if(bbHandle == INVALID_HANDLE)
{
Print("创建布林带指标失败");
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 反初始化函数 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(stochHandle != INVALID_HANDLE) IndicatorRelease(stochHandle);
if(bbHandle != INVALID_HANDLE) IndicatorRelease(bbHandle);
}
//+------------------------------------------------------------------+
//| 主循环函数 |
//+------------------------------------------------------------------+
void OnTick()
{
// 读取指标值
double stochK[];
if(CopyBuffer(stochHandle, 0, 0, 3, stochK) < 3) return;
double stochD[];
if(CopyBuffer(stochHandle, 1, 0, 3, stochD) < 3) return;
double bbUpper[], bbMiddle[], bbLower[];
if(CopyBuffer(bbHandle, MODE_UPPER, 0, 3, bbUpper) < 3) return;
if(CopyBuffer(bbHandle, MODE_MAIN, 0, 3, bbMiddle) < 3) return;
if(CopyBuffer(bbHandle, MODE_LOWER, 0, 3, bbLower) < 3) return;
// 持仓管理
ManageOrders(stochK, stochD, bbUpper, bbMiddle, bbLower);
}
//+------------------------------------------------------------------+
//| 订单管理函数(加仓、止盈、止损) |
//+------------------------------------------------------------------+
void ManageOrders(double &stochK[], double &stochD[], double &bbUpper[], double &bbMiddle[], double &bbLower[])
{
int buyCount=0, sellCount=0, totalOrders=0;
double totalProfit=0;
datetime firstOrderTime=0;
double firstOrderPrice=0;
int firstOrderType=0;
double totalLots=0;
// 遍历订单
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() != _Symbol || OrderMagicNumber() != 魔术号) continue;
totalOrders++;
totalProfit += OrderProfit() + OrderSwap() + OrderCommission();
totalLots += OrderLots();
if(OrderType() == OP_BUY) buyCount++;
if(OrderType() == OP_SELL) sellCount++;
if(OrderOpenTime() < firstOrderTime || firstOrderTime == 0)
{
firstOrderTime = OrderOpenTime();
firstOrderPrice = OrderOpenPrice();
firstOrderType = OrderType();
}
}
}
// 止盈判断(综合止盈)
if(totalOrders > 0)
{
double pipsProfit = 0;
if(firstOrderType == OP_BUY) pipsProfit = (Bid - firstOrderPrice)/pointValue;
if(firstOrderType == OP_SELL) pipsProfit = (firstOrderPrice - Ask)/pointValue;
if(totalOrders >=5 && totalProfit >= 第五单后止盈金额)
{
CloseAllOrders();
return;
}
if(pipsProfit >= 综合止盈点数)
{
CloseAllOrders();
return;
}
}
// 亏损平仓(可选)
if(是否启用亏损平仓 && AccountBalance()>0)
{
double lossPercent = (AccountBalance() - AccountEquity())/AccountBalance()*100;
if(lossPercent >= 亏损平仓百分比)
{
CloseAllOrders();
return;
}
}
// 时间平仓(可选)
if(是否启用时间平仓 && totalOrders>0)
{
if((TimeCurrent() - firstOrderTime)/3600 >= 持仓小时数)
{
CloseAllOrders();
return;
}
}
// 开仓/加仓逻辑
if(totalOrders == 0)
{
// 首次开仓(布林带+STOCH条件)
if(BollingerOpenCondition(stochK, stochD, bbUpper, bbLower))
{
OpenOrder(OP_BUY, 起始手数);
OpenOrder(OP_SELL, 起始手数); // 震荡单双向开仓
}
}
else
{
// 马丁加仓逻辑
if(totalOrders < 最大持仓单数量 && totalLots < 最大加仓手数)
{
double addInterval = GetAddInterval(totalOrders);
if(NeedAddOrder(firstOrderType, firstOrderPrice, addInterval))
{
double newLot = CalculateLot(totalOrders);
if(newLot <= 0) return;
OpenOrder(firstOrderType, newLot);
}
}
}
}
//+------------------------------------------------------------------+
//| 布林带开仓条件(震荡单) |
//+------------------------------------------------------------------+
bool BollingerOpenCondition(double k, double d, double upper, double lower)
{
bool buyCond = (Close <= lower && k <= STOCH开空值小于 && d <= STOCH开空值小于);
bool sellCond = (Close >= upper && k >= STOCH开空值大于 && d >= STOCH开空值大于);
return(buyCond || sellCond);
}
//+------------------------------------------------------------------+
//| 获取加仓间隔(根据层数选择) |
//+------------------------------------------------------------------+
double GetAddInterval(int layer)
{
if(layer <= 加仓层数1) return(加仓间隔1);
if(layer <= 加仓层数1+加仓层数2) return(加仓间隔2);
return(加仓间隔3);
}
//+------------------------------------------------------------------+
//| 计算加仓手数(马丁倍数) |
//+------------------------------------------------------------------+
double CalculateLot(int layer)
{
double lot = 起始手数 * MathPow(加仓倍数, layer);
lot = NormalizeDouble(lot, 2);
if(lot > 最大加仓手数) lot = 0;
return(lot);
}
//+------------------------------------------------------------------+
//| 判断是否需要加仓(亏损间隔条件) |
//+------------------------------------------------------------------+
bool NeedAddOrder(int type, double openPrice, double interval)
{
if(type == OP_BUY)
{
if((openPrice - Bid)/pointValue >= interval) return(true);
}
if(type == OP_SELL)
{
if((Ask - openPrice)/pointValue >= interval) return(true);
}
return(false);
}
//+------------------------------------------------------------------+
//| 下单函数 |
//+------------------------------------------------------------------+
bool OpenOrder(int type, double lot)
{
if(lot <= 0) return(false);
int ticket;
if(type == OP_BUY)
{
ticket = OrderSend(_Symbol, OP_BUY, lot, Ask, 3, 0, 0, "马丁多单", 魔术号, 0, clrBlue);
}
else
{
ticket = OrderSend(_Symbol, OP_SELL, lot, Bid, 3, 0, 0, "马丁空单", 魔术号, 0, clrRed);
}
if(ticket < 0)
{
Print("下单失败,错误码:", GetLastError());
return(false);
}
return(true);
}
//+------------------------------------------------------------------+
//| 平掉所有订单 |
//+------------------------------------------------------------------+
void CloseAllOrders()
{
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() != _Symbol || OrderMagicNumber() != 魔术号) continue;
if(OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrYellow);
}
if(OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrYellow);
}
}
}
}
//+------------------------------------------------------------------+
页:
[1]