306楼
新年快乐!马到成功!
韬客社区www.talkfx.co
发表于:2026-02-21 01:03只看该作者
307楼
新年快乐今年一起赚钱发财
韬客社区www.talkfx.co
308楼
202602 偷懒了

韬客社区www.talkfx.co
310楼
2026年3月,当牛马的日子生活比较有规律

韬客社区www.talkfx.co
发表于:2026-04-02 00:42只看该作者
311楼
这个是盈利吗
韬客社区www.talkfx.co
312楼
每天走8000步,低于6000则为不及格
韬客社区www.talkfx.co
313楼
有人提出要一个MT5账号的净值监控软件,需求只是一句话,那我也只是用一句话给DS写,代码如下:
//+------------------------------------------------------------------+
//| MonitorNetWorthEA.mq5 |
//| Copyright 2023, Your Name |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, Your Name"
#property link ""
#property version "1.00"
#property strict
// 输入参数
input double ThresholdValue = 10000.0; // 净值阈值
input bool AlertWhenAbove = true; // 高于阈值时报警
input bool AlertWhenBelow = true; // 低于阈值时报警
input bool CloseAllWhenAbove = false; // 高于阈值时平仓所有订单
input bool CloseAllWhenBelow = false; // 低于阈值时平仓所有订单
input int CheckInterval = 60; // 检查间隔(秒)
input string AlertMessage = "账户净值已达阈值"; // 报警消息
input bool EnableNotification = true; // 发送推送通知
input bool SendEmailAlert = false; // 发送邮件
input bool LogToFile = true; // 记录到文件
// 全局变量
datetime lastCheckTime = 0;
string logFileName = "NetWorthMonitor.csv";
bool lastAboveThreshold = false;
bool lastBelowThreshold = false;
//+------------------------------------------------------------------+
//| 专家初始化函数 |
//+------------------------------------------------------------------+
int OnInit()
{
// 创建日志文件
if(LogToFile)
{
int handle = FileOpen(logFileName, FILE_WRITE|FILE_CSV|FILE_READ, ",");
if(handle != INVALID_HANDLE)
{
FileWrite(handle, "时间", "净值", "状态", "账户余额", "浮动盈亏");
FileClose(handle);
}
}
// 首次检查
lastCheckTime = TimeCurrent();
CheckNetWorth();
Print("净值监控EA已启动,阈值: ", ThresholdValue, ", 检查间隔: ", CheckInterval, "秒");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 专家反初始化函数 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Print("净值监控EA已停止,原因代码: ", reason);
}
//+------------------------------------------------------------------+
//| 专家主函数 |
//+------------------------------------------------------------------+
void OnTick()
{
// 按间隔检查
if(TimeCurrent() - lastCheckTime >= CheckInterval)
{
lastCheckTime = TimeCurrent();
CheckNetWorth();
}
}
//+------------------------------------------------------------------+
//| 检查账户净值 |
//+------------------------------------------------------------------+
void CheckNetWorth()
{
double equity = AccountInfoDouble(ACCOUNT_EQUITY);
double balance = AccountInfoDouble(ACCOUNT_BALANCE);
double floatingProfit = equity - balance;
bool currentAboveThreshold = (equity > ThresholdValue);
bool currentBelowThreshold = (equity < ThresholdValue);
// 记录日志
if(LogToFile)
{
LogEquity(equity, currentAboveThreshold, balance, floatingProfit);
}
// 检查阈值条件并执行相应操作
if(currentAboveThreshold)
{
// 从低于阈值变为高于阈值时触发报警
if(AlertWhenAbove && !lastAboveThreshold)
{
string msg = AlertMessage + " | 净值: " + DoubleToString(equity, 2) +
" | 高于阈值: " + DoubleToString(ThresholdValue, 2);
SendAlerts(msg);
}
// 高于阈值时平仓
if(CloseAllWhenAbove && !lastAboveThreshold)
{
CloseAllPositions("净值高于阈值");
}
}
else if(currentBelowThreshold)
{
// 从高于阈值变为低于阈值时触发报警
if(AlertWhenBelow && !lastBelowThreshold)
{
string msg = AlertMessage + " | 净值: " + DoubleToString(equity, 2) +
" | 低于阈值: " + DoubleToString(ThresholdValue, 2);
SendAlerts(msg);
}
// 低于阈值时平仓
if(CloseAllWhenBelow && !lastBelowThreshold)
{
CloseAllPositions("净值低于阈值");
}
}
// 更新状态
lastAboveThreshold = currentAboveThreshold;
lastBelowThreshold = currentBelowThreshold;
}
//+------------------------------------------------------------------+
//| 发送警报(弹窗/通知/邮件) |
//+------------------------------------------------------------------+
void SendAlerts(string message)
{
// 弹窗警报
Alert(message);
// 推送通知到手机
if(EnableNotification)
{
SendNotification(message);
}
// 发送邮件
if(SendEmailAlert)
{
SendMail("账户净值警报", message);
}
Print("警报已发送: ", message);
}
//+------------------------------------------------------------------+
//| 平仓所有持仓 |
//+------------------------------------------------------------------+
void CloseAllPositions(string reason)
{
int total = PositionsTotal();
int closed = 0;
for(int i = total - 1; i >= 0; i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket > 0)
{
if(PositionSelectByTicket(ticket))
{
// 准备平仓请求
MqlTradeRequest request = {};
MqlTradeResult result = {};
request.action = TRADE_ACTION_DEAL;
request.symbol = PositionGetString(POSITION_SYMBOL);
request.volume = PositionGetDouble(POSITION_VOLUME);
request.deviation = 10;
request.magic = ExpertMagic();
request.comment = "平仓(" + reason + ")";
// 确定平仓方向
long positionType = PositionGetInteger(POSITION_TYPE);
if(positionType == POSITION_TYPE_BUY)
{
request.type = ORDER_TYPE_SELL;
request.price = SymbolInfoDouble(request.symbol, SYMBOL_BID);
}
else if(positionType == POSITION_TYPE_SELL)
{
request.type = ORDER_TYPE_BUY;
request.price = SymbolInfoDouble(request.symbol, SYMBOL_ASK);
}
request.position = ticket;
// 执行平仓
if(OrderSend(request, result))
{
if(result.retcode == TRADE_RETCODE_DONE)
{
closed++;
Print("已平仓: ", request.symbol, " 订单号: ", ticket);
}
else
{
Print("平仓失败: ", request.symbol, " 错误码: ", result.retcode, " 说明: ", result.comment);
}
}
}
}
}
if(closed > 0)
{
string msg = "已平仓 " + IntegerToString(closed) + " 个订单,原因: " + reason;
SendAlerts(msg);
}
}
//+------------------------------------------------------------------+
//| 记录净值日志 |
//+------------------------------------------------------------------+
void LogEquity(double equity, bool isAboveThreshold, double balance, double floatingProfit)
{
int handle = FileOpen(logFileName, FILE_WRITE|FILE_CSV|FILE_READ, ",");
if(handle != INVALID_HANDLE)
{
// 移动到文件末尾
FileSeek(handle, 0, SEEK_END);
string status = isAboveThreshold ? "高于阈值" : "低于阈值";
string timeStr = TimeToString(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS);
FileWrite(handle, timeStr,
DoubleToString(equity, 2),
status,
DoubleToString(balance, 2),
DoubleToString(floatingProfit, 2));
FileClose(handle);
}
else
{
Print("无法打开日志文件: ", logFileName, " 错误: ", GetLastError());
}
}
//+------------------------------------------------------------------+
//| 获取EA魔术数 |
//+------------------------------------------------------------------+
int ExpertMagic()
{
// 使用EA名称的哈希值作为魔术数
string name = "MonitorNetWorthEA";
int magic = 0;
for(int i = 0; i < StringLen(name); i++)
magic += (int)StringGetCharacter(name, i);
return magic;
}
//+------------------------------------------------------------------+能实现这样的功能:

韬客社区www.talkfx.co
314楼
MT5-净值监控EA 1.0

韬客社区www.talkfx.co
发表于:2026-04-03 03:24只看该作者
315楼
有ai啥都好做啊
韬客社区www.talkfx.co













