Ticker MACD

Download script
Author: mandorr@gmail.com
Ticker MACD

This script is a specialized trading tool designed to analyze price movement by identifying trends and momentum. Unlike standard indicators that rely solely on the closing price of candles (OHLC data), this specific version reacts to every individual price change (tick) as it happens in real-time.

Core Logic and Functionality

1. Real-Time Price Tracking The tool focuses on "Ticks"—the smallest possible changes in price. It monitors the current bid price and compares it to the previous price. If the price remains the same, the script waits; however, as soon as a move occurs, it updates its calculations immediately. This allows for a more responsive view of market volatility compared to traditional time-based indicators.

2. Dual Moving Averages (The Foundation) The script calculates two distinct types of moving averages based on user-defined periods:

  • Fast Average: This reacts quickly to recent price fluctuations.
  • Slow Average: This provides a smoother, long-term view of the price trend.

By calculating these two different speeds, the script can measure the "gap" between short-term momentum and long-term trends.

3. Signal Generation (The MACD Component) The "Main" line shown in the indicator represents the difference between the Fast and Slow averages. When the Fast average is significantly higher than the Slow average, it suggests upward momentum.

The script then takes this difference and calculates a "Signal" line. This is essentially a moving average of the difference itself. By smoothing out the fluctuations of the main line, the signal line helps filter out market "noise," making it easier to identify sustained trends.

Visual Feedback and Interpretation

The tool provides two visual layers on the chart:

  • Main Line: Shows the raw momentum (the distance between fast and slow price speeds).
  • Signal Line: Acts as a benchmark for that momentum.

Actionable Insights: The script automatically determines potential market directions based on the relationship between these lines:

  • Buy Signal: Triggered when the gap between the Fast and Slow averages is higher than the Signal line, suggesting bullish strength.
  • Sell Signal: Triggered when the gap falls below the Signal line, suggesting bearish weakness.

Summary for the User

In simple terms, this tool acts like a high-sensitivity "speedometer" for price action. It measures how fast the price is moving compared to its own history and highlights whether that speed is accelerating or decelerating. By watching the interaction between the Main line and the Signal line, traders can better visualize where momentum is shifting in real-time.

17 Views
0 Downloads
0 Favorites
Ticker MACD
//+------------------------------------------------------------------+
//|                                                                  |
//|                  Ticker MACD                                     |  
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "mandorr@gmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gray
#property indicator_width1 2
#property indicator_style1 0
#property indicator_color2 Red
#property indicator_width2 1
#property indicator_style2 2
//----
extern int PeriodFast=12;
extern int PeriodSlow=26;
extern int PeriodSignal=9;
extern int CountBars=1000;   // Êîëè÷åñòâî îòîáðàæàåìûõ áàðîâ
//----
int count;
int price;
int price_prev;
double period_fast;
double period_slow;
double period_sign;
double const_fast;
double const_slow;
double ma_fast[10];         // Fast EMA
double ma_slow[10];         // Slow EMA
double ma_sign[10];         // Signal SMA
double buffer0[];           // Main
double buffer1[];           // Signal
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void init()
  {
   SetIndexBuffer(0,buffer0);
   SetIndexLabel(0,"Main");
   SetIndexDrawBegin(0,0);
   SetIndexBuffer(1,buffer1);
   SetIndexLabel(1,"Signal");
   SetIndexDrawBegin(1,0);
   count=ArrayResize(ma_fast,CountBars);
   count=ArrayResize(ma_slow,CountBars);
   count=ArrayResize(ma_sign,CountBars);
   count=0;
   ArrayInitialize(ma_sign,EMPTY_VALUE); // EMPTY_VALUE=+2147483647
   price_prev=0;
   period_fast=MathMax(1,PeriodFast);
   period_slow=MathMax(1,PeriodSlow);
   period_sign=MathMax(1,PeriodSignal);
   const_fast=2/(1+period_fast);
   const_slow=2/(1+period_slow);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void start()
  {
   int i, N;
   double sum;
   price=MathRound(Bid/Point);
   if (price_prev==0)
     {
      count=0;
      price_prev=price;
      ma_fast[0]=price;
      ma_slow[0]=price;
      buffer0[0]=0;
      IndicatorShortName("Ticker ("+count+") MACD ("+DoubleToStr(period_fast,0)+","+DoubleToStr(period_slow,0)+","+DoubleToStr(period_sign,0)+")");
      return;
     }
   if (price==price_prev) return;
   price_prev=price;
   for(i=count; i>=0; i--)
     {
      ma_fast[i+1]=ma_fast[i];
      ma_slow[i+1]=ma_slow[i];
      ma_sign[i+1]=ma_sign[i];
     }
   ma_fast[0]=ma_fast[1]+const_fast*(price-ma_fast[1]);
   ma_slow[0]=ma_slow[1]+const_slow*(price-ma_slow[1]);
   if (count<CountBars-1) count++;
   N=period_sign-1;
   if (count>=N)
     {
      sum=0;
      for(i=0; i<=N; i++) sum+=ma_fast[i]-ma_slow[i];
      ma_sign[0]=sum/period_sign;
     }
   for(i=0; i<=count; i++)
     {
      buffer0[i]=ma_fast[i]-ma_slow[i];
      buffer1[i]=ma_sign[i];
     }
   string cmd="";
   if (count>=N)
     {
      if (ma_fast[0]-ma_slow[0]>ma_sign[0]) cmd=" Buy";
      if (ma_fast[0]-ma_slow[0]<ma_sign[0]) cmd=" Sell";
     }
   IndicatorShortName("Ticker ("+count+") MACD ("+DoubleToStr(period_fast,0)+","+DoubleToStr(period_slow,0)+","+DoubleToStr(period_sign,0)+")"+cmd);
  }
//+------------------------------------------------------------------+

Comments