forked from MasoodIqbal/RSI-Stoch-MA-EA
227 lines
9.4 KiB
MQL5
227 lines
9.4 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| TradingSetups.mqh |
|
||
|
|
//| All 18 Trading Setup Execution |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "QuarterTheory x VIZION"
|
||
|
|
#property strict
|
||
|
|
|
||
|
|
#include "GlobalVariables.mqh"
|
||
|
|
#include "InputParams.mqh"
|
||
|
|
#include "Utilities.mqh"
|
||
|
|
#include "TradeExecution.mqh"
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Execute continuation setups (14 setups - 150 SL, 4000 TP) |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void ExecuteContinuationSetups()
|
||
|
|
{
|
||
|
|
if(Current_Family != FAMILY_TRENDING || Current_State != STATE_CONTINUATION)
|
||
|
|
return;
|
||
|
|
|
||
|
|
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||
|
|
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||
|
|
double current = MidPrice();
|
||
|
|
double buffer = MA_Touch_Buffer * _Point;
|
||
|
|
|
||
|
|
// 1. MA14 CROSS
|
||
|
|
int ma14_crosses_up = 0;
|
||
|
|
int ma14_crosses_down = 0;
|
||
|
|
for(int i=0; i<10; i++)
|
||
|
|
{
|
||
|
|
if(i != 1)
|
||
|
|
{
|
||
|
|
if(MA_Current[1] > MA_Current[i]) ma14_crosses_up++;
|
||
|
|
if(MA_Current[1] < MA_Current[i]) ma14_crosses_down++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(ma14_crosses_up >= 2)
|
||
|
|
OpenTrade(true, ask, "MA14-CROSS↑", SETUP_MA14_CROSS, CATEGORY_CONTINUATION);
|
||
|
|
if(ma14_crosses_down >= 2)
|
||
|
|
OpenTrade(false, bid, "MA14-CROSS↓", SETUP_MA14_CROSS, CATEGORY_CONTINUATION);
|
||
|
|
|
||
|
|
// 2. MA50 BOUNCE
|
||
|
|
if(MathAbs(current - MA_Current[3]) <= buffer)
|
||
|
|
{
|
||
|
|
OpenTrade(true, ask, "MA50-BOUNCE↑", SETUP_MA50_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
OpenTrade(false, bid, "MA50-BOUNCE↓", SETUP_MA50_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 3. MA140 BOUNCE
|
||
|
|
if(MathAbs(current - MA_Current[4]) <= buffer)
|
||
|
|
{
|
||
|
|
OpenTrade(true, ask, "MA140-BOUNCE↑", SETUP_MA140_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
OpenTrade(false, bid, "MA140-BOUNCE↓", SETUP_MA140_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 4. MA230 BOUNCE
|
||
|
|
if(MathAbs(current - MA_Current[5]) <= buffer)
|
||
|
|
{
|
||
|
|
OpenTrade(true, ask, "MA230-BOUNCE↑", SETUP_MA230_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
OpenTrade(false, bid, "MA230-BOUNCE↓", SETUP_MA230_BOUNCE, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 5. MA500 TOUCH
|
||
|
|
if(MathAbs(current - MA_Current[6]) <= buffer)
|
||
|
|
{
|
||
|
|
OpenTrade(true, ask, "MA500-TOUCH↑", SETUP_MA500_TOUCH, CATEGORY_CONTINUATION);
|
||
|
|
OpenTrade(false, bid, "MA500-TOUCH↓", SETUP_MA500_TOUCH, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 6. FIB BREAKS
|
||
|
|
double previous = iClose(_Symbol, PERIOD_CURRENT, 1);
|
||
|
|
for(int i=1; i<6; i++)
|
||
|
|
{
|
||
|
|
if(MathAbs(current - PriceLevels[i]) <= buffer)
|
||
|
|
{
|
||
|
|
if(previous < PriceLevels[i])
|
||
|
|
OpenTrade(true, ask, "FIB-BREAK↑", SETUP_FIB_BREAK, CATEGORY_CONTINUATION);
|
||
|
|
if(previous > PriceLevels[i])
|
||
|
|
OpenTrade(false, bid, "FIB-BREAK↓", SETUP_FIB_BREAK, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 7. FIB RECLAIM
|
||
|
|
for(int i=1; i<6; i++)
|
||
|
|
{
|
||
|
|
if(NearLevel(current, PriceLevels[i], buffer))
|
||
|
|
{
|
||
|
|
if(MA_Previous[0] < PriceLevels[i] && MA_Current[0] > PriceLevels[i])
|
||
|
|
OpenTrade(true, ask, "FIB-RECLAIM↑", SETUP_FIB_RECLAIM, CATEGORY_CONTINUATION);
|
||
|
|
if(MA_Previous[0] > PriceLevels[i] && MA_Current[0] < PriceLevels[i])
|
||
|
|
OpenTrade(false, bid, "FIB-RECLAIM↓", SETUP_FIB_RECLAIM, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 8. MAGNET WALK
|
||
|
|
bool hugging = false;
|
||
|
|
if(Current_ATR > 0.0)
|
||
|
|
hugging = (MathAbs(current - MA_Current[2]) / Current_ATR < 0.7);
|
||
|
|
|
||
|
|
if(hugging && MA_Current[0] > MA_Current[3])
|
||
|
|
OpenTrade(true, ask, "MAGNET-WALK↑", SETUP_MAGNET_WALK, CATEGORY_CONTINUATION);
|
||
|
|
if(hugging && MA_Current[0] < MA_Current[3])
|
||
|
|
OpenTrade(false, bid, "MAGNET-WALK↓", SETUP_MAGNET_WALK, CATEGORY_CONTINUATION);
|
||
|
|
|
||
|
|
// 9. MFIB LADDER
|
||
|
|
if(NearLevel(current, MFIB_Level_618, buffer) || NearLevel(current, MFIB_Level_382, buffer))
|
||
|
|
{
|
||
|
|
if(IsBullBias())
|
||
|
|
OpenTrade(true, ask, "MFIB-LADDER↑", SETUP_MFIB_LADDER, CATEGORY_CONTINUATION);
|
||
|
|
if(IsBearBias())
|
||
|
|
OpenTrade(false, bid, "MFIB-LADDER↓", SETUP_MFIB_LADDER, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 10. STAIRCASE ADVANCE
|
||
|
|
bool mas_stacked_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 mas_stacked_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]);
|
||
|
|
|
||
|
|
if(mas_stacked_bull && Current_ADX > 25 && !Band_Snap_Warning)
|
||
|
|
OpenTrade(true, ask, "STAIRCASE↑", SETUP_STAIRCASE_ADV, CATEGORY_CONTINUATION);
|
||
|
|
if(mas_stacked_bear && Current_ADX > 25 && !Band_Snap_Warning)
|
||
|
|
OpenTrade(false, bid, "STAIRCASE↓", SETUP_STAIRCASE_ADV, CATEGORY_CONTINUATION);
|
||
|
|
|
||
|
|
// 11. CONTROLLED PULLBACK
|
||
|
|
bool minor_pb_bull = (MA_Current[0] < MA_Current[1]) && (MA_Current[0] > MA_Current[3]) &&
|
||
|
|
(Stoch_K_Current < 50) && (Stoch_K_Current > Stoch_Low);
|
||
|
|
bool minor_pb_bear = (MA_Current[0] > MA_Current[1]) && (MA_Current[0] < MA_Current[3]) &&
|
||
|
|
(Stoch_K_Current > 50) && (Stoch_K_Current < Stoch_High);
|
||
|
|
|
||
|
|
if(minor_pb_bull && IsBullBias())
|
||
|
|
OpenTrade(true, ask, "CTRL-PB↑", SETUP_CTRL_PULLBACK, CATEGORY_CONTINUATION);
|
||
|
|
if(minor_pb_bear && IsBearBias())
|
||
|
|
OpenTrade(false, bid, "CTRL-PB↓", SETUP_CTRL_PULLBACK, CATEGORY_CONTINUATION);
|
||
|
|
|
||
|
|
// 12. TIMEFRAME RESET
|
||
|
|
bool tf_reset_bull = (MA_Previous[0] < MA_Current[3]) && (MA_Current[0] >= MA_Current[3]) &&
|
||
|
|
(Stoch_K_Current > Stoch_K_Previous);
|
||
|
|
bool tf_reset_bear = (MA_Previous[0] > MA_Current[3]) && (MA_Current[0] <= MA_Current[3]) &&
|
||
|
|
(Stoch_K_Current < Stoch_K_Previous);
|
||
|
|
|
||
|
|
if(tf_reset_bull && IsBullBias())
|
||
|
|
OpenTrade(true, ask, "TF-RESET↑", SETUP_TF_RESET, CATEGORY_CONTINUATION);
|
||
|
|
if(tf_reset_bear && IsBearBias())
|
||
|
|
OpenTrade(false, bid, "TF-RESET↓", SETUP_TF_RESET, CATEGORY_CONTINUATION);
|
||
|
|
|
||
|
|
// 13. MFIB PRESS
|
||
|
|
bool mfib_press_bull = (NearLevel(current, MFIB_Level_618, buffer) || NearLevel(current, MFIB_Level_786, buffer)) &&
|
||
|
|
(MA_Current[0] > MA_Current[1]) && (Stoch_K_Current > 50);
|
||
|
|
bool mfib_press_bear = (NearLevel(current, MFIB_Level_236, buffer) || NearLevel(current, MFIB_Level_382, buffer)) &&
|
||
|
|
(MA_Current[0] < MA_Current[1]) && (Stoch_K_Current < 50);
|
||
|
|
|
||
|
|
if(mfib_press_bull && IsBullBias())
|
||
|
|
OpenTrade(true, ask, "MFIB-PRESS↑", SETUP_MFIB_PRESS, CATEGORY_CONTINUATION);
|
||
|
|
if(mfib_press_bear && IsBearBias())
|
||
|
|
OpenTrade(false, bid, "MFIB-PRESS↓", SETUP_MFIB_PRESS, CATEGORY_CONTINUATION);
|
||
|
|
}
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Execute range setups (50 SL, 3000 TP) |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void ExecuteRangeSetups()
|
||
|
|
{
|
||
|
|
if(Current_Family != FAMILY_RANGING)
|
||
|
|
return;
|
||
|
|
|
||
|
|
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||
|
|
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||
|
|
double current = MidPrice();
|
||
|
|
double buffer = MA_Touch_Buffer * _Point;
|
||
|
|
|
||
|
|
// Range edge entries
|
||
|
|
if(MathAbs(current - PriceLevels[1]) < buffer && Stoch_K_Current < 35)
|
||
|
|
OpenTrade(true, ask, "RANGE-BUY", SETUP_RANGE_ENGINE, CATEGORY_COUNTER_TREND);
|
||
|
|
if(MathAbs(current - PriceLevels[5]) < buffer && Stoch_K_Current > 65)
|
||
|
|
OpenTrade(false, bid, "RANGE-SELL", SETUP_RANGE_ENGINE, CATEGORY_COUNTER_TREND);
|
||
|
|
|
||
|
|
// MFIB reject in range
|
||
|
|
if(MFIB_Reject_Warning && (Stoch_Reject_Warning || Stoch_Extreme_Warning || Warning_Confluence_3Plus))
|
||
|
|
{
|
||
|
|
if(current <= MFIB_Level_050)
|
||
|
|
OpenTrade(true, ask, "RANGE-MFIB-BUY", SETUP_RANGE_ENGINE, CATEGORY_COUNTER_TREND);
|
||
|
|
if(current >= MFIB_Level_050)
|
||
|
|
OpenTrade(false, bid, "RANGE-MFIB-SELL", SETUP_RANGE_ENGINE, CATEGORY_COUNTER_TREND);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Fib reject in range
|
||
|
|
if(Fib_Reject_Warning)
|
||
|
|
{
|
||
|
|
if(current <= PriceLevels[3])
|
||
|
|
OpenTrade(true, ask, "RANGE-FIB-BUY", SETUP_FIB_REJECT, CATEGORY_COUNTER_TREND);
|
||
|
|
if(current >= PriceLevels[3])
|
||
|
|
OpenTrade(false, bid, "RANGE-FIB-SELL", SETUP_FIB_REJECT, CATEGORY_COUNTER_TREND);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Execute chop setups (50 SL, 3000 TP) |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void ExecuteChopSetups()
|
||
|
|
{
|
||
|
|
if(Current_Family != FAMILY_CHOP)
|
||
|
|
return;
|
||
|
|
|
||
|
|
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||
|
|
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||
|
|
double current = MidPrice();
|
||
|
|
|
||
|
|
// Mean reversion on extremes
|
||
|
|
if(Stoch_Extreme_Warning || Stoch_Reject_Warning || Fib_Reject_Warning ||
|
||
|
|
MFIB_Reject_Warning || Warning_Confluence_3Plus)
|
||
|
|
{
|
||
|
|
if(Stoch_K_Current <= Stoch_Low)
|
||
|
|
OpenTrade(true, ask, "CHOP-REV-BUY", SETUP_MEAN_REV, CATEGORY_COUNTER_TREND);
|
||
|
|
if(Stoch_K_Current >= Stoch_High)
|
||
|
|
OpenTrade(false, bid, "CHOP-REV-SELL", SETUP_MEAN_REV, CATEGORY_COUNTER_TREND);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Band snap reversal
|
||
|
|
if(Band_Snap_Warning)
|
||
|
|
{
|
||
|
|
if(current < MA_Current[0])
|
||
|
|
OpenTrade(true, ask, "CHOP-SNAP-BUY", SETUP_MEAN_REV, CATEGORY_COUNTER_TREND);
|
||
|
|
if(current > MA_Current[0])
|
||
|
|
OpenTrade(false, bid, "CHOP-SNAP-SELL", SETUP_MEAN_REV, CATEGORY_COUNTER_TREND);
|
||
|
|
}
|
||
|
|
}
|