Author: Ron T
st_ind_2x

This technical tool is designed to simplify market analysis by visually identifying specific momentum shifts based on price trends. Instead of requiring you to manually track every fluctuation in the market, the script automatically monitors the relationship between current prices and a smoothed average of those prices.

How the Logic Works

The core of this indicator relies on a Linear Weighted Moving Average (LWMA). Unlike a standard moving average that treats all recent price data equally, a weighted average gives more importance to the most recent price points. This makes the indicator more responsive to immediate market movements while still filtering out minor "noise."

The Tracking Process:

  1. Trend Analysis: The script constantly compares the current value of this moving average against its value from the previous candle.
  2. Directional Detection: It looks for a "crossover" or a change in direction:
    • If the moving average is moving upward (the current value is higher than the previous one), it signals a positive trend.
    • If the moving average is moving downward (the current value is lower than the previous one), it signals a negative trend.

Visual Output on Your Chart

To make these signals easy to read at a glance, the script places visual markers directly on your trading chart:

  • Trend Indicators: When the logic detects specific directional shifts in the moving average, it places large dots (markers) at key price levels.
  • Positioning: These dots appear either at the "Low" of a candle or the "High" of a candle, depending on whether the trend is moving up or down. This allows you to quickly identify where the momentum shifted in relation to the actual price action.

Key Takeaway for Traders

The primary goal of this script is to automate the identification of trend changes. By highlighting these points visually, it helps traders see where the momentum has shifted from bullish to bearish (or vice versa) without having to manually calculate moving averages or interpret complex charts.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
st_ind_2x
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                              |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.lightpatch.com"

#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 White
#property indicator_color2 Red


//---- buffers
double Buffer1[];
double Buffer2[];

// User Input
extern double MovingAvg=23;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 158 little dot
   // 168 open square
   // 120 box with X
   
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0, Buffer1);
   SetIndexArrow(0,159);  //big dot
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, Buffer2);
   SetIndexArrow(1,159);  //big dot

   return(0);
  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;
   
   for( i=0; i<Bars; i++ ) Buffer1[i]=0;
   for( i=0; i<Bars; i++ ) Buffer2[i]=0;

   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   int      pos=500; // leave room for moving average periods

   double   cMA=0, pMA=0;

   bool     found=false;
   bool    rising=false;
   bool   falling=false;
   bool    bought=false;
   bool      sold=false;
   
   int      cnt=0;
   int      err=0;
   
   // get 1 & 2 MA (avoid 0, as it's too noisy)
   // (possible mod - open of 0 and 1 has no noise)
   cMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_CLOSE, pos);
   pMA=iMA(Symbol(), 0, MovingAvg, 0, MODE_LWMA, PRICE_CLOSE, pos+1);

   if (pMA<=cMA) {Buffer1[pos]=Low[pos];}
   if (pMA>=cMA) {Buffer2[pos]=High[pos];}

   pos--;

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

Comments