spread_on_chart

Download script
Author: Copyright � 2010, Forexometer
spread_on_chart

This script is a visual dashboard tool designed for MetaTrader users to provide real-time information regarding trading costs and restrictions directly on their main price chart. Instead of requiring the user to navigate through complex menus or data windows, it pulls three specific pieces of market data and displays them as clean, easy-to-read text labels.

Core Functionality

The tool focuses on three key metrics that every trader needs to monitor to ensure they can execute orders correctly:

  • Spread: This shows the difference between the buying and selling price for the current asset. Knowing the spread helps traders understand the immediate cost of entering or exiting a position.
  • Stop Level: This informs you of the minimum distance required between your current market price and where you are allowed to place "Stop" orders (such as Stop Loss or Take Profit).
  • Freeze Level: This indicates the minimum distance from the current price where the broker will temporarily prevent any new orders from being placed, usually occurring during periods of high volatility.

Visual Customization

The script is designed to be non-intrusive and fully adjustable to suit your specific workspace layout. It includes several user-friendly settings:

  • Positioning: You can choose which corner of the screen the information should appear in (Upper Left, Upper Right, Lower Left, or Lower Right).
  • Spacing: There are dedicated margins to ensure the text doesn't sit too close to the edge of your screen.
  • Typography: Users can customize the appearance of the data by selecting a specific font, color, and text size, ensuring the information is visible but doesn't clutter the actual price action.

How it Works

When you load this script onto a chart, it automatically creates three separate labels. Every time the market moves, the script instantly refreshes these labels with the most recent data from your broker. When you remove the script from the chart, it automatically cleans up and deletes the labels, leaving your workspace exactly as it was found.

6 Views
0 Downloads
0 Favorites
spread_on_chart
//+------------------------------------------------------------------+
//|                                              spread_on_chart.mq4 |
//|                                    Copyright © 2010, Forexometer |
//|                                       http://www.forexometer.com |
//|                                           master@forexometer.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Forexometer"
#property link      "http://www.forexometer.com"

#property indicator_chart_window

extern string  _1="// --- Place settings ---";
extern int     Corner=0;
extern string  Corner_tips="// 0 - upper left, 1 - upper right, 2 - lower left, 3 - lower right";
extern int     XMargin=7;
extern int     YMargin=12;
extern string  _2="// --- Font settings ---";
extern string  Font="Arial";
extern color   Color=DarkOrange;
extern int     Size=8;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   if((Corner==1 || Corner==3) && XMargin<1)  XMargin=1;
   if(XMargin<0)  XMargin=0;

   if(Corner>1 && YMargin<1)  YMargin=1;
   if(YMargin<0)  YMargin=0;

   ObjectCreate("spread",     OBJ_LABEL, 0, 0, 0);
   ObjectSet(   "spread",     OBJPROP_CORNER,   Corner);
   ObjectSet(   "spread",     OBJPROP_XDISTANCE,XMargin);
   ObjectSet(   "spread",     OBJPROP_YDISTANCE,YMargin);
   
   ObjectCreate("stoplevel",  OBJ_LABEL, 0, 0, 0);
   ObjectSet(   "stoplevel",  OBJPROP_CORNER,   Corner);
   ObjectSet(   "stoplevel",  OBJPROP_XDISTANCE,XMargin);
   ObjectSet(   "stoplevel",  OBJPROP_YDISTANCE,YMargin+1.5*Size);
   
   ObjectCreate("freezelevel",OBJ_LABEL, 0, 0, 0);
   ObjectSet(   "freezelevel",OBJPROP_CORNER,   Corner);
   ObjectSet(   "freezelevel",OBJPROP_XDISTANCE,XMargin);
   ObjectSet(   "freezelevel",OBJPROP_YDISTANCE,YMargin+3*Size);

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectDelete("spread");
   ObjectDelete("stoplevel");
   ObjectDelete("freezelevel");

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   ObjectSetText("spread",     "spread = "      +DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD),1),     Size,Font,Color);
   ObjectSetText("stoplevel",  "stop level = "  +DoubleToStr(MarketInfo(Symbol(),MODE_STOPLEVEL),1),  Size,Font,Color);
   ObjectSetText("freezelevel","freeze level = "+DoubleToStr(MarketInfo(Symbol(),MODE_FREEZELEVEL),1),Size,Font,Color);

   return(0);
}
//+------------------------------------------------------------------+

Comments