//+------------------------------------------------------------------+
//| Tail_Bar_v01.mq4 |
//+------------------------------------------------------------------+
#property copyright "Inkov Evgeni ew123@mail.ru"
#property link "+7-988-140-68-11"
//+------------------------------------------------------------------+
#property description "Tail_Bar"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 clrGreen
#property indicator_color2 clrRed
#property indicator_width1 2
#property indicator_width2 2
//--- indicator buffers
double BufferU[];
double BufferD[];
double Buffer[];
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorBuffers(3);
//--- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_NONE);
//--- all indicator buffers mapping
SetIndexBuffer(0,BufferU);
SetIndexBuffer(1,BufferD);
SetIndexBuffer(2,Buffer);
IndicatorDigits(1);
IndicatorShortName("Tail Bar");
}
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
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 counted_bars = IndicatorCounted();
//----
int i, limit=0;
if(counted_bars == 0) limit = Bars - 2;
if(counted_bars > 0) limit = Bars - counted_bars;
for(i=0; i<limit; i++)
Buffer[i]=((High[i]-MathMax(Close[i],Open[i]))-(MathMin(Close[i],Open[i])-Low[i]))/Point;
for(i=limit; i>=0;i--)
if(Buffer[i]<Buffer[i+1])
{
BufferU[i]=0.0;
BufferD[i]=Buffer[i];
}
else
{
BufferU[i]=Buffer[i];
BufferD[i]=0.0;
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
Comments