Hi-Lo_v1

Overview

The Hi-Lo indicator is designed to provide visual signals on a trading chart by identifying specific price movements based on moving averages. Its primary purpose is to highlight potential trend shifts or momentum changes by marking entry/exit points using distinct visual symbols (arrows).

Core Logic & Functionality

1. Data Foundation The script operates by analyzing two different types of moving averages simultaneously:

  • One is calculated based on the High prices of the candles.
  • The other is calculated based on the Low prices of the candles. By focusing on both the peaks and the valleys of price action, the indicator gains a broader perspective of the market's volatility compared to using standard closing prices alone.

2. Signal Detection Mechanism The logic determines when to place an arrow on the chart by comparing the current closing price against these moving average boundaries:

  • Bullish Sentiment: The script looks for instances where the price breaks above the high-price moving average.
  • Bearish Sentiment: The script looks for instances where the price falls below the low-price moving average.

3. State Management (The "Toggle" System) A key feature of this logic is its ability to track previous states. It doesn't just signal every time a price touches a line; it monitors the transition between "True" and "False" states. This ensures that once a direction is established, the indicator remains consistent until a confirmed reversal occurs in the opposite direction. This helps filter out minor market noise and focuses on significant shifts in price behavior.

4. Visual Output When the logic identifies a specific condition:

  • It places an arrow slightly above or below the price action to ensure clarity.
  • The two different colors (Tomato and Cornsilk) serve to differentiate between upward and downward signals, making it easy for a trader to see at a glance whether the script is suggesting a bullish or bearish move.

Summary for the User

Think of this tool as a "boundary watcher." It establishes a dynamic "ceiling" and "floor" based on recent price history. When the market price breaks through these boundaries in a specific way, the indicator triggers an arrow to alert you that the trend may be changing or continuing in a new direction.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
Hi-Lo_v1
//+------------------------------------------------------------------+
//|                                                        Hi-Lo.mq4 |
//|                                                                  |
//|                                        Ramdass - Conversion only |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Tomato
#property indicator_color2 Cornsilk
//---- input parameters
extern int Per=2;
extern int CountBars=300;
//---- buffers
double Up[];
double Down[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Down);
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Hi-Lo                                                         |
//+------------------------------------------------------------------+
int start()
  {
   SetIndexDrawBegin(0,Bars-CountBars+Per);
   SetIndexDrawBegin(1,Bars-CountBars+Per);
   int i,counted_bars=IndicatorCounted();
   bool Pr=false, PrevPr=false;
   double val,val2;
//----
   if(CountBars<=Per) return(0);
//---- initial zero
   if(counted_bars<1)
   {
      for(i=1;i<=Per;i++) Up[CountBars-i]=0.0;
      for(i=1;i<=Per;i++) Down[CountBars-i]=0.0;
   }
//----
   i=CountBars-Per-1;
//   if(counted_bars>=CCIPeriod1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      val=iMA(NULL,0,Per,1,MODE_SMA,PRICE_HIGH,i);
      val2=iMA(NULL,0,Per,1,MODE_SMA,PRICE_LOW,i);

if (Close[i]<val2 && PrevPr==true) Pr=false;   
if (Close[i]>val && PrevPr==false) Pr=true;
PrevPr=Pr;   
Up[i]=0.0; Down[i]=0.0;
if (Pr==false) Up[i] = val+2*Point; 
if (Pr==true) Down[i] = val2-2*Point;

      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments