turn_area_chart

Download script
Author: Yuriy Tokman (YTG)
turn_area_chart

This tool is designed to provide traders with a visual representation of market momentum and trend dynamics by combining two foundational technical analysis concepts: Moving Averages and the Relative Strength Index (RSI). Instead of showing these indicators in their traditional, separate windows, this script synthesizes them into a single unified chart view.

Core Logic and Functionality

The primary objective of this script is to create a dynamic "Area" or trend-tracking visualization based on the following logic:

1. Trend Foundation (Moving Average) The script begins by calculating a Moving Average (MA). This acts as the baseline for the indicator, representing the general direction of the price over a specific period. It provides the structural "spine" upon which all other visual data is layered.

2. Momentum Integration (RSI Dynamics) The tool incorporates the Relative Strength Index (RSI) to measure the speed and change of price movements. Rather than plotting the RSI normally, the script uses the RSI values to calculate a variance from the Moving Average.

  • When the momentum is high, the indicator shifts significantly relative to the baseline.
  • When the momentum is low, the indicator stays closer to the baseline.

3. Visual Boundaries and Levels The script generates specific visual markers based on user-defined "Up" and "Down" levels (typically used to identify overbought or oversold conditions). It projects these levels onto the main chart relative to the Moving Average:

  • Upper Boundary: A calculated level based on the upper RSI threshold.
  • Lower Boundary: A calculated level based on the lower RSI threshold.

How it Benefits the Trader

By merging these elements, the script provides a clear visual "corridor." It allows you to see not just where the price is trending (the Moving Average), but also the intensity of that trend (the RSI variance) and the critical boundaries where the market might be reaching extremes. This helps in identifying potential exhaustion points or trend reversals more intuitively than looking at multiple separate sub-windows.

Indicators Used
Moving average indicatorRelative strength index
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
turn_area_chart
//+------------------------------------------------------------------+
//|                                              Turn Area Chart.mq4 |
//|                                               Yuriy Tokman (YTG) |
//|                                               http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "http://ytg.com.ua/"
#property version   "1.00"
#property strict
#property indicator_chart_window

#property indicator_buffers 4
#property indicator_color1 clrDarkViolet
#property indicator_color2 clrRed
#property indicator_color3 clrSilver
#property indicator_color4 clrSilver
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT

input int                EMA_Period   = 12;
input ENUM_MA_METHOD     EMA_Method   = 0;
input ENUM_APPLIED_PRICE EMA_Price    = 0;
input int                RSI_Period   = 21;
input ENUM_APPLIED_PRICE PSI_Price    = 0;
input int                Level_RSI_UP = 70;
input int                Level_RSI_DN = 30;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
string name="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   name = "Turn Area Chart";
   IndicatorShortName(name);
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,name);
   SetIndexDrawBegin(0,MathMax(RSI_Period,EMA_Period));
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"MA");
   SetIndexDrawBegin(1,MathMax(RSI_Period,EMA_Period)); 

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexLabel(2,"Level RSI UP");
   SetIndexDrawBegin(2,MathMax(RSI_Period,EMA_Period)); 
   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexLabel(3,"Level RSI DN");
   SetIndexDrawBegin(3,MathMax(RSI_Period,EMA_Period));       
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int limit=rates_total-prev_calculated;
   if(prev_calculated==0)limit--;
   else  limit++;  
   double ma=0;
   for( int i=0; i<limit && !IsStopped(); i++)
    {
     ma = iMA(NULL,0,EMA_Period,0,EMA_Method,EMA_Price,i); 
     ExtMapBuffer1[i] = ma - (50 - iRSI(NULL, 0, RSI_Period, PSI_Price,i))*Point;    
     ExtMapBuffer2[i] = ma;
     ExtMapBuffer3[i] = ma + (Level_RSI_UP - 50)*Point;     
     ExtMapBuffer4[i] = ma - (50 - Level_RSI_DN)*Point;     
    }    
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Comments