//+------------------------------------------------------------------+
//| Histo.mq4 |
//| Copyright 2023, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_minimum 0
#property indicator_maximum 1
//---
input int MA1 = 22; // период МА1
input int MA2 = 44; // период МА2
input int Barov = 333; // баров для расчета
//--- buffers
double red[];
double lim[];
double gra[];
int redc=0,limc=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
void OnInit(void)
{
SetIndexStyle(0,DRAW_HISTOGRAM,0,3,Red);
SetIndexBuffer(0,red);
SetIndexStyle(1,DRAW_HISTOGRAM,0,3,Lime);
SetIndexBuffer(1,lim);
SetIndexStyle(2,DRAW_HISTOGRAM,0,3,Gray);
SetIndexBuffer(2,gra);
//--- initialization done
}
//+------------------------------------------------------------------+
//| Heiken Ashi |
//+------------------------------------------------------------------+
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[])
{
//--- main loop of calculations
for(int i=0; i<Barov; i++)
{
double ma1 = iMA(NULL,0,MA1,0,0,0,i);
double ma2 = iMA(NULL,0,MA2,0,0,0,i);
//gra[i]=1;
if(ma1>ma2)
{
lim[i]=1;
}
if(ma1<ma2)
{
red[i]=1;
}
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
input int Shift = 1; // бар индикатора
AM2