I_XO_A_H_002

Download script
Author: Copyright � 2005, Amir
I_XO_A_H_002

This tool is designed to analyze price movement trends by identifying specific "breakout" behaviors in the market. Instead of simply looking at whether a price is going up or down, it monitors the intensity and consistency of price shifts relative to a predefined distance.

How the Logic Works

The script operates by establishing a "boundary zone" based on a user-defined size (the BoxSize). It continuously tracks the most recent significant price points to determine if the market is making new progress in a specific direction.

1. Detecting Upward Momentum When the current price moves significantly higher than the previous recorded high—specifically by more than the defined "BoxSize"—the script recognizes this as a positive breakout. It increments an upward counter, signaling that the momentum is trending toward the top of the range.

2. Detecting Downward Momentum Conversely, if the price drops significantly below the previous recorded low by more than the "BoxSize," the script identifies a downward breakout. In this scenario, it triggers a downward counter, indicating a shift in sentiment toward the bottom of the range.

3. Tracking Trend Strength The logic is designed to be cumulative. By tracking these consecutive breakouts, the tool provides a visual representation of trend strength:

  • Upward Trends: Represented by increasing values as the price breaks higher targets.
  • Downward Trends: Represented by increasingly negative values as the price breaks lower targets.

Visual Representation

The script translates these mathematical calculations into a visual histogram displayed in a separate window below your main chart:

  • Blue Bars: These highlight the accumulation of upward momentum.
  • Red Bars: These highlight the accumulation of downward momentum.

By observing these bars, you can quickly see not just which way the price is moving, but how aggressively it is breaking through previous levels. The tool even includes an on-screen text alert that changes color and message to provide a quick status update on the current dominant trend.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
I_XO_A_H_002
//+------------------------------------------------------------------+
//|                                                         Amir.mq4 |
//|                                           Copyright © 2005, Amir |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Amir"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 3
#property indicator_width2 3

//---- input parameters
extern int       BoxSize=15;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
   int Cur=0;
   int KirUp=0;
   int KirDn=0;
   int kr=0;
   int no=0;
   double valueh=0;
   double valuel=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"XOUP");
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"XODOWN");
   IndicatorShortName("I-XO-A-H");
   
   ObjectCreate("I-XO-A-H", OBJ_LABEL, 0, 0, 0);
   ObjectSet   ("I-XO-A-H", OBJPROP_CORNER, 1); 
   ObjectSet   ("I-XO-A-H", OBJPROP_XDISTANCE, 50 ); 
   ObjectSet   ("I-XO-A-H", OBJPROP_YDISTANCE, 80);   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   ObjectDelete("I-XO-A-H");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int CurrentBar;
   double Hi,Lo,Curb;
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here

   //----Calculation---------------------------
   for(int i=0;i<=Bars;i++)
   {
      CurrentBar = Bars-i;
      if (Cur<1)
      {
         Hi=Close[CurrentBar];
         Lo=Close[CurrentBar];
         Cur=1;
      }
      Curb=Close[CurrentBar];
      if (Curb>(Hi+BoxSize*Point))
      {
         Cur+=1;
         Hi=Curb;
         Lo=Curb-BoxSize*Point;
         KirUp=1;
         KirDn=0;
         kr+=1;
         no=0;   
      }
      if (Curb<(Lo-BoxSize*Point))
      {
         Cur+=1;
         Lo=Curb;
         Hi=Curb+BoxSize*Point;
         KirUp=0;
         KirDn=1;
         no+=1;
         kr=0;
      }
      valueh=kr;
      valuel=0-no;
      ExtMapBuffer1[CurrentBar]=valueh;
      ExtMapBuffer2[CurrentBar]=valuel;
   }
   
   if (ExtMapBuffer1[0]>0){
   ObjectSetText("I-XO-A-H","I-XO-A-H:  ¡ü",10,"Arial",Yellow);
   }
   else if (ExtMapBuffer2[0]<0){
   ObjectSetText("I-XO-A-H","I-XO-A-H:  ¡ý",10,"Arial",Red);
   }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments