forked from SahrJohn/RSI-Stoch-MA-EA
266 lines
8.5 KiB
MQL5
266 lines
8.5 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Praise.mqh |
|
||
|
|
//| PRAISE System: 8 Trend Strength Signals |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "QuarterTheory x VIZION"
|
||
|
|
#property strict
|
||
|
|
|
||
|
|
#include "GlobalVariables.mqh"
|
||
|
|
#include "InputParams.mqh"
|
||
|
|
#include "Utilities.mqh"
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Detect all PRAISE signals for aggressive trend following |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void DetectPraiseSignals()
|
||
|
|
{
|
||
|
|
if(!Use_Praise_System)
|
||
|
|
{
|
||
|
|
Praise_Count = 0;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
double current = MidPrice();
|
||
|
|
double bufferPts = (double)MA_Touch_Buffer;
|
||
|
|
|
||
|
|
// Reset all praise flags
|
||
|
|
Praise_Triple_Magnet = false;
|
||
|
|
Praise_Power_Couple = false;
|
||
|
|
Praise_MFIB_Staircase = false;
|
||
|
|
Praise_MFIB_Express = false;
|
||
|
|
Praise_MFIB_Breakout = false;
|
||
|
|
Praise_MA_Stack = false;
|
||
|
|
Praise_Clean_Reclaim = false;
|
||
|
|
Praise_Multi_Breakout = false;
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// CATEGORY 1: MA MAGNET PERFECTION
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// PRAISE 1: 7x14x21 Triple Magnet Hold
|
||
|
|
if(Current_ATR > 0.0)
|
||
|
|
{
|
||
|
|
double dist7 = MathAbs(current - MA_Current[0]) / Current_ATR;
|
||
|
|
double dist14 = MathAbs(current - MA_Current[1]) / Current_ATR;
|
||
|
|
double dist21 = MathAbs(current - MA_Current[2]) / Current_ATR;
|
||
|
|
|
||
|
|
bool all_close = (dist7 < 0.5) && (dist14 < 0.7) && (dist21 < 0.9);
|
||
|
|
bool mas_trending = (MA_Current[0] > MA_Previous[0] && MA_Current[1] > MA_Previous[1] && MA_Current[2] > MA_Previous[2]) ||
|
||
|
|
(MA_Current[0] < MA_Previous[0] && MA_Current[1] < MA_Previous[1] && MA_Current[2] < MA_Previous[2]);
|
||
|
|
|
||
|
|
if(all_close && mas_trending && !Band_Snap_Warning)
|
||
|
|
Praise_Triple_Magnet = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
// PRAISE 2: 14x21 Power Couple
|
||
|
|
if(Current_ATR > 0.0)
|
||
|
|
{
|
||
|
|
double dist_14_21 = MathAbs(MA_Current[1] - MA_Current[2]) / Current_ATR;
|
||
|
|
bool couple_close = (dist_14_21 < 0.3);
|
||
|
|
bool same_direction = (MA_Current[1] > MA_Previous[1] && MA_Current[2] > MA_Previous[2]) ||
|
||
|
|
(MA_Current[1] < MA_Previous[1] && MA_Current[2] < MA_Previous[2]);
|
||
|
|
bool ma7_correct_side = (IsBullBias() && MA_Current[0] > MA_Current[1]) ||
|
||
|
|
(IsBearBias() && MA_Current[0] < MA_Current[1]);
|
||
|
|
bool price_hugging = MathAbs(current - MA_Current[1]) / Current_ATR < 0.8 ||
|
||
|
|
MathAbs(current - MA_Current[2]) / Current_ATR < 0.8;
|
||
|
|
|
||
|
|
if(couple_close && same_direction && ma7_correct_side && price_hugging)
|
||
|
|
Praise_Power_Couple = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// CATEGORY 2: MFIB MOMENTUM
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// PRAISE 3: MFIB Staircase Advance
|
||
|
|
static double last_mfib_level = 0;
|
||
|
|
static int mfib_advances = 0;
|
||
|
|
|
||
|
|
double mfib_levels[5] = {MFIB_Level_786, MFIB_Level_618, MFIB_Level_050, MFIB_Level_382, MFIB_Level_236};
|
||
|
|
|
||
|
|
for(int i=0; i<5; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(current - mfib_levels[i]) / _Point < 30)
|
||
|
|
{
|
||
|
|
if(IsBullBias())
|
||
|
|
{
|
||
|
|
if(i > 0 && last_mfib_level == mfib_levels[i-1])
|
||
|
|
mfib_advances++;
|
||
|
|
}
|
||
|
|
else if(IsBearBias())
|
||
|
|
{
|
||
|
|
if(i < 4 && last_mfib_level == mfib_levels[i+1])
|
||
|
|
mfib_advances++;
|
||
|
|
}
|
||
|
|
|
||
|
|
last_mfib_level = mfib_levels[i];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(mfib_advances >= 2 && !MFIB_Reject_Warning)
|
||
|
|
Praise_MFIB_Staircase = true;
|
||
|
|
|
||
|
|
static datetime last_advance_time = 0;
|
||
|
|
if(TimeCurrent() - last_advance_time > 10 * PeriodSeconds())
|
||
|
|
{
|
||
|
|
mfib_advances = 0;
|
||
|
|
last_mfib_level = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// PRAISE 4: MFIB Express (skips a level)
|
||
|
|
static double prev_mfib_zone = 0;
|
||
|
|
double curr_mfib_zone = 0;
|
||
|
|
|
||
|
|
for(int i=0; i<5; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(current - mfib_levels[i]) / _Point < 50)
|
||
|
|
{
|
||
|
|
curr_mfib_zone = i;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(curr_mfib_zone > 0 && prev_mfib_zone > 0)
|
||
|
|
{
|
||
|
|
double zone_diff = MathAbs(curr_mfib_zone - prev_mfib_zone);
|
||
|
|
if(zone_diff >= 2 && Current_ADX > 25)
|
||
|
|
Praise_MFIB_Express = true;
|
||
|
|
}
|
||
|
|
prev_mfib_zone = curr_mfib_zone;
|
||
|
|
|
||
|
|
// PRAISE 5: MFIB Breakout Hold
|
||
|
|
static int mfib_breakout_hold_bars = 0;
|
||
|
|
|
||
|
|
if(MFIB_Break_Confirmed)
|
||
|
|
mfib_breakout_hold_bars++;
|
||
|
|
else
|
||
|
|
mfib_breakout_hold_bars = 0;
|
||
|
|
|
||
|
|
if(mfib_breakout_hold_bars >= 3 && !MFIB_Reject_Warning)
|
||
|
|
{
|
||
|
|
bool ma7_correct = (IsBullBias() && MA_Current[0] > last_mfib_level) ||
|
||
|
|
(IsBearBias() && MA_Current[0] < last_mfib_level);
|
||
|
|
if(ma7_correct)
|
||
|
|
Praise_MFIB_Breakout = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// CATEGORY 3: STRUCTURE PERFECTION
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// PRAISE 6: MA Stack Perfection
|
||
|
|
bool stack_bull = (MA_Current[0] > MA_Current[1]) && (MA_Current[1] > MA_Current[2]) &&
|
||
|
|
(MA_Current[2] > MA_Current[3]) && (MA_Current[3] > MA_Current[4]);
|
||
|
|
bool stack_bear = (MA_Current[0] < MA_Current[1]) && (MA_Current[1] < MA_Current[2]) &&
|
||
|
|
(MA_Current[2] < MA_Current[3]) && (MA_Current[3] < MA_Current[4]);
|
||
|
|
|
||
|
|
bool properly_spaced = true;
|
||
|
|
if(Current_ATR > 0.0)
|
||
|
|
{
|
||
|
|
for(int i=0; i<4; i++)
|
||
|
|
{
|
||
|
|
double spacing = MathAbs(MA_Current[i] - MA_Current[i+1]) / Current_ATR;
|
||
|
|
if(spacing < 0.1)
|
||
|
|
{
|
||
|
|
properly_spaced = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
bool all_trending = true;
|
||
|
|
for(int i=0; i<5; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(MA_Current[i] - MA_Previous[i]) / _Point < 5)
|
||
|
|
{
|
||
|
|
all_trending = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if((stack_bull || stack_bear) && properly_spaced && all_trending)
|
||
|
|
Praise_MA_Stack = true;
|
||
|
|
|
||
|
|
// PRAISE 7: Clean Reclaim Sequence
|
||
|
|
bool triple_reclaim = false;
|
||
|
|
|
||
|
|
if(MFIB_Reclaim_Warning && MA_Reclaim_Warning && Fib_Reclaim_Warning)
|
||
|
|
{
|
||
|
|
double mfib_price = 0, ma_price = 0, fib_price = 0;
|
||
|
|
|
||
|
|
for(int i=0; i<5; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(current - mfib_levels[i]) / _Point < 100)
|
||
|
|
{
|
||
|
|
mfib_price = mfib_levels[i];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(MA50_Warning) ma_price = MA_Current[3];
|
||
|
|
else if(MA140_Warning) ma_price = MA_Current[4];
|
||
|
|
else if(MA230_Warning) ma_price = MA_Current[5];
|
||
|
|
|
||
|
|
for(int i=1; i<6; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(current - PriceLevels[i]) / _Point < 100)
|
||
|
|
{
|
||
|
|
fib_price = PriceLevels[i];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(mfib_price > 0 && ma_price > 0 && fib_price > 0)
|
||
|
|
{
|
||
|
|
if(MathAbs(mfib_price - ma_price) / _Point < 100 &&
|
||
|
|
MathAbs(mfib_price - fib_price) / _Point < 100)
|
||
|
|
triple_reclaim = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(triple_reclaim)
|
||
|
|
Praise_Clean_Reclaim = true;
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// CATEGORY 4: BREAKOUT CONFIRMATION
|
||
|
|
//================================================================
|
||
|
|
|
||
|
|
// PRAISE 8: Multi-Level Breakout
|
||
|
|
static int breakout_time_window = 0;
|
||
|
|
static bool mfib_broke = false, fib_broke = false, ma_broke = false;
|
||
|
|
|
||
|
|
if(MFIB_Break_Confirmed) mfib_broke = true;
|
||
|
|
if(Fib_Break_Warning) fib_broke = true;
|
||
|
|
if(MA_Break_Warning) ma_broke = true;
|
||
|
|
|
||
|
|
if(mfib_broke || fib_broke || ma_broke)
|
||
|
|
breakout_time_window++;
|
||
|
|
|
||
|
|
if(breakout_time_window > 0 && breakout_time_window <= 5)
|
||
|
|
{
|
||
|
|
if(mfib_broke && fib_broke && ma_broke)
|
||
|
|
Praise_Multi_Breakout = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
if(breakout_time_window > 5)
|
||
|
|
{
|
||
|
|
breakout_time_window = 0;
|
||
|
|
mfib_broke = false;
|
||
|
|
fib_broke = false;
|
||
|
|
ma_broke = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
//================================================================
|
||
|
|
// COUNT TOTAL PRAISE
|
||
|
|
//================================================================
|
||
|
|
Praise_Count = 0;
|
||
|
|
if(Praise_Triple_Magnet) Praise_Count++;
|
||
|
|
if(Praise_Power_Couple) Praise_Count++;
|
||
|
|
if(Praise_MFIB_Staircase) Praise_Count++;
|
||
|
|
if(Praise_MFIB_Express) Praise_Count++;
|
||
|
|
if(Praise_MFIB_Breakout) Praise_Count++;
|
||
|
|
if(Praise_MA_Stack) Praise_Count++;
|
||
|
|
if(Praise_Clean_Reclaim) Praise_Count++;
|
||
|
|
if(Praise_Multi_Breakout) Praise_Count++;
|
||
|
|
}
|