Author: ������� ������� (�) 2007
Sem Force

This tool is designed as a visual trend analysis indicator for trading platforms. Its primary purpose is to help traders identify the prevailing direction of the market by measuring the relationship between current price action and various moving averages.

Core Logic and Methodology

The script operates by analyzing the "strength" of a trend through the following logical steps:

1. Multi-Layered Trend Comparison Instead of looking at just one average, the tool calculates six different moving averages simultaneously. Each of these averages uses a different multiplier (increasing in size) based on your chosen period settings. The logic then compares the current closing price against all six of these averages.

2. Calculating the Trend Value The script assigns a "score" to every point on the chart:

  • If the current price is lower than an average, it adds to the downward momentum score.
  • If the current price is higher than an average, it subtracts from that score.
  • By aggregating these results across all six averages, the tool produces a normalized percentage value. This represents how strongly the price is pushing in one direction relative to the historical data provided by those moving averages.

3. Smoothing and Signaling To prevent the data from being too erratic or "noisy," the script applies a secondary smoothing layer (the Signal line). This creates a base trend line that follows the primary trend values but with less volatility, making it easier for a human observer to see the broader movement.

Visual Output and Interpretation

The indicator translates these complex calculations into three distinct visual components on your chart:

  • The Trend Value (Histogram/Line): This shows the raw momentum calculation derived from the six-average comparison.
  • Buy and Sell Signals: The script monitors the crossover between the primary trend value and the smoothed signal line.
    • When the trend value crosses above the signal line, it identifies a potential upward shift.
    • When the trend value crosses below the signal line, it identifies a potential downward shift.
  • Color Coding: The tool uses color-coded bars (Crimson and Lime Green) to highlight these active signals, providing a clear visual cue of when the momentum has shifted from one direction to another.

In summary, this script functions as a "momentum sentiment" gauge. It looks at where the price sits in relation to multiple layers of historical averages to determine if the current trend is dominant or reversing.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
Sem Force
//+------------------------------------------------------------------+
//|                                  Áîëüøàÿ Êîëëåêöèÿ Ñåìàôîðîâ.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ñåðãååâ Àëåêñåé (ñ) 2007"

#property indicator_separate_window
#property indicator_minimum -110
#property indicator_maximum  110
#property indicator_buffers 4
#property indicator_color1 Crimson
#property indicator_color2 LimeGreen
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1
#property indicator_width4 2
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_SOLID

extern int PeriodStep=10;			// Øàã ïåðèîäà ñêîëüçÿùèõ
extern int Slowing=3;					// Çàìåäëåíèå îñíîâíîé ëèíèè (ñèãíàëüíàÿ ëèíèÿ)
extern int CountBar=5000;			//ñêîëüêî áàðîâ ñ÷èòàòü
extern int Mode=MODE_SMA;			//0-sma, 1-ema, 2-smma, 3-lwma
extern int Price=PRICE_CLOSE;	//0-close, 1-open, 2-high, 3-low, 4-median, 5-typic, 6-wieight

//---- buffers
double Buy[];
double Sell[];
double buffer[];
double Signal[];

void init()
{
	SetIndexStyle(0,DRAW_HISTOGRAM);	SetIndexBuffer(0,Sell);
	SetIndexStyle(1,DRAW_HISTOGRAM);	SetIndexBuffer(1,Buy);
	SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,buffer); SetIndexLabel(2,"Value");
	SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,Signal); SetIndexLabel(3,"Signal");
	IndicatorShortName("Ñèëà òðåíäà ("+PeriodStep +","+Slowing+")");
	return(0);
}

void start()
{
	int value, i;
	int step=1; if (PeriodStep>1) step=PeriodStep;
	double x0, x1, x2, x3, x4, x5, x6;
	for (i=0; i<=CountBar; i++)
	{
		x0=Close[i];
		x1=iMA(NULL,0,1*step,0,Mode,Price,i);
		x2=iMA(NULL,0,2*step,0,Mode,Price,i);
		x3=iMA(NULL,0,3*step,0,Mode,Price,i);
		x4=iMA(NULL,0,4*step,0,Mode,Price,i);
		x5=iMA(NULL,0,5*step,0,Mode,Price,i);
		x6=iMA(NULL,0,6*step,0,Mode,Price,i);
		value=0;
		if (x1<x0) value++;
		if (x2<x0) value++;
		if (x3<x0) value++;
		if (x4<x0) value++;
		if (x5<x0) value++;
		if (x6<x0) value++;
		if (x1>x0) value--;
		if (x2>x0) value--;
		if (x3>x0) value--;
		if (x4>x0) value--;
		if (x5>x0) value--;
		if (x6>x0) value--;
		buffer[i]=100*value/6;
	}
	for (i=0; i<=CountBar; i++) Signal[i]=iMAOnArray(buffer,0,Slowing,0,Mode,i);

	bool b=false, s=false;
	for (i=CountBar-1; i>=0; i--) 
	{
		Buy[i]=0.0; Sell[i]=0.0;
		if (Signal[i]>buffer[i]) { Sell[i] = Signal[i]; b=false; s=true; } //ïðîäàåì
		else
			if (Signal[i]<buffer[i]) { Buy[i] = Signal[i]; b=true; s=false;}//ïîêóïàåì
			else 
			{
				if (b) Buy[i]=Signal[i];
				if (s) Sell[i]=Signal[i];
			}
	}
	
	return(0);
}

Comments