//+------------------------------------------------------------------+
//| Trend Confluence EA
//+------------------------------------------------------------------+
#property copyright "Your Name"
#property version "1.00"
// Input Parameters
input int ShortMA_Period = 20; // Short-term MA period
input int MidMA_Period = 50; // Mid-term MA period
input int LongMA_Period = 200; // Long-term MA period
input int RSI_Period = 14; // RSI Period
input int MinConfluencePoints = 8; // Minimum points needed for signal
// Indicator handles
int rsi_handle;
//+------------------------------------------------------------------+
void OnInit()
{
rsi_handle = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE);
}
//+------------------------------------------------------------------+
void OnTick()
{
int confluencePoints = 0;
bool bullishTrend = false;
// Check 5min chart trend
double ma_short_5m_1 = iMA(NULL, PERIOD_M5, ShortMA_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
double ma_short_5m_2 = iMA(NULL, PERIOD_M5, ShortMA_Period, 0, MODE_EMA, PRICE_CLOSE, 2);
// Check 1hr chart trend
double ma_mid_1h_1 = iMA(NULL, PERIOD_H1, MidMA_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
double ma_mid_1h_2 = iMA(NULL, PERIOD_H1, MidMA_Period, 0, MODE_EMA, PRICE_CLOSE, 2);
// Check 4hr chart trend
double ma_long_4h_1 = iMA(NULL, PERIOD_H4, LongMA_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
double ma_long_4h_2 = iMA(NULL, PERIOD_H4, LongMA_Period, 0, MODE_EMA, PRICE_CLOSE, 2);
// Check Daily chart trend
double ma_long_d1_1 = iMA(NULL, PERIOD_D1, LongMA_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
double ma_long_d1_2 = iMA(NULL, PERIOD_D1, LongMA_Period, 0, MODE_EMA, PRICE_CLOSE, 2);
// Additional indicators
double rsi = iRSI(NULL, PERIOD_M5, RSI_Period, PRICE_CLOSE, 1);
double macd_main = iMACD(NULL, PERIOD_M5, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
double macd_signal = iMACD(NULL, PERIOD_M5, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
// Count confluence points for bullish trend
if(ma_short_5m_1 > ma_short_5m_2) confluencePoints++;
if(ma_mid_1h_1 > ma_mid_1h_2) confluencePoints++;
if(ma_long_4h_1 > ma_long_4h_2) confluencePoints++;
if(ma_long_d1_1 > ma_long_d1_2) confluencePoints++;
if(rsi > 50) confluencePoints++;
if(macd_main > macd_signal) confluencePoints++;
if(Close[1] > ma_short_5m_1) confluencePoints++;
if(Close[1] > ma_mid_1h_1) confluencePoints++;
if(Close[1] > ma_long_4h_1) confluencePoints++;
if(Close[1] > ma_long_d1_1) confluencePoints++;
// Create arrows based on confluence
if(confluencePoints >= MinConfluencePoints)
{
CreateArrow(Time[0], Low[0] - (10 * Point), 233, clrGreen, "BullArrow");
}
else if((10 - confluencePoints) >= MinConfluencePoints)
{
CreateArrow(Time[0], High[0] + (10 * Point), 234, clrRed, "BearArrow");
}
}
//+------------------------------------------------------------------+
void CreateArrow(datetime time, double price, int code, color clr, string name)
{
string arrowName = name + TimeToString(time);
if(ObjectFind(0, arrowName) < 0)
{
ObjectCreate(0, arrowName, OBJ_ARROW, 0, time, price);
ObjectSetInteger(0, arrowName, OBJPROP_ARROWCODE, code);
ObjectSetInteger(0, arrowName, OBJPROP_COLOR, clr);
ObjectSetInteger(0, arrowName, OBJPROP_WIDTH, 2);
}
}