Author: Yuriy Tokman
Raznost

This tool is designed to provide a clear, visual summary of price movement between two specific points in time on a trading chart. Its primary purpose is to calculate the mathematical difference between the current market opening and the previous market closing, presenting this information as an immediate on-screen label.

How the Logic Works

The script performs three main actions to help a trader quickly gauge market dynamics:

1. Price Gap Calculation The tool looks at the most recent data points available on the chart. It identifies the Opening Price of the current candle (the price at which the most recent trading period began) and compares it against the Closing Price of the previous candle (the price where the last period ended).

2. Trend Identification The script automatically determines the "direction" of this price movement by comparing these two numbers:

  • Upward Movement: If the current opening price is higher than the previous close, it identifies an upward trend.
  • Downward Movement: If the current opening price is lower than the previous close, it identifies a downward trend.
  • Flat Movement: If both prices are identical, it recognizes that there has been no change in value.

3. Visual Display Instead of requiring the trader to do manual math, the script generates two dynamic text labels directly on the trading window:

  • Trend Label: This displays a text indicator (e.g., "up", "down", or "flet") to notify you of the direction of the price shift.
  • Numeric Value: It calculates the exact numerical distance between the two prices, converting that value into standard trading points for easy reading.

Summary for the User

In simple terms, this script acts as a real-time "gap monitor." Every time the chart updates, it tells you exactly how many points the market moved from where it left off to where it is now, while simultaneously labeling whether that move was up, down, or non-existent. This allows for a quick glance at price volatility and momentum without manual calculation.

17 Views
0 Downloads
0 Favorites
Raznost
//+------------------------------------------------------------------+
//|                                                      Raznost.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  double a=Open[0]-Close[1];
    string name;
    string par =DoubleToStr((a/Point),0);
    
       if(Open[0]>Close[1])
      {
       name = "  up = ";
      }
    if(Open[0]<Close[1])
      {
       name = "down = ";
      }
     if(Open[0]==Close[1]) 
      {
       name = "flet = ";
      }
  
    
   // ñåé÷àñ ìû ñîçäàäèì òåêñòîâóþ ìåòêó.
   // äëÿ ýòîãî, êàê âñåãäà, èñïîëüçóåì ôóíêöèþ ObjectCreate.
   // êîîðäèíàòû óêàçûâàòü íå íóæíî
   ObjectCreate("signal",OBJ_LABEL,0,0,0,0,0);
   ObjectCreate("signal2",OBJ_LABEL,0,0,0,0,0);
 
   // èçìåíÿåì êîîðäèíàòó õ
   ObjectSet("signal",OBJPROP_XDISTANCE,3);
   ObjectSet("signal2",OBJPROP_XDISTANCE,59);
 
   // èçìåíÿåì êîîðäèíàòó ó
   ObjectSet("signal",OBJPROP_YDISTANCE,12);
   ObjectSet("signal2",OBJPROP_YDISTANCE,12);
 
   // ÷òîáû óêàçàòü òåêñò ìåòêè, èñïîëüçóåì ýòó ôóíêöèþ
   ObjectSetText("signal",name,12,"Tahoma",Red);
   ObjectSetText("signal2",par,12,"Tahoma",Red);
   // "signal" - íàçâàíèå îáúåêòà
  

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments