Finding Strong Trend with 7 Indicators

[Deleted]  

Hello, 

I am trying to find a stronger trend. I am using 

MA + ADX(DI) + MACD + Momentum + Bulls/Bears Power + ATR + Ichimoku Cloud

This is the ultimate system, combining:

  • ✔ Trend Structure (MA)

  • ✔ Trend Direction (DI)

  • ✔ Trend Strength (ADX)

  • ✔ Momentum (Momentum)

  • ✔ Momentum (MACD)

  • ✔ Buying/Selling Pressure (Bulls/Bears)

  • ✔ Volatility Support (ATR)

  • Market Structure & Future Trend (Ichimoku)

I am trying something like this :


#property strict

extern int  MinVotesForTrend = 4     // Required confirmations
extern bool Use_MA            = true;
extern bool Use_ADX           = true;
extern bool Use_DI            = true;
extern bool Use_MACD          = true;
extern bool Use_Momentum      = true;
extern bool Use_Power         = true;
extern bool Use_ATR           = true;
extern bool Use_Ichimoku      = true;

//------------------------------------------------------------------
// 1. MA Trend
//------------------------------------------------------------------
int Trend_MA()
{
   double ema  = iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,0);
   double ema1 = iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,1);
   double price = Close[0];

   if (price > ema && ema > ema1) return 1;
   if (price < ema && ema < ema1) return -1;
   return 0;
}

//------------------------------------------------------------------
// 2. ADX Trend (strength direction)
//------------------------------------------------------------------
int Trend_ADX()
{
   double adx  = iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,0);
   double adx1 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,1);

   if (adx > adx1) return 1;   // strengthening trend
   if (adx < adx1) return -1;  // trend weakening
   return 0;
}

//------------------------------------------------------------------
// 3. DI Trend (direction)
//------------------------------------------------------------------
int Trend_DI()
{
   double plus  = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);
   double minus = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);

   if (plus > minus) return 1;
   if (minus > plus) return -1;
   return 0;
}

//------------------------------------------------------------------
// 4. MACD Trend
//------------------------------------------------------------------
int Trend_MACD()
{
   double main   = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
   double signal = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);

   if (main > signal) return 1;
   if (main < signal) return -1;
   return 0;
}

//------------------------------------------------------------------
// 5. Momentum Trend
//------------------------------------------------------------------
int Trend_Momentum()
{
   double m0 = iMomentum(NULL,0,14,PRICE_CLOSE,0);
   double m1 = iMomentum(NULL,0,14,PRICE_CLOSE,1);

   if (m0 > 100 && m0 > m1) return 1;
   if (m0 < 100 && m0 < m1) return -1;
   return 0;
}

//------------------------------------------------------------------
// 6. Bulls/Bears Power Trend
//------------------------------------------------------------------
int Trend_Power()
{
   double bulls = iBullsPower(NULL,0,13,PRICE_CLOSE,0);
   double bears = iBearsPower(NULL,0,13,PRICE_CLOSE,0);

   if (bulls > 0 && bears > -0.00001) return 1;
   if (bears < 0 && bulls < 0.00001)  return -1;
   return 0;
}

//------------------------------------------------------------------
// 7. ATR Trend (volatility direction)
//------------------------------------------------------------------
int Trend_ATR()
{
   double a0 = iATR(NULL,0,14,0);
   double a1 = iATR(NULL,0,14,1);

   if (a0 > a1) return 1;   // volatility expanding → trend strengthening
   if (a0 < a1) return -1;  // volatility shrinking → consolidation
   return 0;
}

//------------------------------------------------------------------
// 8. Ichimoku Cloud Trend
//------------------------------------------------------------------
int Trend_Ichimoku()
{
   double tenkan = iIchimoku(NULL,0,9,26,52,MODE_TENKANSEN,0);
   double kijun  = iIchimoku(NULL,0,9,26,52,MODE_KIJUNSEN,0);

   double sa = iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANA,0);
   double sb = iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANB,0);

   double price = Close[0];

   // Bullish
   if (price > sa && price > sb && tenkan > kijun)
      return 1;

   // Bearish
   if (price < sa && price < sb && tenkan < kijun)
      return -1;

   return 0;
}

//------------------------------------------------------------------
// Voting Engine (Final Trend Decision)
//------------------------------------------------------------------
int GetTrendFinal()
{
   int bull = 0, bear = 0;

   if (Use_MA)       { int r = Trend_MA();       if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_ADX)      { int r = Trend_ADX();      if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_DI)       { int r = Trend_DI();       if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_MACD)     { int r = Trend_MACD();     if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_Momentum) { int r = Trend_Momentum(); if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_Power)    { int r = Trend_Power();    if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_ATR)      { int r = Trend_ATR();      if (r==1) bull++; else if (r==-1) bear++; }
   if (Use_Ichimoku) { int r = Trend_Ichimoku(); if (r==1) bull++; else if (r==-1) bear++; }

   // Final Decision
   if (bull - bear >= MinVotesForTrend) return 1;
   if (bear - bull >= MinVotesForTrend) return -1;

   return 0; // no consensus
}

//------------------------------------------------------------------
// OnTick
//------------------------------------------------------------------
void OnTick()
{
   int trend = GetTrendFinal();

   if (trend == 1)
      Comment("TREND: STRONG UPTREND\nBull Votes: ", trend);
   else if (trend == -1)
      Comment("TREND: STRONG DOWNTREND\nBear Votes: ", trend);
   else
      Comment("NO TREND / NOT ENOUGH AGREEMENT");
}

I am using MinVotesForTrend for minimum indicator confirmation check and using it in final decision by subtracting. Is i am doing correct?, any suggestion to improve it?  

 
anuj71:

Hello, 

I am using MinVotesForTrend for minimum indicator confirmation check and using it in final decision by subtracting. Is i am doing correct?, any suggestion to improve it?  

Maybe replace the bool inputs with options to give different votes for each indicator? If they are 0 then that indicator is not counted? ie

extern MA_Votes = 1,

Macd_Votes = 2,

blah blah;

 
anuj71:


I am using MinVotesForTrend for minimum indicator confirmation check and using it in final decision by subtracting. Is i am doing correct?, any suggestion to improve it?  

Search ForexFactory for indicator Trendy. has more indicators in it and already coded similarly to what you have above.