Disp_Ask_Bid_01
Download scriptThis tool is a visual display indicator designed for the MetaTrader trading platform. Its primary purpose is to provide a clear, real-time snapshot of the current market prices directly on your trading chart.
Core Functionality
The script automatically identifies and tracks two critical pieces of market data:
- The Ask Price: The price at which you can buy the asset.
- The Bid Price: The price at which you can sell the asset.
Instead of requiring you to look at the standard price quotes in the platform's sidebar or top header, this script pulls those values automatically and displays them as a single, combined text string on your main chart area (e.g., "Price A - Price B").
Key Features & Customization
The logic allows for several visual adjustments to ensure the information fits perfectly with your personal trading layout:
- Text Formatting: You can customize the size of the numbers and choose a specific color (such as white or any other preferred shade) to make sure the prices are easy to read against your chosen background.
- Positioning: The script includes settings to adjust the horizontal and vertical distance from the corners of your screen. This ensures the price display doesn't overlap with your candles, trendlines, or other technical indicators.
- Alignment: There is an option to toggle the orientation of the display between the left and right sides of the chart, allowing for maximum flexibility based on how you organize your workspace.
How it Operates
Every time the market updates, the script refreshes the data. It captures the most recent Ask and Bid values, formats them into a clean text string, and updates the visual label on your screen instantly. When you remove the indicator from your chart, the script is designed to automatically clear these labels to keep your workspace tidy.
//*****************************************************************************
// Disp_Ask_Bid_01.mq4 2011-06-22
//
// This code display ask-bid value.
// indicator
// Create by artsurf
//*****************************************************************************
#property indicator_chart_window
extern int word_size = 14;
extern color word_color = White;
extern bool right_left = false;
extern int x_distance = 5;
extern int y_distance = 15;
//-----------------------------------------------------------------------------
int init(){
return(0);
}
//-----------------------------------------------------------------------------
int deinit(){
ObjectsDeleteAll(0, OBJ_LABEL);
return(0);
}
//-----------------------------------------------------------------------------
int start(){
string disp_price;
double ask_price = MarketInfo(Symbol(), MODE_ASK);
double bid_price = MarketInfo(Symbol(), MODE_BID);
disp_price = StringConcatenate(DoubleToStr(ask_price, Digits)," - ",DoubleToStr(bid_price, Digits));
ObjectCreate("word", OBJ_LABEL, 0, 0, 0);
ObjectSetText("word", disp_price, word_size, "Arial", word_color);
ObjectSet("word", OBJPROP_CORNER, right_left);
ObjectSet("word", OBJPROP_XDISTANCE, x_distance);
ObjectSet("word", OBJPROP_YDISTANCE, y_distance);
return(0);
}
Comments