stoch_only
Download scriptThis tool is designed as a visual technical indicator for the MetaTrader trading platform. It functions by analyzing price momentum through three distinct layers of data to identify specific "overbought" and "oversold" conditions on a chart.
How the Logic Works
The core mechanism of this script relies on the Stochastic Oscillator, a common tool used by traders to determine if an asset is being traded at an extreme high or low relative to its recent price action. Instead of relying on just one setting, this indicator uses a multi-layered approach:
1. Triple-Layer Filtering The script monitors three different time-based periods simultaneously:
- A very long-term period (providing the "big picture" trend).
- A medium-term period (identifying intermediate momentum).
- A short-term period (capturing immediate price fluctuations).
For a signal to appear, all three of these layers must agree with one another. This multi-layered check helps filter out "noise" and ensures that the signals are backed by various levels of market momentum.
2. Identifying Entry Signals The script looks for two specific scenarios:
- Buy Opportunities (Oversold): The tool scans for moments when all three stochastic layers fall below a specific "low zone." When the entire market structure suggests the price has dropped significantly enough to be considered undervalued, the script places a visual marker below the candle.
- Sell Opportunities (Overbought): Conversely, it looks for moments when all three stochastic layers rise above a specific "high zone." When the data indicates that the price has reached an extreme peak relative to its recent movement, the script places a visual marker above the candle.
3. Dynamic Placement To ensure that the visual markers do not overlap with the actual price candles or other chart elements, the script calculates the distance of the arrows dynamically. It uses a volatility measurement (ATR) to determine how much space to leave between the price bar and the signal icon, ensuring the display remains clean and readable regardless of how volatile the market is at that moment.
Summary for the User
In simple terms, this indicator acts as a "consensus seeker." It waits for long-term, medium-term, and short-term momentum indicators to all point toward an extreme price level before highlighting a potential turning point on your chart with clear red and blue markers.
//+------------------------------------------------------------------+
//| Stoch_Only.mq4 |
//| Copyright © 2015-2016, assurkov, Alexey Surkov |
//| http://www.assurkov.ru/ |
//+------------------------------------------------------------------+
#property strict
#property copyright "Copyright © 2015-2016, www.assurkov.ru, Alexey Surkov"
#property link "http://www.assurkov.ru/"
#property version "1.00"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_width1 1
#property indicator_width2 1
input int ST_Period1 =700;
input int ST_Period2 =120;
input int ST_Period3 =30;
input int ST_Zone1 =10;
input int ST_Zone2 =10;
input int ST_Zone3 =5;
double BuyBuffer[],SellBuffer[];
bool counter=false;
string TimeFrame;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Stoch_Only");
SetIndexBuffer(0,BuyBuffer);
SetIndexLabel(0,"Buy");
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
SetIndexArrow(0,241);
SetIndexBuffer(1,SellBuffer);
SetIndexLabel(1,"Sell");
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
SetIndexArrow(1,242);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if(counted_bars<0)
{
Print("Indicator Error (Counted bars < 0)!");
return(-1);
}
//----
if(Bars<17)
{
Print("Indicator Error (Bars < 12)!");
return(-1);
}
int limit=Bars-17;
//----
if(counted_bars>17)
{
limit=Bars-counted_bars;
}
//----
for(int i=limit; i>=0; i --)
{
BuyBuffer[i]=EMPTY_VALUE;
SellBuffer[i]=EMPTY_VALUE;
double ST1=iStochastic(Symbol(),Period(),ST_Period1,3,3,MODE_SMA,1,MODE_MAIN,i);
double ST2=iStochastic(Symbol(),Period(),ST_Period2,3,3,MODE_SMA,1,MODE_MAIN,i);
double ST3=iStochastic(Symbol(),Period(),ST_Period3,3,3,MODE_SMA,1,MODE_MAIN,i);
if(ST1<ST_Zone1 && ST2<ST_Zone2 && ST3<ST_Zone3)
{
BuyBuffer[i]=Low[i]-iATR(NULL,0,14,i);
}
if(ST1>(100-ST_Zone1) && ST2>(100-ST_Zone2) && ST3>(100-ST_Zone3))
{
SellBuffer[i]=High[i]+iATR(NULL,0,14,i);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments