Harden HIT entry and manager state handling

This commit is contained in:
Hiroaki86
2026-06-14 22:02:17 +09:00
parent 7b11d44d66
commit 52067c1973
10 changed files with 107 additions and 120 deletions
+31 -5
View File
@@ -335,12 +335,14 @@ public:
continue;
double candidate_sl = 0.0;
const double position_open_price = PositionGetDouble(POSITION_PRICE_OPEN);
const double evaluation_price = (type == POSITION_TYPE_BUY) ? tick.bid : tick.ask;
if (!CalcHighVolatilitySL(type,
evaluation_price,
open_m1,
open_m3,
open_m5,
evaluation_price,
position_open_price,
open_m1,
open_m3,
open_m5,
open_m10,
open_m15,
pip_size,
@@ -590,6 +592,7 @@ private:
/// @return いずれかの時間足でしきい値を超え、SL候補を出力した場合は true。
bool CalcHighVolatilitySL(const ENUM_POSITION_TYPE type,
const double current_price,
const double position_open_price,
const double open_m1,
const double open_m3,
const double open_m5,
@@ -612,13 +615,36 @@ private:
if (!has_candidate)
return false;
if (!IsProfitProtectingStopLoss(type, candidate_sl, position_open_price))
return false;
sl_value = NormalizeDouble(candidate_sl, digits);
return true;
}
/// @brief 急変時SL候補が建値より不利にならないことを確認する。
bool IsProfitProtectingStopLoss(const ENUM_POSITION_TYPE type,
const double candidate_sl,
const double open_price)
{
if (open_price <= 0.0)
return false;
const double point = SymbolInfoDouble(m_symbol, SYMBOL_POINT);
const double tolerance = point * 0.1;
if (type == POSITION_TYPE_BUY)
return (candidate_sl >= open_price - tolerance);
if (type == POSITION_TYPE_SELL)
return (candidate_sl <= open_price + tolerance);
return false;
}
/// @brief 1本の時間足始値から急変幅を評価し、有効なSL候補なら最良候補へ反映する。
void EvaluateHighVolatilityOpen(const ENUM_POSITION_TYPE type,
const double current_price,
const double current_price,
const double open_price,
const double limit_pips,
const double rate_ratio,