ind2

This tool is designed to act as a visual guide on your trading charts, helping to identify potential shifts in market momentum by highlighting specific price action trends. Instead of cluttering your screen with constant lines, it uses distinct arrow markers to signal when the price is interacting with key moving averages.

How the Logic Works

The script operates by analyzing two specific types of averages based on the highest and lowest prices reached within a short, user-defined window (the "Period").

  1. Dynamic Boundary Tracking: The tool constantly calculates two invisible boundaries: one representing a ceiling based on recent highs and another representing a floor based on recent lows. These boundaries move fluidly with the market, adapting to current volatility.
  2. Trend Detection: The core logic monitors how the current closing price relates to these high and low boundaries. It looks for specific "breakout" moments:
    • When the price moves above the upper boundary, it registers a potential shift in upward momentum.
    • When the price drops below the lower boundary, it registers a potential shift in downward momentum.
  3. Signal Filtering: To ensure the signals are meaningful, the script uses a "state memory" system. It tracks whether the previous candle was in an up-trend or a down-trend. This prevents the tool from flickering between signals; it only places a marker when a definitive shift in direction occurs relative to the previous state.
  4. Visual Output: Once a trend shift is confirmed, the script places an arrow on your chart:
    • Upward Signals: These appear near the upper boundary when the price shows strength.
    • Downward Signals: These appear near the lower boundary when the price shows weakness.

Summary for the Trader

Essentially, this script filters out the "noise" of minor price fluctuations. It waits for the price to interact with its recent highs or lows and then marks the exact point where the momentum appears to flip. By looking at these arrows, you can more easily identify where the market is potentially transitioning from a period of selling pressure to buying pressure, or vice versa.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
ind2


#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