MA_Mirror

This indicator is designed to provide traders with a visual representation of market momentum and price behavior by analyzing the relationship between the opening and closing prices of candles. It operates in a separate window below the main price chart, allowing you to monitor these fluctuations independently of the primary price movement.

Core Logic Overview

The tool works by calculating two distinct "mirrored" differences based on Simple Moving Averages (SMA). Rather than just looking at the price trend, it focuses on the spread between the price at which a candle begins (Open) and the price at which it ends (Close).

The script calculates two specific data streams:

  • The Primary Difference: This tracks the distance between the Moving Average of the Closing Prices and the Moving Average of the Opening Prices. Essentially, it shows the direction and strength of the price movement over a set period.
  • The Mirrored Difference: This performs the inverse calculation by subtracting the Moving Average of the Closing Prices from the Moving Average of the Opening Prices.

How It Works in Practice

By creating these two opposing calculations, the indicator highlights the "gap" or tension between the start and end of price action.

  1. Visual Representation: The tool plots these two mirrored values as distinct lines (colored Red and Blue) on your screen.
  2. Dynamic Comparison: Because one line is the mathematical opposite of the other, they mirror each other's movements. When the market moves strongly in one direction, these lines will diverge significantly.
  3. Momentum Identification: When the lines are close together or crossing, it suggests a period of consolidation or equilibrium. When they spread apart, it indicates significant momentum shifting from the opening price to the closing price (or vice versa) over the chosen time frame.

Customizable Settings

Users can adjust the "Moving Period" to change how much historical data the indicator considers. A shorter period will make the lines more sensitive to immediate, rapid price changes, while a longer period will smooth out the data to show broader, long-term trends.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
MA_Mirror
//+------------------------------------------------------------------+
//|                                                    MA_Mirror.mq4 |
//|                                   Copyright © 2010, Andy Tjatur. |
//|                                            andy.tjatur@gmail.com |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2010, Andy Tjatur."
#property  link      "andy.tjatur@gmail.com"
//---- indicator settings
#property  indicator_separate_window
#property indicator_level1 1
#property indicator_levelcolor White
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Blue
#property  indicator_width1 2
#property  indicator_width2 2

extern double MovingPeriod       = 20;
extern double MovingShift        = 0;
double     MacdBuffer1[];
double     MacdBuffer2[];
double     ma1,ma2;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);

   
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer1);
   SetIndexBuffer(1,MacdBuffer2);
 
   

   IndicatorShortName("MA_Mirror by Andy Tjatur");
   SetIndexLabel(0,"MA_CO");
   SetIndexLabel(1,"MA_OC");
 
   

   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Mirror                                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

  
   for(int i=0; i<limit; i++)
      MacdBuffer1[i]=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,i)-iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_OPEN,i);
    
   for(i=0; i<limit; i++)
      MacdBuffer2[i]=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_OPEN,i)-iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,i);
    


   return(0);
  }
//+----------------------------------------------------------------

Comments