This tool is designed to help traders visualize price momentum and identify potential turning points in the market. It functions by calculating and plotting two distinct lines—commonly referred to as K and D—which represent the relative strength of price movements over a specific period.
Core Functionality
The script works by analyzing historical price data to determine whether an asset is beingซื้อ heavily (overbought) or sold off aggressively (oversold). Instead of just looking at the price, it looks at the "speed" and "depth" of the movement, displaying this information in a separate window below your main trading chart.
Key Features and Logic:
1. Momentum Tracking (The Lines)
- The Main Line (K): This is the primary indicator that reacts quickly to price changes. It helps you see the immediate pulse of the market.
- The Signal Line (D): This line acts as a smoothed average of the K line. Because it moves more slowly, it helps filter out "noise" and provides a clearer picture of the underlying trend.
2. Automated Alerts for Overextended Markets The script monitors where the primary line sits relative to two specific thresholds:
- Overbought Alert: If the indicator rises above a set upper limit (typically 80), it suggests that the asset may have been bought too quickly and could be due for a price correction or pullback.
- Oversold Alert: If the indicator falls below a set lower limit (typically 20), it suggests that the asset may have been sold off aggressively and could be approaching a potential rebound.
3. Crossover Detection One of the most common ways traders use this logic is by watching for "crossings":
- Bullish Signal: When the fast-moving line (K) crosses from below to above the slower signal line (D), it can indicate that upward momentum is gaining strength.
- Bearish Signal: When the fast-moving line (K) crosses from above to below the slower signal line (D), it may indicate that downward pressure is increasing.
The script is programmed to detect these specific moments automatically and trigger an audible/visual alert on your platform, ensuring you don't have to watch the screen constantly to catch these shifts in momentum.
Customization
Users can adjust the "sensitivity" of these lines (via settings like K, D, and Slowing) to make the indicator react faster to volatile markets or more smoothly for longer-term trends. You can also toggle the alerts on or off depending on your personal trading style.
//+------------------------------------------------------------------+
//| Stochastic (with alert) |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_minimum 0
#property indicator_maximum 100
extern string ________General_______;
extern int K = 5;
extern int D = 3;
extern int Slowing = 3;
extern int MA_Mode = 0; // 0 = SMA, 1 = EMA,
extern int Shift_Bars=0;
extern int Bars_Count= 0;
extern string _________Alert________;
extern double Overbuy_Level = 80;
extern double Oversell_Level = 20;
extern bool Enable_Alert_1 = true;
extern double Crossover_Gap = 0;
extern bool Enable_Alert_2 = true;
//---- buffers
double v1[];
double v2[];
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(0,K+Slowing);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"K");
SetIndexStyle(1,DRAW_LINE,STYLE_DOT,1);
SetIndexDrawBegin(1,K+D+Slowing);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"D");
watermark();
return(0);
}
int start()
{
int i;
int shift;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
if (Bars_Count > 0 && Bars_Count <= Bars)
{
i = Bars_Count - counted_bars;
}else{
i = Bars - counted_bars;
}
while(i>=0)
{
shift = i + Shift_Bars;
v1[i] = iStochastic(Symbol(), Period(), K, D, Slowing, MA_Mode, 0, 0, shift);
v2[i] = iStochastic(Symbol(), Period(), K, D, Slowing, MA_Mode, 0, 1, shift);
Print(v1[i]);
i--;
}
// Alert: Overbuy and Oversold
static int OBOS;
if (Enable_Alert_1 && v1[0] >= Overbuy_Level && OBOS != 1)
{
OBOS = 1;
Alert("Stoch: Overbuy! Stoch K: ", v1[0]);
}else if (Enable_Alert_1 && v1[0] <= Oversell_Level && OBOS != -1){
OBOS = -1;
Alert("Stoch: Oversell! Stoch K: ", v1[0]);
}
// Alert crossover
static int Crossover;
if (Enable_Alert_2 && v1[1] < v2[0] + Crossover_Gap && v1[0] >= v2[0] + Crossover_Gap && Crossover != 1) {
Crossover = 1;
Alert("Stoch: K crosses above D! Trend: Bull");
}else if(Enable_Alert_2 && v1[1] > v2[0] - Crossover_Gap && v1[0] <= v2[0] - Crossover_Gap && Crossover != -1) {
Crossover = -1;
Alert("Stoch: K crosses below D! Trend: Bear");
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
Comments