Author: JDP
#TickPrice

This tool is designed to provide real-time price tracking and automated chart synchronization within the MetaTrader platform. By monitoring the live market feed, it specifically focuses on displaying the current "Bid" and "Ask" prices—the two most critical figures for any trader looking to enter or exit a position.

Core Functionality

Real-Time Price Tracking The script maintains a continuous history of the current market prices. Instead of only showing the current moment, it builds a visual record of how the Bid and Ask prices move over time. This allows traders to see the immediate fluctuations of the market as they happen, rendered in a dedicated separate window for clear visibility.

Dynamic Time Synchronization One of the primary features of this script is its ability to manage "Objects" on your chart (such as trendlines, rectangles, or other custom drawing tools). The logic includes an automated synchronization mechanism that handles how these objects behave in relation to time:

  • Forward Progression: When a new candle or time period begins, the script can automatically shift existing drawing objects forward in time. This ensures that your visual analysis remains aligned with the current progression of the market.
  • Backward Adjustment: Conversely, it includes logic to shift these objects backward as prices update, preventing your technical drawings from becoming "detached" or misaligned with the current price action as new data arrives.

How It Works for the User

The tool operates automatically in the background. You do not need to manually move your indicators or lines every time the market moves. If the "Move Objects" setting is enabled, the script acts as a coordinator, ensuring that your visual workspace stays updated and synchronized with the live price stream.

In summary, this script serves as a precision tracking tool that bridges the gap between raw market data (Bid/Ask prices) and your personal visual analysis, ensuring that both are always perfectly in sync.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
#TickPrice
//+------------------------------------------------------------------+
//|                                                   #TickPrice.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "JDP"
#property link      ""
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 White
#property indicator_separate_window
double bid[],ask[];
extern bool MoveObjects=true;
int LastTm;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0,ask);
   SetIndexLabel(0,"Ask");
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(1,bid);
   SetIndexLabel(1,"Bid");
   string shortname=Symbol()+"-#TickPrice";
   IndicatorShortName(shortname);
   LastTm = Time[0];
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,total,oTm;
   int    counted_bars=IndicatorCounted();
//----
   if (LastTm < Time[0]) {
      for (i = 0;i<1000;i++) {
         ask[i] = ask[i+1];
         bid[i] = bid[i+1];
      }
      if (MoveObjects==true) {
         total = ObjectsTotal();
         for (i=0;i<total;i++) {
            oTm =ObjectGet(ObjectName(i),OBJPROP_TIME1);
            oTm = oTm + (60*Period());
            ObjectSet(ObjectName(i),OBJPROP_TIME1,oTm);
         }
      }
      LastTm = Time[0];   
   }
   for (i = 1001;i>0;i--) {
      ask[i] = ask[i-1];
      bid[i] = bid[i-1];
   }
   if (MoveObjects==true) {
      total = ObjectsTotal();
      for (i=0;i<total;i++) {
         oTm =ObjectGet(ObjectName(i),OBJPROP_TIME1);
         oTm = oTm - (60*Period());
         ObjectSet(ObjectName(i),OBJPROP_TIME1,oTm);
      }
   }
   ask[0] = Ask;
   bid[0] = Bid;
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments