This script is designed as a comprehensive technical analysis tool for MetaTrader 4, functioning as an automated "signal scanner." Its primary goal is to filter out market noise by requiring multiple independent trading indicators to agree before providing a visual cue on the chart.
Core Logic Overview
Rather than relying on a single piece of data, the script evaluates eight different technical metrics simultaneously. It looks for a "confluence" of signals, meaning it only triggers a buy or sell marker when all (or specific selected) conditions align in the same direction.
The logic processes the following components:
- Momentum & Trend Strength: It monitors the Stochastic Oscillator, RSI (Relative Strength Index), and ADX to determine if the market is gaining speed and in which direction it is moving.
- Trend Dynamics: It utilizes MACD and Rate of Change (ROC) to identify the underlying momentum and price velocity.
- Volatility & Price Action: It uses Bollinger Bands to check where the current price sits relative to its standard deviation, alongside Bears/Bulls power indicators to measure the strength of the respective market participants.
- Dynamic Range Calculation: The script automatically calculates a "Range" based on the high and low prices of recent candles. This allows it to plot the visual arrows at a mathematically consistent distance above or below the current price, ensuring they don't overlap with the candles.
Signal Execution
The script performs two distinct checks:
- The Bullish Signal (CrossUp): If all conditions indicate upward pressure—such as the RSI being above a specific level, the MACD showing positive momentum, and the price breaking above moving averages—the script places a visual marker below the candle.
- The Bearish Signal (CrossDown): Conversely, if the indicators align to show downward pressure—such as the RSI dropping below its threshold and the ADX indicating a negative trend—the script places a marker above the candle.
User Customization & Alerts
The logic is highly modular. It allows the user to choose whether the script must wait for a "crossover" (a specific moment where an indicator flips from one state to another) or if it simply needs to see that the indicator is currently in a favorable zone.
Additionally, the script includes a real-time notification system. When a new valid signal is detected on the current live candle, it triggers an audible and visual alert, providing the trader with the exact time of the occurrence without requiring them to constantly watch the screen.
//+------------------------------------------------------------------+
//| vForce Like Indy.mq4 |
//| Copyright © 2008, TradingSytemForex |
//| http://www.tradingsystemforex.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, TradingSytemForex"
#property link "http://www.tradingsystemforex.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 OrangeRed
double CrossUp[];
double CrossDown[];
double prevtime;
double Range, AvgRange;
double LimeRmonow, LimeRmoprevious;
double GoldRmonow, GoldRmoprevious;
extern int StochKPeriod = 5;
extern int StochDPeriod = 3;
extern int StochSlowing = 3;
extern bool OnlyAtStochSignal=false;
extern int RSIPeriod = 14;
extern int RSILevel = 50;
extern bool OnlyAtRSISignal=false;
extern int ADXPeriod = 14;
extern bool OnlyAtADXSignal=false;
extern int BearsPeriod = 13;
extern bool OnlyAtBearsSignal=false;
extern int BullsPeriod = 13;
extern bool OnlyAtBullsSignal=false;
extern int MACDFast = 12;
extern int MACDSlow = 26;
extern int MACDSMA = 9;
extern bool OnlyAtMacdSignal=false;
extern int RPeriod = 10;
extern bool OnlyAtROCSignal=false;
extern int BBPeriod = 20;
extern bool OnlyAtBBSignal=false;
extern int SoundAlert = 0; //0=disabled
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY, 2);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 2);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Deinitialization |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Iteration |
//+------------------------------------------------------------------+
int start()
{
int limit, i, counter;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = 1; i <= limit; i++)
{
counter=i;
Range=0;
AvgRange=0;
for(counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
double StoMa=iStochastic(NULL,0,StochKPeriod,StochDPeriod,StochSlowing,MODE_SMA,0,MODE_MAIN,i+1);
double StoSa=iStochastic(NULL,0,StochKPeriod,StochDPeriod,StochSlowing,MODE_SMA,0,MODE_SIGNAL,i+1);
double StoM=iStochastic(NULL,0,StochKPeriod,StochDPeriod,StochSlowing,MODE_SMA,0,MODE_MAIN,i);
double StoS=iStochastic(NULL,0,StochKPeriod,StochDPeriod,StochSlowing,MODE_SMA,0,MODE_SIGNAL,i);
double RSIa=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);
double RSI=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);
double ADXPa=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_PLUSDI,i+1);
double ADXMa=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MINUSDI,i+1);
double ADXP=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_PLUSDI,i);
double ADXM=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MINUSDI,i);
double Bearsa=iBearsPower(NULL,0,BearsPeriod,PRICE_CLOSE,i+1);
double Bullsa=iBullsPower(NULL,0,BullsPeriod,PRICE_CLOSE,i+1);
double Bears=iBearsPower(NULL,0,BearsPeriod,PRICE_CLOSE,i);
double Bulls=iBullsPower(NULL,0,BullsPeriod,PRICE_CLOSE,i);
double MacdMa=iMACD(NULL,0,MACDFast,MACDSlow,MACDSMA,PRICE_CLOSE,MODE_MAIN,i+1);
double MacdSa=iMACD(NULL,0,MACDFast,MACDSlow,MACDSMA,PRICE_CLOSE,MODE_SIGNAL,i+1);
double MacdM=iMACD(NULL,0,MACDFast,MACDSlow,MACDSMA,PRICE_CLOSE,MODE_MAIN,i);
double MacdS=iMACD(NULL,0,MACDFast,MACDSlow,MACDSMA,PRICE_CLOSE,MODE_SIGNAL,i);
double CurrentClosea=iClose(NULL,0,i+RPeriod);
double PrevClosea=iClose(NULL,0,i+RPeriod+RPeriod);
double ROCa=CurrentClosea-PrevClosea;
double CurrentClose=iClose(NULL,0,i);
double PrevClose=iClose(NULL,0,i+RPeriod);
double ROC=CurrentClose-PrevClose;
double BBandsa=iMA(Symbol(),0,BBPeriod,0,MODE_SMA,PRICE_CLOSE,i+1);
double BBands=iMA(Symbol(),0,BBPeriod,0,MODE_SMA,PRICE_CLOSE,i);
if(((OnlyAtStochSignal==false && StoM>StoS) || (OnlyAtStochSignal && StoMa<StoSa && StoM>StoS ))
&& ((OnlyAtRSISignal==false && RSI>RSILevel) || (OnlyAtRSISignal && RSIa<RSILevel && RSI>RSILevel ))
&& ((OnlyAtADXSignal==false && ADXP>ADXM) || (OnlyAtADXSignal && ADXPa<ADXMa && ADXP>ADXM ))
&& ((OnlyAtBearsSignal==false && Bears>0) || (OnlyAtBearsSignal && Bearsa<0 && Bears>0 ))
&& ((OnlyAtBullsSignal==false && Bulls>0) || (OnlyAtBullsSignal && Bullsa<0 && Bulls>0 ))
&& ((OnlyAtMacdSignal==false && MacdM>MacdS) || (OnlyAtMacdSignal && MacdMa<MacdSa && MacdM>MacdS ))
&& ((OnlyAtROCSignal==false && ROC>0) || (OnlyAtROCSignal && ROCa<0 && ROC>0 ))
&& ((OnlyAtBBSignal==false && Close[i]>BBands) || (OnlyAtBBSignal && Close[i+1]<BBandsa && Close[i]>BBands )))
{
CrossUp[i] = Low[i] - Range*1.5;
}
if(((OnlyAtStochSignal==false && StoM>StoS) || (OnlyAtStochSignal && StoMa>StoSa && StoM<StoS ))
&& ((OnlyAtRSISignal==false && RSI<RSILevel) || (OnlyAtRSISignal && RSIa>RSILevel && RSI<RSILevel ))
&& ((OnlyAtADXSignal==false && ADXP<ADXM) || (OnlyAtADXSignal && ADXPa>ADXMa && ADXP<ADXM ))
&& ((OnlyAtBearsSignal==false && Bears<0) || (OnlyAtBearsSignal && Bearsa>0 && Bears<0 ))
&& ((OnlyAtBullsSignal==false && Bulls<0) || (OnlyAtBullsSignal && Bullsa>0 && Bulls<0 ))
&& ((OnlyAtMacdSignal==false && MacdM<MacdS) || (OnlyAtMacdSignal && MacdMa>MacdSa && MacdM<MacdS ))
&& ((OnlyAtROCSignal==false && ROC<0) || (OnlyAtROCSignal && ROCa>0 && ROC<0 ))
&& ((OnlyAtBBSignal==false && Close[i]<BBands) || (OnlyAtBBSignal && Close[i+1]>BBandsa && Close[i]<BBands )))
{
CrossDown[i] = High[i] + Range*1.5;
}
}
if((CrossUp[0] > 2000) && (CrossDown[0] > 2000)) { prevtime = 0; }
if((CrossUp[0] == Low[0] - Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," vForce Like Indy Up @ Hour ",Hour()," Minute ",Minute());
}
if((CrossDown[0] == High[0] + Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," vForce Like Indy Down @ Hour ",Hour()," Minute ",Minute());
}
return(0);
}
Comments