spread swap

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

This tool is designed to function as a real-time visual dashboard for traders who need to keep a close eye on specific market costs while monitoring their active positions. Rather than making you dig through complex menus or data tabs, it pulls three critical pieces of information directly from the market feed and displays them clearly on your trading screen in an organized, easy-to-read format.

How it Works

The script automatically connects to the current financial instrument you are trading and retrieves three specific types of data:

  • The Spread: It captures the "Spread," which is the difference between the buying and selling price of a currency or asset. This helps you understand the immediate cost of entering or exiting a trade at that exact second.
  • Buy Swap Rates: It identifies the overnight interest rate (swap) applied when you hold a long (buy) position.
  • Sell Swap Rates: It simultaneously identifies the swap rate for short (sell) positions.

Visual Experience

Once activated, the script creates a dedicated monitoring window on your platform. It organizes these three data points into a horizontal display with distinct visual cues:

  1. Current Spread: Displayed in gold text, providing an instant look at the current market liquidity and entry costs.
  2. Buy Swap Details: Located in the middle section and highlighted in blue, this shows you exactly what the "holding cost" will be if you are betting on the price going up.
  3. Sell Swap Details: Located on the right side and highlighted in red, this clearly shows the holding cost for positions where you are betting on the price going down.

By aggregating these values into a single, color-coded dashboard, the tool allows you to monitor both the immediate "gate" costs (Spread) and the long-term "holding" costs (Swaps) simultaneously without cluttering your main workspace.

13 Views
0 Downloads
0 Favorites
spread swap
//+------------------------------------------------------------------+
//|                                                  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, "Arial Black", Gold);
        ObjectSet("spread/swap monitor", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor1", OBJPROP_XDISTANCE, 200);
        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, "Arial Black", Gold);
        ObjectSet("spread/swap monitor2", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor2", OBJPROP_XDISTANCE, 320);
        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, "Arial Black", Blue);
        ObjectSet("spread/swap monitor3", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor3", OBJPROP_XDISTANCE, 470);
        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, "Arial Black", Blue);
        ObjectSet("spread/swap monitor4", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor4", OBJPROP_XDISTANCE, 550);
        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, "Arial Black", Red);
        ObjectSet("spread/swap monitor5", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor5", OBJPROP_XDISTANCE, 660);
        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, "Arial Black", Red);
        ObjectSet("spread/swap monitor6", OBJPROP_CORNER, 0);
        ObjectSet("spread/swap monitor6", OBJPROP_XDISTANCE, 740);
        ObjectSet("spread/swap monitor6", OBJPROP_YDISTANCE, 2);
        

   return(0);
  }

Comments