forked from SahrJohn/RSI-Stoch-MA-EA
125 lines
5.6 KiB
MQL5
125 lines
5.6 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| ReEntry.mqh |
|
||
|
|
//| Smart Re-Entry System with 10 Combos |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "QuarterTheory x VIZION"
|
||
|
|
#property strict
|
||
|
|
|
||
|
|
#include "GlobalVariables.mqh"
|
||
|
|
#include "InputParams.mqh"
|
||
|
|
#include "Utilities.mqh"
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Check if setup can re-enter based on combos |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
bool CanReEnter(SETUP_TYPE setup)
|
||
|
|
{
|
||
|
|
if(!Allow_Re_Entry) return true;
|
||
|
|
|
||
|
|
datetime now = TimeCurrent();
|
||
|
|
datetime cooldown_end = LastEntryTime[setup] + Re_Entry_Cooldown_Bars * PeriodSeconds(PERIOD_CURRENT);
|
||
|
|
bool cooldown_passed = (now >= cooldown_end);
|
||
|
|
|
||
|
|
// Check if recently stopped out
|
||
|
|
bool recently_stopped = false;
|
||
|
|
datetime cutoff = now - 10 * PeriodSeconds(PERIOD_CURRENT);
|
||
|
|
|
||
|
|
for(int i=0; i<10; i++)
|
||
|
|
{
|
||
|
|
if(RecentClosures[i].setup_type == setup &&
|
||
|
|
RecentClosures[i].close_time > cutoff &&
|
||
|
|
(RecentClosures[i].closed_at_sl || RecentClosures[i].closed_at_be))
|
||
|
|
{
|
||
|
|
recently_stopped = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// RE-ENTRY COMBO TRIGGERS (Override cooldown)
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// COMBO 1: 3+ Rejection/Reclaim at Strong MAs (140, 230, 500)
|
||
|
|
int reject_reclaim_count = 0;
|
||
|
|
if(Fib_Reject_Warning) reject_reclaim_count++;
|
||
|
|
if(MFIB_Reject_Warning) reject_reclaim_count++;
|
||
|
|
if(MA_Reject_Warning) reject_reclaim_count++;
|
||
|
|
if(Fib_Reclaim_Warning) reject_reclaim_count++;
|
||
|
|
if(MFIB_Reclaim_Warning) reject_reclaim_count++;
|
||
|
|
if(MA_Reclaim_Warning) reject_reclaim_count++;
|
||
|
|
|
||
|
|
bool at_strong_ma = (MA140_Warning || MA230_Warning || MA500_Warning);
|
||
|
|
bool combo1_strong_ma_confluence = (reject_reclaim_count >= 3 && at_strong_ma);
|
||
|
|
|
||
|
|
// COMBO 2: MA14 Magnet + Fib/MFIB Break (Trending)
|
||
|
|
bool combo2_ma14_magnet_break = (MA14_Magnet_Active && (Fib_Break_Confirmed || MFIB_Break_Confirmed));
|
||
|
|
|
||
|
|
// COMBO 3: Strong MA Bounce + Stoch Confirmation (Post-SL/BE)
|
||
|
|
bool combo3_strong_bounce = (Strong_MA_Bounce && recently_stopped &&
|
||
|
|
(Stoch_Level_Cross || StochCrossUp() || StochCrossDown()));
|
||
|
|
|
||
|
|
// COMBO 4: Trend Resumption after Pullback (MA50 reclaim + 2+ signals)
|
||
|
|
bool combo4_trend_resume = (Trend_Resumption && Warning_Confluence_Count >= 2);
|
||
|
|
|
||
|
|
// COMBO 5: Fib/MFIB Reclaim + MA Alignment (Post-BE)
|
||
|
|
bool mas_aligned_bull = (MA_Current[0] > MA_Current[1]) && (MA_Current[1] > MA_Current[2]);
|
||
|
|
bool mas_aligned_bear = (MA_Current[0] < MA_Current[1]) && (MA_Current[1] < MA_Current[2]);
|
||
|
|
bool combo5_level_reclaim = ((Fib_Reclaim_Warning || MFIB_Reclaim_Warning) &&
|
||
|
|
recently_stopped && (mas_aligned_bull || mas_aligned_bear));
|
||
|
|
|
||
|
|
// COMBO 6: Band Snap Recovery + Strong MA (Overextension correction)
|
||
|
|
bool combo6_snap_recovery = (Band_Snap_Warning && at_strong_ma && recently_stopped);
|
||
|
|
|
||
|
|
// COMBO 7: Multiple Level Confluence (Fib + MFIB + MA all align)
|
||
|
|
bool fib_and_mfib = (Fib_Reject_Warning || Fib_Reclaim_Warning) &&
|
||
|
|
(MFIB_Reject_Warning || MFIB_Reclaim_Warning);
|
||
|
|
bool combo7_triple_level = (fib_and_mfib && (MA_Reject_Warning || MA_Reclaim_Warning));
|
||
|
|
|
||
|
|
// COMBO 8: Stoch Extreme + Fib/MFIB Level + Post-SL
|
||
|
|
bool combo8_extreme_level = (Stoch_Extreme_Warning && recently_stopped &&
|
||
|
|
(Fib_Reject_Warning || MFIB_Reject_Warning));
|
||
|
|
|
||
|
|
// COMBO 9: MA Cross + Level Break + Continuation State
|
||
|
|
bool combo9_cross_break = (MA7_Cross_14_Warning && (Fib_Break_Confirmed || MFIB_Break_Confirmed) &&
|
||
|
|
Current_State == STATE_CONTINUATION);
|
||
|
|
|
||
|
|
// COMBO 10: 4+ Warning Confluence (Extreme conviction)
|
||
|
|
bool combo10_mega_confluence = (Warning_Confluence_Count >= 4);
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// DECISION LOGIC
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// If ANY combo triggers, allow immediate re-entry
|
||
|
|
bool combo_triggered =
|
||
|
|
combo1_strong_ma_confluence ||
|
||
|
|
combo2_ma14_magnet_break ||
|
||
|
|
combo3_strong_bounce ||
|
||
|
|
combo4_trend_resume ||
|
||
|
|
combo5_level_reclaim ||
|
||
|
|
combo6_snap_recovery ||
|
||
|
|
combo7_triple_level ||
|
||
|
|
combo8_extreme_level ||
|
||
|
|
combo9_cross_break ||
|
||
|
|
combo10_mega_confluence;
|
||
|
|
|
||
|
|
// Log re-entry combo if triggered
|
||
|
|
if(combo_triggered && !cooldown_passed)
|
||
|
|
{
|
||
|
|
string combo_name = "";
|
||
|
|
if(combo1_strong_ma_confluence) combo_name = "3+Reject/Reclaim@StrongMA";
|
||
|
|
else if(combo2_ma14_magnet_break) combo_name = "MA14Magnet+FibBreak";
|
||
|
|
else if(combo3_strong_bounce) combo_name = "StrongMA_Bounce+Stoch";
|
||
|
|
else if(combo4_trend_resume) combo_name = "TrendResumption";
|
||
|
|
else if(combo5_level_reclaim) combo_name = "Level_Reclaim+MA_Align";
|
||
|
|
else if(combo6_snap_recovery) combo_name = "BandSnap_Recovery";
|
||
|
|
else if(combo7_triple_level) combo_name = "Triple_Level_Confluence";
|
||
|
|
else if(combo8_extreme_level) combo_name = "Stoch_Extreme+Level";
|
||
|
|
else if(combo9_cross_break) combo_name = "MA_Cross+Level_Break";
|
||
|
|
else if(combo10_mega_confluence) combo_name = "4+_Confluence";
|
||
|
|
|
||
|
|
Print("🔁 RE-ENTRY COMBO TRIGGERED: ", combo_name, " | Setup: ", IntegerToString(setup));
|
||
|
|
}
|
||
|
|
|
||
|
|
return (cooldown_passed || combo_triggered);
|
||
|
|
}
|