Full_Bar_w_Spread_Shadow_v3

Download script
Author: transport_david , David W Honeywell
Full_Bar_w_Spread_Shadow_v3

This tool is designed to provide a more accurate visual representation of price action on a trading chart by accounting for the "Spread"—the difference between the buy and sell prices offered by a broker. In many standard charts, the visual data may only reflect one side of the market, but this script calculates the actual boundaries of trade execution to give you a clearer picture of where the price truly sits.

How the Logic Works

The script works by analyzing every completed candle on your chart and calculating specific price points based on four key components: the current market spread, the high price, the low price, and the closing price of each bar.

Instead of relying on a single price line, it identifies several distinct levels for each bar:

  • The Execution Ceiling: It calculates the maximum reachable price by adding the current market spread to the candle's highest point. This represents the "worst-case" entry or exit scenario at the top of the bar.
  • The Closing Range: The script identifies where the price actually finished relative to the spread. It determines whether the candle's high was sufficient to cover the spread; if it wasn't, it marks the spread-adjusted closing price as a key boundary. If the high did exceed the spread, it recognizes the actual top of the bar as the primary limit.
  • The Baseline Floor: It establishes the lower boundary based on the closing price without the spread, providing a clear anchor for where the price settled.

Visual Representation

The tool renders these calculations as a series of histograms on your chart using two distinct colors:

  1. Lime Elements: These represent the "upper" boundaries of the price action, showing you the maximum reach and the adjusted closing high.
  2. Coral Elements: These represent the "lower" boundaries and the standard closing levels.

By plotting these values side-by-side, the script creates a visual "shadow" or range for each candle. This allows traders to see the gap between where the price is displayed and where a trade can actually be executed, helping to identify volatility and potential entry zones more effectively than a standard chart alone.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Full_Bar_w_Spread_Shadow_v3
//+------------------------------------------------------------------+
//|                                     Full_Bar_w_Spread_Shadow.mq4 |
//|                              transport_david , David W Honeywell |
//|                                        transport.david@gmail.com |
//+------------------------------------------------------------------+
#property copyright "transport_david , David W Honeywell"
#property link      "transport.david@gmail.com"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Coral
#property indicator_color4 Coral
//---- input parameters
//---- buffers
double ExtMapBuffer0[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1);
   SetIndexBuffer(0, ExtMapBuffer0);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1);
   SetIndexBuffer(1, ExtMapBuffer1);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 1);
   SetIndexBuffer(2, ExtMapBuffer2);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 1);
   SetIndexBuffer(3, ExtMapBuffer3);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  { 
   double spread, Hsplitprice, Lsplitprice, Top, TopPlus;
   int counted_bars=IndicatorCounted();
   if  (counted_bars<0) return(-1);
   if  (counted_bars>0) counted_bars--;
   int i;
//---- 
   for(i=counted_bars-1; i>=0; i--)
     { spread=(Ask-Bid);
      TopPlus=(High[i]+spread);
      Top=(High[i]);
      Hsplitprice=(Close[i]+spread);
      Lsplitprice=(Close[i]);
//----
      ExtMapBuffer0[i]=TopPlus;
      if (Top <  Hsplitprice) { ExtMapBuffer1[i]=Hsplitprice; }
      if (Top>=Hsplitprice) { ExtMapBuffer1[i]=Top; }
      ExtMapBuffer2[i]=Hsplitprice;
      ExtMapBuffer3[i]=Lsplitprice;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments