Author: Copyright � 2005, Amir
XO_A_H

This tool is designed to visualize price movement trends by identifying significant shifts in momentum based on specific price "breaks." Rather than following every minor fluctuation, the script filters out market noise to highlight instances where the price moves aggressively enough to establish a new direction.

How the Logic Works

The core logic operates like a series of "threshold gates." It tracks the current price and compares it against a user-defined boundary (the "BoxSize"). Here is the step-by-step breakdown of how it processes market data:

  • Trend Tracking: The script monitors the closing price of each bar. It keeps a running memory of the high and low points reached during the current trend.
  • Breakout Detection:
    • Upward Momentum: If the current price climbs above the previous high by a specific distance (the BoxSize), the tool registers this as a positive breakout. It then resets its "floor" to the new price level and prepares to track further upward movement.
    • Downward Momentum: Conversely, if the price drops below the previous low by that same distance, it registers a negative breakout. It then resets its "ceiling" to the new price level to track the downward progression.
  • Counter System: The tool uses a scoring system to differentiate between these movements:
    • When an upward breakout occurs, it increments an "Up" counter.
    • When a downward breakout occurs, it increments a "Down" counter (displayed as a negative value).
    • If a new move happens in the opposite direction of the previous one, the system resets the opposing counter to zero.

Visual Representation

The results are displayed in a separate window below your main chart as a histogram:

  • Green Histogram: This represents the cumulative strength of upward breakouts. A rising green bar indicates that price is making consecutive successful moves toward the upside.
  • Red Histogram: This represents the cumulative strength of downward breakouts. Because it is calculated as a negative value, it points downward, showing the strength of the bearish momentum.

Summary for the User

Essentially, this script tells you how many times the price has "broken out" in one direction compared to the other over a specific period. It helps you see which side of the market currently holds the most momentum by ignoring small price jitters and only reacting when the price moves significantly enough to be considered a trend change.

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

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- 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("XO_A_H");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   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;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments