mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-07 16:07:55 +00:00
Fix critical Phase 2 multi-timeframe analysis bug
- Fixed UpdateMultiTimeframeAnalysis() returning false when no updates needed - Changed return logic to return success status instead of update status - This resolves thousands of 'Failed to update multi-timeframe analysis' warnings - Phase 2 multi-timeframe analysis now works correctly after first initialization - EA will now properly continue analysis and trading after initial pattern detection
This commit is contained in:
+83
-70
@@ -850,70 +850,6 @@ void UpdateInfoPanel()
|
||||
ObjectSetString(0, "SniperEA_Info", OBJPROP_TEXT, info_text);
|
||||
}
|
||||
|
||||
void DrawPatternsOnChart(string symbol, MarketStructureData &mtf_data)
|
||||
{
|
||||
if (!IsVisualizationEnabled())
|
||||
return;
|
||||
|
||||
// Draw Order Blocks
|
||||
if (ShowOrderBlocks)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.order_blocks); i++)
|
||||
{
|
||||
if (mtf_data.order_blocks[i].is_fresh && mtf_data.order_blocks[i].strength > OBStrengthFilter)
|
||||
{
|
||||
DrawOrderBlock(symbol, mtf_data.order_blocks[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Fair Value Gaps
|
||||
if (ShowFVG)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.fair_value_gaps); i++)
|
||||
{
|
||||
if (!mtf_data.fair_value_gaps[i].is_filled)
|
||||
{
|
||||
DrawFairValueGap(symbol, mtf_data.fair_value_gaps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Break of Structure events
|
||||
if (ShowBOS)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.bos_events); i++)
|
||||
{
|
||||
if (mtf_data.bos_events[i].confirmed)
|
||||
{
|
||||
DrawBreakOfStructure(symbol, mtf_data.bos_events[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Liquidity Sweeps
|
||||
if (ShowSweeps)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.liquidity_sweeps); i++)
|
||||
{
|
||||
if (mtf_data.liquidity_sweeps[i].confirmed)
|
||||
{
|
||||
DrawLiquiditySweep(symbol, mtf_data.liquidity_sweeps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EnableDebugMode)
|
||||
{
|
||||
LogDebug(StringFormat("Drew patterns for %s %s: OB=%d, FVG=%d, BOS=%d, Sweeps=%d",
|
||||
symbol, EnumToString(mtf_data.timeframe),
|
||||
ArraySize(mtf_data.order_blocks),
|
||||
ArraySize(mtf_data.fair_value_gaps),
|
||||
ArraySize(mtf_data.bos_events),
|
||||
ArraySize(mtf_data.liquidity_sweeps)));
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get current trading session |
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -3213,36 +3149,47 @@ bool UpdateMultiTimeframeAnalysis(string symbol)
|
||||
{
|
||||
LogDebug("Updating Multi-Timeframe Analysis for " + symbol);
|
||||
|
||||
bool success = true;
|
||||
bool updated = false;
|
||||
|
||||
// Update M1 analysis (most frequent)
|
||||
if (IsNewBar(symbol, PERIOD_M1) || !MTF_Data_M1.is_valid)
|
||||
{
|
||||
updated |= UpdateTimeframeData(symbol, MTF_Data_M1);
|
||||
bool m1_result = UpdateTimeframeData(symbol, MTF_Data_M1);
|
||||
success &= m1_result;
|
||||
updated |= m1_result;
|
||||
}
|
||||
|
||||
// Update M15 analysis
|
||||
if (IsTimeframeUpdateNeeded(symbol, MTF_Data_M15) || !MTF_Data_M15.is_valid)
|
||||
{
|
||||
updated |= UpdateTimeframeData(symbol, MTF_Data_M15);
|
||||
bool m15_result = UpdateTimeframeData(symbol, MTF_Data_M15);
|
||||
success &= m15_result;
|
||||
updated |= m15_result;
|
||||
}
|
||||
|
||||
// Update H4 analysis
|
||||
if (IsTimeframeUpdateNeeded(symbol, MTF_Data_H4) || !MTF_Data_H4.is_valid)
|
||||
{
|
||||
updated |= UpdateTimeframeData(symbol, MTF_Data_H4);
|
||||
bool h4_result = UpdateTimeframeData(symbol, MTF_Data_H4);
|
||||
success &= h4_result;
|
||||
updated |= h4_result;
|
||||
}
|
||||
|
||||
// Update D1 analysis
|
||||
if (IsTimeframeUpdateNeeded(symbol, MTF_Data_D1) || !MTF_Data_D1.is_valid)
|
||||
{
|
||||
updated |= UpdateTimeframeData(symbol, MTF_Data_D1);
|
||||
bool d1_result = UpdateTimeframeData(symbol, MTF_Data_D1);
|
||||
success &= d1_result;
|
||||
updated |= d1_result;
|
||||
}
|
||||
|
||||
// Update W1 analysis (least frequent)
|
||||
if (IsTimeframeUpdateNeeded(symbol, MTF_Data_W1) || !MTF_Data_W1.is_valid)
|
||||
{
|
||||
updated |= UpdateTimeframeData(symbol, MTF_Data_W1);
|
||||
bool w1_result = UpdateTimeframeData(symbol, MTF_Data_W1);
|
||||
success &= w1_result;
|
||||
updated |= w1_result;
|
||||
}
|
||||
|
||||
if (updated)
|
||||
@@ -3250,7 +3197,9 @@ bool UpdateMultiTimeframeAnalysis(string symbol)
|
||||
LogDebug("Multi-Timeframe Analysis updated for " + symbol);
|
||||
}
|
||||
|
||||
return updated;
|
||||
// Return success (true) even if no updates were needed
|
||||
// Only return false if there was an actual error during updates
|
||||
return success;
|
||||
}
|
||||
|
||||
bool IsTimeframeUpdateNeeded(string symbol, MarketStructureData &mtf_data)
|
||||
@@ -3336,6 +3285,70 @@ bool UpdateTimeframeData(string symbol, MarketStructureData &mtf_data)
|
||||
return success;
|
||||
}
|
||||
|
||||
void DrawPatternsOnChart(string symbol, MarketStructureData &mtf_data)
|
||||
{
|
||||
if (!IsVisualizationEnabled())
|
||||
return;
|
||||
|
||||
// Draw Order Blocks
|
||||
if (ShowOrderBlocks)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.order_blocks); i++)
|
||||
{
|
||||
if (mtf_data.order_blocks[i].is_fresh && mtf_data.order_blocks[i].strength > OBStrengthFilter)
|
||||
{
|
||||
DrawOrderBlock(symbol, mtf_data.order_blocks[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Fair Value Gaps
|
||||
if (ShowFVG)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.fair_value_gaps); i++)
|
||||
{
|
||||
if (!mtf_data.fair_value_gaps[i].is_filled)
|
||||
{
|
||||
DrawFairValueGap(symbol, mtf_data.fair_value_gaps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Break of Structure events
|
||||
if (ShowBOS)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.bos_events); i++)
|
||||
{
|
||||
if (mtf_data.bos_events[i].confirmed)
|
||||
{
|
||||
DrawBreakOfStructure(symbol, mtf_data.bos_events[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Liquidity Sweeps
|
||||
if (ShowSweeps)
|
||||
{
|
||||
for (int i = 0; i < ArraySize(mtf_data.liquidity_sweeps); i++)
|
||||
{
|
||||
if (mtf_data.liquidity_sweeps[i].confirmed)
|
||||
{
|
||||
DrawLiquiditySweep(symbol, mtf_data.liquidity_sweeps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EnableDebugMode)
|
||||
{
|
||||
LogDebug(StringFormat("Drew patterns for %s %s: OB=%d, FVG=%d, BOS=%d, Sweeps=%d",
|
||||
symbol, EnumToString(mtf_data.timeframe),
|
||||
ArraySize(mtf_data.order_blocks),
|
||||
ArraySize(mtf_data.fair_value_gaps),
|
||||
ArraySize(mtf_data.bos_events),
|
||||
ArraySize(mtf_data.liquidity_sweeps)));
|
||||
}
|
||||
}
|
||||
|
||||
string GetMarketBias(string symbol)
|
||||
{
|
||||
// Phase 2: Enhanced market bias calculation using bias strength
|
||||
|
||||
Reference in New Issue
Block a user