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
+24 -3
View File
@@ -134,7 +134,6 @@ ulong slippage = 10;
//--- 主要な定数・設定
#define POSITION_LIMIT 48
#define ENTRY_H1_LIMIT 2 // H1本数(=2時間)
#define CLOSE_H1_LIMIT 12 // H1本数(=12時間)
#define HISTORY_BARS 72
#define OHLC_START_SHIFT 1 // 1: 確定足のみをPythonへ渡す
#define M15_CONFIRM_BARS 30
@@ -375,6 +374,17 @@ void ConfigurePythonGatewayPaths()
Print("Python app dir: ", python_app_dir);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/**
* @brief The split entry/manager design requires ticket-based hedging positions.
*/
bool IsHedgingAccount()
{
return (AccountInfoInteger(ACCOUNT_MARGIN_MODE) == ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);
}
//+------------------------------------------------------------------+
//| 起動時の処理
//+------------------------------------------------------------------+
@@ -391,6 +401,13 @@ int OnInit()
magic_number = input_entry_magic_number;
slippage = input_slippage_points;
if(!IsHedgingAccount())
{
Print("HITEntryEA requires a retail hedging account. account_margin_mode=",
AccountInfoInteger(ACCOUNT_MARGIN_MODE));
return INIT_FAILED;
}
ConfigurePythonGatewayPaths();
PrepareDoneFileOnInit(done_trend_file, running_trend_file, "trend");
@@ -459,6 +476,11 @@ void OnTick()
// H1新バーまたは初回起動時に、エントリー価格生成用Pythonを起動する。
ProcessEntryUpdate(g_ea);
// Read completed H1 results before spread gating so stale split orders and state updates are not delayed.
bool entry_result_ready = IsEntryResultReady();
if(entry_result_ready)
RefreshTargetPrices(g_ea);
// M15確定足ごとに、H1候補価格を発注してよいタイミングか再判定する。
ProcessM15EntryTimingUpdate();
@@ -468,10 +490,9 @@ void OnTick()
if(!IsSpreadAllowed(ctx))
return;
if(!IsEntryResultReady())
if(!entry_result_ready)
return;
RefreshTargetPrices(g_ea);
ProcessEntryDecisionIfNeeded(g_ea, ctx);
}