Hi,
thanks very much for your help. Yes, the codes work on MT4.
Please find the indicator codes below.
Indicator 1:/+------------------------------------------------------------------+
//| Meanchange_Histo |
//| Copyright ďż˝ 2010, MetaQuotes Software Corp. |
//|
https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ďż˝ 2010, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net"
#property indicator_separate_window //Indicator is in a separate window
#property indicator_buffers 2 //Number of buffers
extern int History =20; //# of bars in calculation history
double Line_0[], Line_1[]; //Declaring data arrays
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//+-------
//Negative Histogramm
SetIndexBuffer(0,Line_0); //Assigning an array to buffer 0
SetIndexStyle(0,DRAW_HISTOGRAM,2,2,Red); //Line style
SetIndexArrow(0, 234);
//Positive Histogramm
SetIndexBuffer(1,Line_1);
SetIndexStyle(1,DRAW_HISTOGRAM,2,2,Green); //Line style
SetIndexArrow(1, 233);
//+-------
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, Counted_bars=IndicatorCounted(); //Number of counted bars
double MED0, AVGMED0;
//+-------
Counted_bars=IndicatorCounted(); //Number of counted bars
i=Bars-Counted_bars-1; //Index of the first uncounted bar
if (i>History-1) //If too many bars...
i=History-1; //... calculate only for specified # of bars
while (i>=0) //Loop for uncounted Bars
{
//Initialization
MED0=iMA(NULL,0,1,0,MODE_SMA,PRICE_MEDIAN,i);
AVGMED0=iMA(NULL,0,2,1,MODE_SMA,PRICE_MEDIAN,i);
if (AVGMED0<=MED0)
{
Line_0[i]=0;
Line_1[i]=MED0-AVGMED0;
}
else
{
Line_0[i]=MED0-AVGMED0;
Line_1[i]=0;
}
i--; //Next bar
}
//+-------
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
Indicator2://+------------------------------------------------------------------+
//| Meanchange.mq4 |
//| Copyright ďż˝ 2010, MetaQuotes Software Corp. |
//|
https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ďż˝ 2010, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net"
#property indicator_chart_window //Indicator is in a separate window
#property indicator_buffers 2 //Number of buffers
extern int History =20; //# of bars in calculation history
double Line_0[], Line_1[]; //Declaring data arrays
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//+-------
//Change down
SetIndexBuffer(0,Line_0); //Assigning an array to buffer 0
SetIndexStyle(0,DRAW_ARROW,EMPTY,2,Red); //Line style
SetIndexArrow(0, 234);
//Change up
SetIndexBuffer(1,Line_1);
SetIndexStyle(1,DRAW_ARROW,EMPTY,2,Green); //Line style
SetIndexArrow(1, 233);
//+-------
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, Counted_bars=IndicatorCounted(); //Number of counted bars
double MED0, MED1, AVGMED0, AVGMED1;
//+-------
Counted_bars=IndicatorCounted(); //Number of counted bars
i=Bars-Counted_bars-1; //Index of the first uncounted bar
if (i>History-1) //If too many bars...
i=History-1; //... calculate only for specified # of bars
while (i>=0) //Loop for uncounted Bars
{
//Initialization
MED0=iMA(NULL,0,1,0,MODE_SMA,PRICE_MEDIAN,i);
MED1=iMA(NULL,0,1,0,MODE_SMA,PRICE_MEDIAN,i+1);
AVGMED0=iMA(NULL,0,2,1,MODE_SMA,PRICE_MEDIAN,i);
AVGMED1=iMA(NULL,0,2,1,MODE_SMA,PRICE_MEDIAN,i+1);
if (((AVGMED1>MED1)&&(AVGMED0>MED0))||((AVGMED1<MED1)&&(AVGMED0<MED0)))
{
Line_0[i]=2147483647;
Line_1[i]=2147483647;
}
if ((AVGMED1>MED1)&&(AVGMED0<MED0))
{
Line_0[i]=2147483647;
Line_1[i]=Low[i]-40*Point;
}
if ((AVGMED1<MED1)&&(AVGMED0>MED0))
{
Line_0[i]=High[i]+40*Point;
Line_1[i]=2147483647;
}
i--; //Next bar
}
//+-------
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}