SpreadIndicator
Download scriptThis tool is designed to provide traders with a real-time, visual readout of the "Spread" directly on their trading charts. In simple terms, it acts as a live information ticker that monitors and displays the cost of entering a trade at any given moment.
How it Works
The script operates by constantly communicating with the market data feed to retrieve the current spread—which is the difference between the купить (bid) and продать (ask) prices. Because these prices fluctuate every millisecond, the script is programmed to refresh this information automatically as new data arrives.
Key Features & Functionality
- Real-Time Monitoring: The tool continuously scans the live market data for the specific symbol you are currently viewing. It doesn't require manual refreshing; it updates the information dynamically.
- On-Chart Visualization: Instead of forcing you to look at the "Market Watch" window or other external tabs, the script places a clear text label directly on your main chart area. This allows you to keep your eyes on the price action while staying aware of trading costs.
- Dynamic Labeling: The script automatically formats the data into a readable string (e.g., "Spread: X points"). It ensures the number is rounded clearly so that it is easy to read at a glance during fast-moving market conditions.
- Automatic Management: The tool handles its own lifecycle on the chart. When you activate it, it creates the display label in a specific corner of your screen; when you remove the tool, it automatically cleans up and deletes the label to keep your chart tidy.
Why This Is Useful
For many traders, knowing the exact spread is crucial for calculating potential profit margins and avoiding "slippage" or high-cost entries during volatile periods. By placing this information front and center on your workspace, the script helps you make faster, more informed decisions without needing to navigate away from your primary analysis view.
//+------------------------------------------------------------------+
//| SpreadIndikator.mq4 |
//| Copyright © 2010 MeinMetatrader.de |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010 MeinMetatrader.de"
#property link ""
#property indicator_chart_window
//#property indicator_buffers 0
extern color LabelColor = Red;
#define OBJ_NAME "SpreadIndikatorObj"
int init()
{
ShowSpread();
}
int start()
{
ShowSpread();
}
int deinit()
{
ObjectDelete(OBJ_NAME);
}
void ShowSpread()
{
static double spread;
spread = MarketInfo(Symbol(), MODE_SPREAD);
DrawSpreadOnChart(spread);
}
void DrawSpreadOnChart(double spread)
{
string s = "Spread: "+DoubleToStr(spread, 0)+" points";
if(ObjectFind(OBJ_NAME) < 0)
{
ObjectCreate(OBJ_NAME, OBJ_LABEL, 0, 0, 0);
ObjectSet(OBJ_NAME, OBJPROP_CORNER, 0);
ObjectSet(OBJ_NAME, OBJPROP_YDISTANCE, 12);
ObjectSet(OBJ_NAME, OBJPROP_XDISTANCE, 3);
ObjectSetText(OBJ_NAME, s, 10, "FixedSys", LabelColor);
}
ObjectSetText(OBJ_NAME, s);
WindowRedraw();
}
Comments