spread_swap_v1

Download script
Author: Copyright � 2007, MetaQuotes Software Corp.

This script functions as a real-time data dashboard for MetaTrader users who need to keep a close eye on specific transaction costs and market pricing. Instead of forcing you to dig through various menus or tabs to find essential figures, it consolidates three critical pieces of information into a single, easy-to-read display window.

Core Functionality

The script automatically identifies and tracks the following data points for the specific currency pair or asset you are currently viewing:

  • Market Spread: It captures the current difference between the buy and sell prices (the "spread"), which represents the immediate cost of entering a trade.
  • Swap Rates: It retrieves the overnight financing costs for both long (buying) and short (selling) positions. These figures help traders understand the carrying costs of holding a position open past the market close.
  • Live Bid/Ask Prices: It displays the current "Bid" (the price at which you can sell) and "Ask" (the price at which you can buy) prices in real-time.

User Interface and Experience

The logic is designed to provide a clean, organized visual summary rather than just a list of numbers. Here is how the information is presented:

  • Dynamic Labeling: The script automatically names itself based on the current symbol (e.g., "spread/swap monitor EURUSD"), making it clear which asset you are looking at.
  • Color-Coded Organization: To ensure quick readability, the data is organized into a linear layout with distinct colors:
    • Swap Information: Clearly differentiates between "Buy Swap" and "Sell Swap" using green and red text labels to prevent confusion during high-pressure trading moments.
    • Bid/Ask Differentiation: The final section of the display highlights the live Bid price in Red and the Ask price in Blue, following standard market conventions for immediate visual recognition.
  • Auto-Updating Display: The script continuously refreshes these values as the market moves, ensuring that the data on your screen is always synchronized with the current live market conditions.

In short, this tool acts as a dedicated "heads-up display" (HUD) for traders, providing a snapshot of execution costs and financing rates in one convenient location.

9 Views
0 Downloads
0 Favorites
spread_swap_v1
//+------------------------------------------------------------------+
//|                                                  spread swap.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_separate_window
//----
double    swaplong,swapshort;
int spread;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  int init()
  {
   IndicatorShortName("spread/swap monitor ("+Symbol()+")");
//----
  return(0);}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
   {
      return(0);
   }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   spread=MarketInfo(Symbol(),13);
   swaplong=NormalizeDouble(MarketInfo(Symbol(),18),2);
   swapshort=NormalizeDouble(MarketInfo(Symbol(),19),2);
//----
   ObjectCreate("spread/swap monitor1", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor1","Current Spread:", 9, "Tahoma", White);
   ObjectSet("spread/swap monitor", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor1", OBJPROP_XDISTANCE, 155);
   ObjectSet("spread/swap monitor1", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor2", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor2",DoubleToStr(spread ,0),9, "Tahoma", Black);
   ObjectSet("spread/swap monitor2", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor2", OBJPROP_XDISTANCE, 250);
   ObjectSet("spread/swap monitor2", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor3", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor3","Buy Swap:", 9, "Tahoma", Green);
   ObjectSet("spread/swap monitor3", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor3", OBJPROP_XDISTANCE, 275);
   ObjectSet("spread/swap monitor3", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor4", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor4",DoubleToStr( swaplong ,2),9, "Tahoma", Black);
   ObjectSet("spread/swap monitor4", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor4", OBJPROP_XDISTANCE, 345);
   ObjectSet("spread/swap monitor4", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor5", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor5","Sell Swap:", 9, "Tahoma", Red);
   ObjectSet("spread/swap monitor5", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor5", OBJPROP_XDISTANCE, 380);
   ObjectSet("spread/swap monitor5", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor6", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor6",DoubleToStr( swapshort ,2),9, "Tahoma", Black);
   ObjectSet("spread/swap monitor6", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor6", OBJPROP_XDISTANCE, 445);
   ObjectSet("spread/swap monitor6", OBJPROP_YDISTANCE, 2);
//----
//----
   ObjectCreate("spread/swap monitor7", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor7","Bid/Ask:", 9, "Tahoma", Black);
   ObjectSet("spread/swap monitor7", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor7", OBJPROP_XDISTANCE, 505);
   ObjectSet("spread/swap monitor7", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor8", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor8",DoubleToStr(Bid ,5),9, "Tahoma", Red);
   ObjectSet("spread/swap monitor8", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor8", OBJPROP_XDISTANCE, 555);
   ObjectSet("spread/swap monitor8", OBJPROP_YDISTANCE, 3);
//----
   ObjectCreate("spread/swap monitor9", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor9",DoubleToStr(Ask ,5),9, "Tahoma", Blue);
   ObjectSet("spread/swap monitor9", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor9", OBJPROP_XDISTANCE, 555);
   ObjectSet("spread/swap monitor9", OBJPROP_YDISTANCE, 15);

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

Comments