notonlyspread

Download script
Author: Fabrizio
notonlyspread

This tool is designed to provide traders with a real-time, visual summary of market "spread" and liquidity speed directly on their trading charts. In simple terms, it acts as a live dashboard that monitors how much it costs to enter or exit a trade and how fast the market is currently moving.

Core Functionality

The indicator focuses on four primary metrics to help you gauge market conditions at a glance:

  • Instant Spread: This shows you the current cost of trading—the difference between the buy and sell prices—at this exact moment.
  • EMA Average: Rather than just showing a single number, the tool calculates a "Moving Average" of the spread. This helps you understand if the current spread is normal or unusually high compared to recent activity.
  • Highs and Lows (Max/Min): The script tracks the highest and lowest spreads reached during your current viewing session. This allows you to see the extreme boundaries of trading costs, helping you identify periods of high volatility or low liquidity.
  • Market Speed (Ticks per Minute): This calculates how many price updates (ticks) are occurring. It translates this into a "speed" reading, allowing you to see how active the market is. A high number indicates fast-moving activity, while a low number suggests a quieter, slower market.

How it Works

The script operates using two simultaneous methods to ensure accuracy:

  1. Continuous Tracking: Every time the price moves (a "tick"), the tool updates its memory of the highest and lowest costs and adjusts the moving average calculation. It also counts these movements to calculate the market speed.
  2. Periodic Refresh: At a set interval (which you can customize, but defaults to every 30 seconds), the tool creates a clean text summary on your screen. This summary displays all your key metrics in one easy-to-read line, ensuring that the information stays organized and up-to-date without cluttering your view.

Key Benefits for Traders

By using this tool, you can quickly assess "market health." Instead of manually checking price differences, you get an instant snapshot of:

  • Whether trading costs are currently favorable.
  • The volatility of the market based on spread extremes.
  • The pace of the market activity to determine if it is a high-frequency environment or a slow-moving period.
3 Views
0 Downloads
0 Favorites
notonlyspread
//+------------------------------------------------------------------+
//|                                                NotOnlySpread.mq4 |
//|        Spread, its moving average (ema), its maximum and minimum,|
//|                   and ticks per second (market speed) on comment.|
//+------------------------------------------------------------------+
#property copyright "Fabrizio"
#property link      "fajuzi@yahoo.it"
#property version   "1.00"
#property indicator_chart_window
input int     digi=1;//digits format
input int     sec=30;//seconds to refresh
input bool    clear=false;//if true clears comment after closing indicator
double newspread,emaspread,cost,maxpread,minspread;
int tickscount;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
   EventSetTimer(sec);
   emaspread=MarketInfo(Symbol(),MODE_SPREAD);
   cost=(sec+1.0)/2.0;
   newspread=emaspread; maxpread=emaspread; minspread=emaspread;
   tickscount=0;
   Comment("INSTANT SPREAD = ",DoubleToString(emaspread,digi),
           "; PLEASE WAIT ",IntegerToString(sec)," SECONDS...");
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+  
void OnDeinit(const int reason)
  {
   EventKillTimer();
   if(clear==true) Comment("");
  }
//+------------------------------------------------------------------+
//| On timer function                                                |
//+------------------------------------------------------------------+ 
void OnTimer()
  {
   Comment("INSTANT SPREAD = ",DoubleToString(newspread,digi),
           ";  EMA AVERAGE = ",DoubleToString(emaspread,digi),
           ";  MAX = ",DoubleToString(maxpread,digi),
           ";  MIN = ",DoubleToString(minspread,digi),
           ";  TICKS/MINUTE SPEED = ",IntegerToString(60*tickscount/sec),
           "; ",IntegerToString(sec)," SECONDS TO REFRESH...");
   newspread=emaspread; maxpread=emaspread; minspread=emaspread;
   tickscount=0;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   tickscount++;
   newspread=MarketInfo(Symbol(),MODE_SPREAD);
   maxpread=MathMax(maxpread,newspread);
   minspread=MathMin(minspread,newspread);
   emaspread=emaspread+(newspread-emaspread)/cost;
   return(rates_total);
  }
//+------------------------------------------------------------------+

Comments