This script is designed as a visual trading tool for the MetaTrader platform, specifically crafted to identify potential momentum shifts and trend signals on a price chart. Instead of drawing continuous lines, it functions by placing specific markers (arrows) at key points to highlight moments where market sentiment may be shifting between bullish and bearish states.
How the Logic Works
The script operates by analyzing the underlying "power" of the market—essentially measuring the strength of buyers versus the strength of sellers over a specific period. Here is a breakdown of its operational logic:
1. Data Processing The tool looks back at a specific number of historical bars (adjustable by the user) to calculate a combined value based on both "Bulls Power" and "Bears Power." By combining these two metrics, the script attempts to gauge the overall momentum of the currency or asset being traded.
2. Threshold Detection The logic identifies significant market activity by looking for values that exceed specific positive or negative thresholds.
- Bearish Signals: When the calculated power falls below a certain negative threshold, the script recognizes it as a sign of downward pressure. In response, it places a magenta marker above the high price of the candle.
- Bullish Signals: Conversely, when the power rises above a specific positive threshold, it identifies upward momentum and places an aqua marker below the low price of the candle.
3. Visual Presentation The primary goal of this script is "conversion"—taking complex mathematical data regarding market power and converting it into simple visual cues. By placing these arrows on the chart, the tool allows a trader to quickly see where the momentum might be favoring a move in one direction or the other without having to manually calculate the strength of the bulls and bears.
Key Customizations
The script includes several "input parameters" that allow users to fine-tune how sensitive the logic is:
- Risk Factor: Adjusts the calculation base for the momentum readings.
- SSP (Smoothing Period): Determines the timeframe over which the market power is averaged.
- Count Bars: Controls how much historical data the script scans to generate signals on your screen.
//+------------------------------------------------------------------+
//| BykovTrend_Sig.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Aqua
//---- input parameters
extern int RISK=3;
extern int SSP=9;
extern int CountBars=500;
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,159);
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
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=iBearsPower(NULL, 0, 5,PRICE_TYPICAL,i)+iBullsPower(NULL, 0, 5,PRICE_TYPICAL,i);
val1[i]=0.0; val2[i]=0.0;
if (wpr<(-0.0035)) {val1[i]=High[i]+15*Point;}
if (wpr>0.0035) {val2[i]=Low[i]-15*Point;}
//if ((! uptrend==old) && uptrend==true) {val2[i]=Low[i]-15*Point;}
//if ((! uptrend==old) && uptrend==false) {val1[i]=High[i]+15*Point;}
old=uptrend;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments