StatMonitor
Download scriptThis script is a specialized monitoring tool designed to provide traders with real-time visibility into critical market costs directly on their trading platform. Instead of requiring you to dig through complex menus or technical settings to find specific data points, it gathers this information automatically and displays it in a clean, easy-to-read dashboard format.
How It Works
The tool functions as a live "Stat Monitor." Every time the market updates, the script performs the following actions:
-
Data Retrieval: It automatically communicates with the broker's server to fetch three specific pieces of information for the currency pair or asset you are currently viewing:
- The Spread: The difference between the buy and sell price.
- The Buy Swap: The cost/interest rate associated with holding a "Long" position (buying).
- The Sell Swap: The cost/interest rate associated with holding a "Short" position (selling).
-
Dynamic Formatting: To ensure the data is useful and accurate, the script cleans up the raw numbers provided by the broker (rounding them to a standard two-decimal format) so they are easy to interpret at a glance.
-
Visual Display: The script creates a dedicated text window on your screen. It organizes the information into a horizontal layout with clear labels and color-coding:
- Current Spread is highlighted in a distinct blue tone.
- Buy Swap values are highlighted in Green, making it easy to identify "Long" costs.
- Sell Swap values are highlighted in Red, clearly marking "Short" costs.
Key Benefits for the User
This script eliminates the need for manual calculation or constant navigation between windows. By placing the Spread and Swap rates directly on your chart area, it allows you to monitor overnight carrying costs and transaction overhead instantly, helping you make more informed decisions about your trading positions in real-time.
//+------------------------------------------------------------------+
//| SwapMon |
//| Lowphat © 2006 |
//| Format hijacked from cja |
//+------------------------------------------------------------------+
#property copyright "Lowphat © 2006"
#property link "mystikvgv@yahoo.com (mail only)"
#property indicator_separate_window
double swaplong,swapshort;
int spread;
int init(){
IndicatorShortName("Stat 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("Stat Monitor1", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor1","Current Spread:", 14, "Arial Bold", CadetBlue);
ObjectSet("Stat Monitor1", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor1", OBJPROP_XDISTANCE, 150);
ObjectSet("Stat Monitor1", OBJPROP_YDISTANCE, 2);
ObjectCreate("Stat Monitor2", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor2",DoubleToStr(spread ,0),14, "Arial Bold", CadetBlue);
ObjectSet("Stat Monitor2", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor2", OBJPROP_XDISTANCE, 295);
ObjectSet("Stat Monitor2", OBJPROP_YDISTANCE, 2);
ObjectCreate("Stat Monitor3", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor3","Buy Swap:", 14, "Arial Bold", Lime);
ObjectSet("Stat Monitor3", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor3", OBJPROP_XDISTANCE, 350);
ObjectSet("Stat Monitor3", OBJPROP_YDISTANCE, 2);
ObjectCreate("Stat Monitor4", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor4",DoubleToStr( swaplong ,2),14, "Arial Bold", Lime);
ObjectSet("Stat Monitor4", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor4", OBJPROP_XDISTANCE, 450);
ObjectSet("Stat Monitor4", OBJPROP_YDISTANCE, 2);
ObjectCreate("Stat Monitor5", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor5","Sell Swap:", 14, "Arial Bold", Red);
ObjectSet("Stat Monitor5", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor5", OBJPROP_XDISTANCE, 550);
ObjectSet("Stat Monitor5", OBJPROP_YDISTANCE, 2);
ObjectCreate("Stat Monitor6", OBJ_LABEL, WindowFind("Stat Monitor ("+Symbol()+")"), 0, 0);
ObjectSetText("Stat Monitor6",DoubleToStr( swapshort ,2),14, "Arial Bold", Red);
ObjectSet("Stat Monitor6", OBJPROP_CORNER, 0);
ObjectSet("Stat Monitor6", OBJPROP_XDISTANCE, 650);
ObjectSet("Stat Monitor6", OBJPROP_YDISTANCE, 2);
return(0);
}
Comments