Itrend Old_v2

Download script
Author: Andrew
Itrend Old_v2

This technical indicator is designed to provide traders with a visual representation of market trends by monitoring the relationship between current price action and specific volatility boundaries. Rather than showing raw price data, it translates complex market movements into a simplified dual-histogram display in a separate window on your trading platform.

Core Logic Overview

The script functions by analyzing two distinct types of market data simultaneously to determine "trend strength." It processes historical price information starting from the oldest available data point up to the current live candle.

1. Price Boundary Analysis The indicator first calculates a dynamic boundary using a Bollinger Band methodology. By comparing the current price against these boundaries, the script determines the price's position relative to the "normal" trading range.

  • If the price is consistently pushing above or moving outside these specific calculated boundaries, the script identifies a positive trend signal.
  • The result is normalized into a binary state (0 or 1), which feeds into the first part of the visual histogram.

2. Momentum and Power Measurement Simultaneously, the indicator calculates market "Power" by looking at the intensity of buying and selling pressure over a specific period. It aggregates these forces to determine how much momentum is backing the current price movement.

  • This calculation considers various price types (such as Highs, Lows, or Close prices) depending on the user's settings.
  • The script then creates a secondary signal that reflects whether the prevailing power is shifting in favor of one direction or the other, again normalizing this into a simplified value for the second histogram.

Visual Representation and Output

The final output is presented as two colored histograms:

  • The First Histogram (Blue): Represents the price position relative to its volatility bands. It highlights when the price is successfully breaking out of standard range patterns.
  • The Second Histogram (Red): Represents the cumulative power of the market participants.

Coordination Logic

A key feature of this script is how it handles conflicting signals. The logic includes a "Median Value" check. If both the price position and the market power signals align in the same direction, it reinforces the trend signal. However, if the signals conflict—meaning the price is moving in one direction while the underlying momentum power suggests another—the script recognizes this as a potential discrepancy or "neutral" zone, effectively alerting the user that the current trend may be unstable or lack sufficient conviction.

Indicators Used
Bollinger bands indicatorBears Power indicatorBulls Power indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Itrend Old_v2
//+------------------------------------------------------------------+
//|                                           Traditional Itrend.mq4 |
//|                                             TREND INDICATOR      |
//|                                                                  |
//|                                           Conversion: Dr. Gaines |
//|                                  dr_richard_gaines@yahoo.com     |
//|                                                                  |
//+------------------------------------------------------------------+
/*
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 
*/
#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                                        |
//+------------------------------------------------------------------+
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                                                              |
//+------------------------------------------------------------------+
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;
//----
   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