BykovTrend_Sig_byRENAAT_Alert
Download scriptThis script is designed as a visual trend-following indicator for the MetaTrader platform. It functions by analyzing price momentum to identify specific "turning points" in the market, providing traders with clear visual signals on whether the current trend is shifting toward an upward (Buy) or downward (Sell) direction.
Core Logic and Functionality
Trend Detection Mechanism The core of this tool relies on a momentum oscillator. It calculates the relationship between current prices and historical price ranges over a specific period (defined by the user as "SSP"). By monitoring these fluctuations, the script determines the strength and direction of the market's movement.
Signal Identification Instead of showing a constant line, the script looks for a definitive change in the state of the market:
- Buy Signals: When the momentum moves from a bearish state into a confirmed bullish threshold, the script identifies a "Buy" opportunity. It then places a visual marker (an arrow) just below the price candles.
- Sell Signals: When the momentum drops from a bullish state into a confirmed bearish threshold, the script identifies a "Sell" opportunity. It places a visual marker (an arrow) just above the price candles.
Key Features for the User
- Visual Alerts: The script automatically plots arrows on your chart to highlight entry points, making it easy to see historical trend changes at a glance.
- Real-Time Notifications: To ensure traders don't miss active moves, the script includes an automated alert system. When a new signal is detected at the close of a candle, the platform will trigger:
- An audible sound notification.
- A pop-up text alert on your screen displaying the current price (Bid/Ask) and the specific currency pair.
- Customizable Sensitivity: The logic includes several adjustable parameters that allow users to define how "aggressive" or "conservative" the signals are, including the look-back period for momentum and the risk threshold for signal confirmation.
How it behaves on a chart
The indicator scans a set number of historical bars (defaulting to 500) to ensure accuracy. It filters out minor market noise to focus only on significant trend reversals. When the market switches from "Down" to "Up," a signal is triggered; once that state is established, no further signals are shown until the trend reverses again.
//+------------------------------------------------------------------+
//| BykovTrend_Sig.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Magenta
//---- input parameters
extern int RISK=3;
extern int SSP=9;
extern int CountBars=500;
extern bool SoundAlert=true;
extern bool TextAlert=true;
//---- buffers
double val1[];
double val2[];
string Dir = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,234);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,233);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| BykovTrend_Sig |
//+------------------------------------------------------------------+
int start()
{
SetIndexDrawBegin(0,Bars-CountBars+SSP+1);
SetIndexDrawBegin(1,Bars-CountBars+SSP+1);
int i,counted_bars=IndicatorCounted();
int K;
bool uptrend,old;
double wpr;
K=33-RISK;
//----
if(Bars<=SSP+1) return(0);
//---- initial zero
for(i=0;i<CountBars;i++) val1[i]=0.0;
for(i=0;i<CountBars;i++) val2[i]=0.0;
//----
i=CountBars-1;
while(i>=0)
{
wpr=iWPR(NULL,0,SSP,i);
val1[i]=0.0; val2[i]=0.0;
if (wpr<-100+K) uptrend=false;
if (wpr>-K) uptrend=true;
if ((! uptrend==old) && uptrend==true)
{
val2[i]=Low[i]-5*Point;
if (i < 2)
{
Dir="BUY";
UpAlert(Dir);
}
}
if ((! uptrend==old) && uptrend==false)
{
val1[i]=High[i]+5*Point;
if (i < 2)
{
Dir="SELL";
DownAlert(Dir);
}
}
old=uptrend;
i--;
}
return(0);
}//+------------------------------------------------------------------+
void UpAlert(string Dir)
{
if (!NewBar() || !SoundAlert)
return;
if(TextAlert==true)Alert("BUY at Ask ",Ask," ",Symbol()," - ",Period());
PlaySound ("alert2.wav");
}
void DownAlert(string Dir)
{
if (!NewBar() || !SoundAlert)
return;
if(TextAlert==true)Alert("SELL at Bid ",Bid," ",Symbol()," - ",Period());
PlaySound ("alert2.wav");
}
bool NewBar()
{
static datetime dt = 0;
if (dt != Time[0])
{
dt = Time[0];
return(true);
}
}
Comments