Author: Yuriy Tokman
2_2_MA

This script is designed as a specialized visual tool for traders who want to monitor the relative momentum between two major currency pairs simultaneously: EURUSD and GBPUSD. Rather than showing you standard price charts, this indicator calculates a specific mathematical "gap" or spread between moving averages for both currencies and displays them in a separate window.

How the Logic Works

1. Dual-Currency Monitoring The script looks at two different markets at the same time. It tracks the price action of EURUSD and GBPUSD, even if you are currently viewing a different chart. This allows for a high-level comparison of how these two specific pairs are moving in relation to their historical averages.

2. The Moving Average Calculation For each currency pair, the script calculates two separate "Moving Averages." A Moving Average is a common technical tool that smooths out price data to show the general direction of the market.

  • It uses a Short-Term period (which reacts quickly to recent price changes).
  • It uses a Long-Term period (which represents the broader, slower trend).

3. Calculating the "Spread" Instead of simply plotting these averages as lines on your chart, the script performs a subtraction: it takes the Short-Term average and subtracts the Long-Term average from it.

By doing this, the indicator tells you how far "stretched" the current price is away from its long-term trend. If the difference is increasing, the momentum is strengthening; if it is narrowing, the momentum may be cooling off.

4. Standardization (Normalization) Because different currency pairs move in different "point" sizes, a raw difference might look confusing or inconsistent between two pairs. To fix this, the script automatically divides the result by the specific point value of each currency. This ensures that the movements for both EURUSD and GBPUSD are scaled proportionally, making it easy to compare their relative strength side-by-side on a single visual scale.

Visual Output

The final result is displayed in a separate window at the bottom of your trading platform as two distinct lines:

  • Green Line: Represents the calculated momentum spread for EURUSD.
  • Red Line: Represents the calculated momentum spread for GBPUSD.

By observing these two lines together, traders can quickly identify when one currency pair is leading the other or when both are experiencing a synchronized shift in trend strength.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
2_2_MA
//+------------------------------------------------------------------+
//|                                                       2*2_MA.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

extern int period_1 = 13 ;
extern int period_2 = 55 ;
extern int ma_method = 0;
extern int applied_price = 0;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   IndicatorShortName("2*2_MA("+period_1+","+period_2+")");
   
   SetIndexLabel(0,"EURUSD");
   SetIndexLabel(1,"GBPUSD");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  int limit;
   int counted_bars=IndicatorCounted();
   
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   //---- main loop
   for(int i=0; i<limit; i++)
   {
     double p1 = MarketInfo("EURUSD",MODE_POINT);
     double MA1 = iMA("EURUSD",0,period_1,0,ma_method,applied_price,i);
     double MA2 = iMA("EURUSD",0,period_2,0,ma_method,applied_price,i);
     ExtMapBuffer1[i]=(MA1-MA2)/p1;
     
     double p2 = MarketInfo("GBPUSD",MODE_POINT);
     double MA11 = iMA("GBPUSD",0,period_1,0,ma_method,applied_price,i);
     double MA22 = iMA("GBPUSD",0,period_2,0,ma_method,applied_price,i);
     ExtMapBuffer2[i]=(MA11-MA22)/p2;     
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+


Comments