BykovTrend_Sig_v1
Download scriptThis tool is designed to act as a visual signaling system on your trading charts, helping to identify potential shifts in market momentum and trend direction. Instead of providing a constant line that follows price, it focuses on specific "turning points" by analyzing historical price data over a set period.
How the Logic Works
The script operates by monitoring a technical oscillator (the Williams Percent Range) which measures the relationship between the high, low, and closing prices of an asset. It uses this data to determine the prevailing market "mood."
1. Trend Detection The system constantly looks at where the current price action sits relative to its recent history. It categorizes the market into two states:
- Uptrend: When the momentum moves above a specific threshold (calculated based on your risk settings), the system recognizes a bullish bias.
- Downtrend: When the momentum drops below a corresponding lower boundary, the system recognizes a bearish bias.
2. Signal Generation The core logic is designed to ignore the "noise" of minor price fluctuations. It only triggers a visual signal at the exact moment the market shifts from one state to another.
- Buy Signals: When the momentum switches from bearish to bullish, the script places a specific visual marker (a blue arrow) below the current candle's low price.
- Sell Signals: When the momentum switches from bullish to bearish, the script places a different visual marker (a magenta arrow) above the current candle's high price.
Key Features for the User
- Visual Clarity: By using arrows instead of continuous lines, the tool keeps your chart clean and highlights only the specific moments where a trend change is detected.
- Customizable Sensitivity: The logic allows you to adjust the "Lookback" period (how much history the script considers) and the "Risk" factor. Increasing these values will make the script less sensitive (filtering out more small movements), while decreasing them will make the script react more quickly to minor price changes.
- Historical Analysis: The script calculates these signals over a significant number of past bars, allowing you to see how accurately it identified previous trend reversals during different market conditions.
//+------------------------------------------------------------------+
//| BykovTrend_Sig.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 DodgerBlue
#property indicator_width1 2
#property indicator_width2 2
extern int RISK=-15;
extern int SSP=9;
extern int CountBars=500;
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW,0,2);
SetIndexArrow(0,234);
SetIndexStyle(1,DRAW_ARROW,0,2);
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=30-RISK;
//----
if(Bars<=SSP+1) return(0);
//---- initial zero
if(counted_bars<SSP+1)
{
for(i=1;i<=0;i++) val1[CountBars-i]=0.0;
for(i=1;i<=0;i++) val2[CountBars-i]=0.0;
}
//----
i=CountBars-SSP-1;
if(counted_bars>=SSP+1) i=CountBars-counted_bars-1;
while(i>=0)
{
wpr=iWPR(NULL,0,SSP,i);
//val1[i]=0.0; val2[i]=0.0;
val1[i]=EMPTY; val2[i]=EMPTY;
if (wpr<-100+K) uptrend=false;
if (wpr>-K) uptrend=true;
if ((! uptrend==old) && uptrend==true) {val2[i]=Low[i]-5*Point;}
if ((! uptrend==old) && uptrend==false) {val1[i]=High[i]+5*Point;}
old=uptrend;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments