StochTxt(komposter)
Download scriptThis tool is a technical analysis indicator designed for the MetaTrader platform to help traders identify potential entry points in the financial markets. It focuses on spotting specific momentum shifts by monitoring the interaction between price movements and "overbought" or "oversold" conditions.
Core Functional Logic
The script operates by constantly scanning the historical data of a currency pair or asset to detect two specific types of market signals:
1. Buy Signals (Oversold Reversal) The logic looks for moments when the price momentum has dropped significantly low. It identifies a "Buy" opportunity when the momentum indicator crosses upward past a specific threshold (defined by the user). When this happens, the script automatically places a visual marker on the chart at a level slightly below the current price to signal a potential upward move.
2. Sell Signals (Overbought Reversal) Conversely, the logic monitors for moments when the market becomes excessively "hot" or overextended in an upward direction. When the momentum indicator crosses downward from a high threshold, the script places a visual marker slightly above the current price to signal a potential downward move.
Visual and Interactive Features
The script is designed to be highly customizable and informative for the user through several key features:
- Dynamic Chart Markers: Instead of just providing numbers, it draws physical arrows on your chart. These arrows appear automatically at the exact moment the technical conditions are met, making it easier to see trends at a glance.
- Optional Text Labels: The script can be configured to display specific text labels alongside the markers. These labels provide extra context by displaying the closing price and the exact time of the signal directly on the chart.
- Smart Positioning: To ensure the visual markers don't clutter the actual price candles, the script calculates a "buffer zone" (based on market volatility). This ensures that the arrows and text are placed at a clean, readable distance from the price line.
- Real-Time Alerts: For traders who cannot watch the screen constantly, the script includes an alert system. It can send a pop-up notification to your computer whenever a new Buy or Sell signal is detected, ensuring you don't miss a trade while away from the monitor.
Summary of User Experience
Essentially, this script acts as a "scout." It does the heavy lifting of constantly calculating complex momentum averages and volatility math in the background. When it finds a specific pattern that suggests a price reversal, it alerts you visually on your screen and sends a notification to your desktop, highlighting exactly where and when a potential trade might occur.
//+------------------------------------------------------------------+
//| iStochTxt(komposter).mq4 |
//| Copyright © 2006, komposter |
//| mailto:komposterius@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, komposter"
#property link "mailto:komposterius@mail.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1
//----
extern int k = 5;
extern int s = 1;
extern int l = 50;
extern bool text = false;
extern color text_color = Yellow;
extern bool alert = false;
//----
double BuyBuffer[], SellBuffer[];
int pre_signal = 0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("iStochTxt");
//----
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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
if(text)
{
for(int i = 0; i < ObjectsTotal(); i++)
{
if(StringFind( ObjectName(i), "txt_", 0 ) == 0)
{
ObjectDelete(ObjectName(i));
i--;
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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 mc = iStochastic(NULL, 0, k, 3, s, 0, 0, MODE_MAIN, i);
double mp = iStochastic(NULL, 0, k, 3, s, 0, 0, MODE_MAIN, i+1);
//----
if(mc > l && mp <= l)
{
BuyBuffer[i] = Low[i] - iATR(NULL, 0, 14, i);
if(text)
{
create_text(i, Low[i] - 1.5*iATR(NULL, 0, 14, i ));
}
}
if(mc < 100-l && mp >= 100-l)
{
SellBuffer[i] = High[i] + iATR(NULL, 0, 14, i);
if(text)
{
create_text(i, High[i] + 1.5*iATR( NULL, 0, 14, i));
}
}
}
if(alert)
{
if(pre_signal <= 0 && BuyBuffer [1] != EMPTY_VALUE)
{
Alert("iStochTxt( ", Symbol(), ", ", Period(), " ) - BUY!");
pre_signal = 1;
}
if(pre_signal >= 0 && SellBuffer[1] != EMPTY_VALUE)
{
Alert("iStochTxt( ", Symbol(), ", ", Period(), " ) - SELL!");
pre_signal = -1;
}
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void create_text(int u, double p)
{
string name = "txt_" + Time[u];
ObjectDelete(name);
ObjectCreate(name, OBJ_TEXT, 0, Time[u], p);
ObjectSetText(name, DoubleToStr( Close[u], Digits ) + " " + TimeToStr( Time[u],
TIME_MINUTES), 8, "Arial", text_color);
}
//+------------------------------------------------------------------+
Comments