ytg_DveMashki_ind

Download script
Author: Yuriy Tokman
ytg_DveMashki_ind

This custom indicator is designed to provide visual clarity on your trading charts by highlighting specific trend dynamics using a "Moving Average" crossover logic. It simplifies complex price action into easy-to-read visual cues, helping traders identify shifts in market momentum at a glance.

Core Functionality

The tool operates by calculating two distinct types of Moving Averages simultaneously. These averages act as "smoothed" versions of the market price, filtering out minor market noise to reveal the broader underlying trend.

  • Short-Term Trend: The script calculates a faster-moving average (defaulting to 25 periods), which reacts more quickly to recent price changes.
  • Long-Term Trend: The script calculates a slower-moving average (defaulting to 50 periods), which represents the primary established direction of the market.

Visual Representation

Instead of standard lines, this indicator displays the data as thick histograms directly on your main chart window. This makes it much easier to distinguish between different market states:

  • Lime Highlights: These represent one set of calculations (associated with the shorter timeframe), providing a visual cue for immediate price movement.
  • Red Highlights: These represent the second set of calculations (associated with the longer timeframe), highlighting the broader market context.

How it Works for the Trader

The logic follows a "dual-layer" approach. By comparing the two averages, the script allows you to see whether the current short-term momentum is aligned with or diverging from the long-term trend. Because these are rendered as distinct colors and widths, you can quickly identify areas of agreement (where trends move together) or potential reversal points (where the faster trend begins to pull away from the slower one).

Key Features

  • Customizable Periods: You can adjust the length of the averages (e.g., changing 25 or 50 to other numbers) to suit different trading styles, such as scalping or long-term swing trading.
  • Flexible Smoothing: The script allows for different calculation methods, meaning you can choose how "smooth" or "sensitive" the data appears on your screen.
  • Real-Time Updates: The indicator automatically scans every bar on your chart to ensure that as new prices come in, the visual histograms update instantly to reflect current market conditions.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
ytg_DveMashki_ind
//+------------------------------------------------------------------+
//|                                            ytg_DveMashki_ind.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 6
#property indicator_width2 6
//----
extern color color1 = Lime;
extern color color2 = Red;
extern int ma_1 = 25;
extern int ma_2 = 50;
extern int method = 0;
extern int price = 0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
int ExtCountedBars=0;
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 6, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 6, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   IndicatorShortName("yuriytokman@gmail.com");
   SetIndexLabel(0,"yuriytokman@gmail.com");
   SetIndexLabel(1,"yuriytokman@gmail.com");   
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
     
Comment("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n yuriytokman@gmail.com");

   return(0);
  }
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int start()
  {
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     { 
      ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,0,method,price,pos);
      ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,0,method,price,pos);
 	   pos--;
     }
//----
   return(0);
  }
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n

Comments