Itrend Old_v1

Download script
Author: Andrew
Itrend Old_v1

This script is designed as a visual trend indicator for the MetaTrader platform, providing traders with a clear representation of market momentum and price direction. It operates in a separate window below the main chart, using two distinct histogram colors (Blue and Red) to signal different market conditions.

Core Logic and Functionality

The tool functions by analyzing several layers of market data simultaneously to determine whether the current trend is bullish, bearish, or neutral. Here is a breakdown of how it processes that information:

1. Price Source Customization The indicator allows users to choose which specific price points the logic should "watch." Rather than relying solely on the closing price, you can configure the script to monitor opening prices, highs, lows, or various weighted averages (such as typical or median prices). This flexibility ensures that the trend detection can be adjusted to suit different trading styles.

2. Bollinger Band Analysis The logic utilizes a variation of Bollinger Bands to measure price deviation. By calculating the distance between the current market price and specific bands (Main, High, or Low), the script determines the strength of the move:

  • If the price exceeds a certain threshold relative to these bands, the indicator triggers a positive signal (represented in Blue).
  • This helps identify when a trend is gaining significant "stretch" or momentum.

3. Power Indicators (Bulls vs. Bears) In addition to band analysis, the script incorporates "Power" metrics that measure the relative strength of buying pressure versus selling pressure. It calculates the "Bulls Power" and "Bears Power" over a set period.

  • By combining these two metrics, the script can detect the dominance of one side of the market over the other.
  • A negative result in this calculation (indicating bearish dominance) triggers a corresponding signal on the histogram (represented in Red).

4. Signal Synthesis and State Management The indicator doesn't just show isolated signals; it synthesizes the information from both the band analysis and the power metrics to provide a cleaner output:

  • Bullish Signal: Occurs when the price dynamics confirm upward momentum.
  • Bearish Signal: Occurs when the power metrics confirm downward pressure.
  • Neutral State: The logic includes a "balancing" mechanism. If the script detects conflicting signals—where both bullish and bearish conditions are met simultaneously—it intelligently sets the value to zero (neutral), preventing false signals during choppy or undecided market phases.

Visual Summary for the Trader

When you look at the indicator on your chart:

  • Blue Histograms signify that the price dynamics and band positions are favoring an upward trend.
  • Red Histograms signify that the power metrics are favoring a downward trend.
  • The presence of both signals or a lack of clear dominance will result in no histogram display, helping you identify periods where the market lacks a clear direction.
Indicators Used
Bollinger bands indicatorBears Power indicatorBulls Power indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Itrend Old_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                           Traditional Itrend.mq4 |
//| TREND INDICATOR                                                  |
//|                                                                  |
//|                                           Conversion: Dr. Gaines |
//|                                  dr_richard_gaines@yahoo.com 
//|                                     |
//+------------------------------------------------------------------+

#property copyright " Andrew "
#property link      " http://anri.aney.ru/forex/ "

#property indicator_separate_window
#property indicator_color1 Blue
#property indicator_buffers 2
#property indicator_color2 Red
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double iBands_Mode_0_2 = 0;
extern double iPower_Price_0_6 = 0;
extern double iPrice_Type_0_3 = 0;
extern double iBands_Period = 20;
extern double iBands_Deviation = 2;
extern double iPower_Period = 14;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double value = 0;
double value2 = 0;
int CurrentBar = 0;
double Bands_Mode = 0;
double Power_Price = 0;
double CurrentPrice = 0;

/*[[ 
Name := iTrend 1.01 
Author := Andrew 
Link := http://anri.aney.ru/forex/ 
Notes := TREND INDICATOR 
Separate Window := YES 
First Color := blue 
First Draw Type := histogram 
First Symbol := 217 
Use Second Data := Yes 
Second Color := red 
Second Draw Type := histogram 
Second Symbol := 218 
]]*/ 
 // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH 
 // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED 
 // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW 
//20 
 
//13 
 

SetLoopCount(0); 
if( iBands_Mode_0_2 == 1 ) Bands_Mode=MODE_LOW 
; else if( iBands_Mode_0_2 == 2 ) Bands_Mode=MODE_HIGH 
; else Bands_Mode=MODE_MAIN; 

if( iPower_Price_0_6 == 1 ) Power_Price=PRICE_OPEN 
; else if( iPower_Price_0_6 == 2 ) Power_Price=PRICE_HIGH 
; else if( iPower_Price_0_6 == 3 ) Power_Price=PRICE_LOW 
; else if( iPower_Price_0_6 == 4 ) Power_Price=PRICE_MEDIAN 
; else if( iPower_Price_0_6 == 5 ) Power_Price=PRICE_TYPICAL 
; else if( iPower_Price_0_6 == 6 ) Power_Price=PRICE_WEIGHTED 
; else Power_Price=PRICE_CLOSE; 

for(CurrentBar=Bars+1;CurrentBar>=0 ;CurrentBar--){ 
if( iPrice_Type_0_3 == 1 ) CurrentPrice=Open[CurrentBar] 
; else if( iPrice_Type_0_3 == 2 ) CurrentPrice=High[CurrentBar] 
; else if( iPrice_Type_0_3 == 3 ) CurrentPrice=Low[CurrentBar] 
; else CurrentPrice=Close[CurrentBar]; 
value=CurrentPrice-iBands(NULL, 0, iBands_Period, iBands_Deviation, 0, PRICE_CLOSE, Bands_Mode, CurrentBar); 
if( value < 0 ) value = 0; 
if( value > 0 ) value = 1; 
SetIndexValue(CurrentBar, value); 
value2=-(iBearsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar)+iBullsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar)); 
if( value2 < 0 ) value2 = 0; 
if( value2 > 0 ) value2 = -1; 
SetIndexValue2(CurrentBar, value2); 
if( value == 1 ) GlobalVariableSet("MEDV",value); 
if( value2 == -1 ) GlobalVariableSet("MEDV",value); 
if( value2 == -1 && value == 1 ) GlobalVariableSet("MEDV",0); 
//SetGlobalVariable("BUK",value); 
} 


  return(0);
}

Comments