feat: 最小止损点数

This commit is contained in:
zhangyangbin
2026-05-17 14:25:26 +08:00
parent b2c6ef04e8
commit 80c2debaba
+6 -5
View File
@@ -20,6 +20,7 @@ input double InpPullbackTolerance = 0.0; // 反向突破容忍度(%) 0=
input group "=== 风险管理参数 ==="
input double InpStopLossPercent = 0.05; // 止损百分比(%)
input int InpMinStopLossPoints = 100; // 最小止损点数
input double InpRiskRewardRatio = 1.5; // 盈亏比
input bool InpUseTrailingStop = false; // 使用移动止损
input int InpMaxHoldingMinutes = 5; // 最大持仓时间(分钟)
@@ -119,7 +120,7 @@ int OnInit()
Print("反向突破容忍度: ", DoubleToString(InpPullbackTolerance, 1), "% (启用)");
else
Print("反向突破容忍度: 0% (禁用 - 保持原有逻辑)");
Print("止损:", InpStopLossPercent, "% (最小1美元) | 盈亏比:", InpRiskRewardRatio);
Print("止损:", InpStopLossPercent, "% (最小", InpMinStopLossPoints, "点) | 盈亏比:", InpRiskRewardRatio);
Print("移动止损:", (InpUseTrailingStop ? "启用" : "禁用"));
Print("最大持仓时间:", InpMaxHoldingMinutes, "分钟");
Print("最大开仓手数:", InpMaxPositions);
@@ -743,8 +744,8 @@ bool OpenPosition(ENUM_ORDER_TYPE order_type, double wave_high, double wave_low,
// 计算止损和止盈(基于开仓价的百分比)
double stop_loss_amount = current_price * InpStopLossPercent / 100.0;
// 确保止损金额不小于1美元(100点)
double min_stop_loss = 1.0; // 1美元 = 100点
// 确保止损金额不小于最小止损点数
double min_stop_loss = InpMinStopLossPoints * _Point;
if(stop_loss_amount < min_stop_loss) {
stop_loss_amount = min_stop_loss;
}
@@ -873,8 +874,8 @@ void CheckTrailingStop(ulong ticket)
// 计算止损金额(开仓价的百分比)
double stop_loss_amount = open_price * InpStopLossPercent / 100.0;
// 确保止损金额不小于1美元(100点)
double min_stop_loss = 1.0; // 1美元 = 100点
// 确保止损金额不小于最小止损点数
double min_stop_loss = InpMinStopLossPoints * _Point;
if(stop_loss_amount < min_stop_loss) {
stop_loss_amount = min_stop_loss;
}