ASK+BID+SPREAD-INDI
Download scriptThis script is designed as an on-screen visual dashboard for MetaTrader users who need to monitor real-time market pricing and costs at a glance. Instead of having to look at the price labels or the Market Watch window constantly, this tool pulls live data and displays it directly onto your trading chart in a clear, customizable format.
Core Functionality
The script focuses on three primary pieces of information:
- The Spread: It calculates the difference between the "Bid" (the price at which you can sell) and the "Ask" (the price at which you can buy). This is a crucial metric for traders as it represents the transaction cost provided by the broker.
- Live Ask Price: The current price at which you can enter a buy position.
- Live Bid Price: The current price at which you can enter a sell position.
Smart Logic & Calculations
To ensure the information is accurate and easy to read, the script includes several intelligent features:
- Automatic Pip Scaling: Different brokers use different decimal places (e.g., some 3-digit forex pairs, others 5-digit). The script automatically detects these differences to ensure that the "Spread" value is calculated correctly based on your specific broker's settings.
- Normalization: There is an option to "normalize" the spread. This converts the raw numbers into traditional pips, making it much easier for human traders to interpret the cost quickly without having to do mental math.
- Dynamic Refreshing: The script constantly polls the market for new data. As soon as the price moves or the spread fluctuates, the labels on your screen update instantly to reflect the live market state.
Visual Customization
The tool is built to be non-intrusive and highly adjustable. Users can customize the following without changing any code:
- Visibility: You can toggle the Ask, Bid, and Spread information on or off independently. If you only care about the spread, you can hide the individual prices.
- Positioning: You can move the text around the screen (via corner selection and X/Y distance offsets) so that it does not overlap with your candles or other technical indicators.
- Styling: The script allows for specific adjustments to font size, font type, and colors (e.g., setting the Ask price to Green and the Bid price to Red) to match your personal trading layout.
Summary of Use
In short, this script acts as a real-time heads-up display. It streamlines your workflow by placing the most vital "entry" information directly on your active chart, ensuring you always know exactly what the current market cost is before you execute a trade.
#property copyright "Code modification - Copyright @ Mar, 2012, File45"
#property indicator_chart_window
// ASK+BID+SPREAD-INDI
// ++++++++++++++++++++++++++++++++ START OF DEFAULT OPTIONS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Spread
extern string SPREAD_OPTIONS;
extern color Spread_Color = DarkOrange;
extern int Spread_Font_Size = 13;
extern string Spread_Font_Type = "Verdana";
extern int Spread_Corner = 1;
extern int Spread_X_distance = 120;
extern int Spread_Y_distance = 15;
extern bool Spread_HIDE=false;
extern bool Spread_Normalize = false; //If true then spread normalized to traditional pips
//extern string _;
extern string ASK_BID_OPTIONS;
extern color Ask_Color = LimeGreen;
extern color Bid_Color = Red;
extern int Ask_Bid_Font_Size=13;
extern string Ask_Bid_Font_Type = "Verdana";
extern int Ask_Bid_Corner = 1;
extern int Ask_X_Distance = 20;
extern int Bid_X_Distance = 20;
extern int Ask_Y_Distance = 15;
extern int Bid_Y_Distance = 40;
extern bool Ask_HIDE = false;
extern bool Bid_HIDE = false;
extern bool Ask_Bid_HIDE = false;
// +++++++++++++++++++++++++++++++++++++ END OF DEFAULT OPTIONS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
double Pointx;
int x_digits = 0;
double divider = 1;
int init(){
//Spread: Check for 3 & 5 digit
if (Point == 0.00001) Pointx = 0.0001; //5 digits
else if (Point == 0.001) Pointx = 0.01; //3 digits
else Pointx = Point; //Normal
if ((Pointx > Point) && (Spread_Normalize==true))
{
divider = 10.0;
x_digits = 1;
}
double spread = MarketInfo(Symbol(), MODE_SPREAD);
return(0);
}
int deinit(){
// Spread: delets
ObjectDelete("Spread");
// Market: Ask - Bid deletes
ObjectDelete("Market_Bid_Label");
ObjectDelete("Market_Ask_Label");
return(0);
}
int start(){
// Spread: refresh
if(Spread_HIDE==false){
RefreshRates();
double spread = (Ask - Bid) / Point;
ObjectCreate("Spread",OBJ_LABEL,0,0,0);
ObjectSetText("Spread", " " + DoubleToStr(NormalizeDouble(spread / divider, 1), x_digits), Spread_Font_Size, Spread_Font_Type, Spread_Color);
ObjectCreate("Spread", OBJ_LABEL, 0,0,0 );
ObjectSet("Spread", OBJPROP_CORNER, Spread_Corner);
ObjectSet("Spread", OBJPROP_XDISTANCE, Spread_X_distance);
ObjectSet("Spread", OBJPROP_YDISTANCE, Spread_Y_distance);}
// Prcie: Ask
if(Ask_Bid_HIDE == false){
if(Ask_HIDE == false){
string Market_Ask = DoubleToStr(Ask, Digits);
ObjectCreate("Market_Ask_Label", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Market_Ask_Label", Market_Ask, Ask_Bid_Font_Size, Ask_Bid_Font_Type, Ask_Color);
ObjectSet("Market_Ask_Label", OBJPROP_CORNER, Ask_Bid_Corner);
ObjectSet("Market_Ask_Label", OBJPROP_XDISTANCE, Ask_X_Distance);
ObjectSet("Market_Ask_Label", OBJPROP_YDISTANCE, Ask_Y_Distance);}
// Price: Bid
if(Bid_HIDE == false){
string Market_Bid = DoubleToStr(Bid, Digits);
ObjectCreate("Market_Bid_Label", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Market_Bid_Label", Market_Bid, Ask_Bid_Font_Size, Ask_Bid_Font_Type, Bid_Color);
ObjectSet("Market_Bid_Label", OBJPROP_CORNER, Ask_Bid_Corner);
ObjectSet("Market_Bid_Label", OBJPROP_XDISTANCE, Bid_X_Distance);
ObjectSet("Market_Bid_Label", OBJPROP_YDISTANCE, Bid_Y_Distance);}}
return(0);
}
Comments