//+------------------------------------------------------------------+
//| body+shadow_size.mq4 |
//| Влад Сергеев aka moneyinnetwork |
//+------------------------------------------------------------------+
#property copyright "Vlad Sergeev"
#property link "http://moneyinnetwork.ru"
#property version "1.00"
#property strict
#property indicator_chart_window
input int TextSize = 8; //размер шрифта
input color TextColor = clrYellow; //цвет текста
input int TextAngle = 90; //угол поворота текста
input int MaxBar = 100; //количество баров, начиная с 0, для которых вычисляется размер свечей
int OnInit()
{
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
for ( int i = 0; i < MaxBar; i++ ) {
if ( ObjectFind ("candlesize"+ IntegerToString(i)) >=0 ) {
ObjectDelete("candlesize"+ IntegerToString(i));
}
}
}
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 i;
double body_size=0, up_shadow=0, down_shadow=0;
for ( i = 0; i < MaxBar; i++ ) {
if ( ObjectFind ("candlesize"+ IntegerToString(i)) >=0 ) {
ObjectDelete("candlesize"+ IntegerToString(i));
}
ObjectCreate ("candlesize"+ IntegerToString(i),
OBJ_TEXT,
0,
time[i],
high[i]+StepPer()*Point);
ObjectSet ( "candlesize"+IntegerToString(i),
OBJPROP_ANGLE,
TextAngle
);
body_size = MathAbs(close[i]-open[i])/Point; //тело свечи
//проверка на "бычье тело"
if ( close[i] > open[i] ) {
up_shadow = (high[i]-close[i])/Point; //верхняя тень - фитиль
down_shadow = (open[i]-low[i])/Point; //нижняя тень - ножка
}
//проверка на "медвежье тело"
if ( close[i] < open[i] ) {
up_shadow = (high[i]-open[i])/Point; //верхняя тень
down_shadow = (close[i]-low[i])/Point; //нижняя тень
}
ObjectSetText ( "candlesize"+IntegerToString(i),
DoubleToStr(down_shadow, 0)+"-"+DoubleToStr(body_size, 0)+"-"+DoubleToStr(up_shadow, 0),
TextSize,
NULL,
TextColor
);
}
return(rates_total);
}
int StepPer ()
{
int i = 0;
switch (Period())
{
case PERIOD_M1:
i = 5;
break;
case PERIOD_M5:
i = 15;
break;
case PERIOD_M15:
i = 25;
break;
case PERIOD_M30:
i = 40;
break;
case PERIOD_H1:
i = 60;
break;
case PERIOD_H4:
i = 90;
break;
case PERIOD_D1:
i = 220;
break;
case PERIOD_W1:
i = 500;
break;
case PERIOD_MN1:
i = 2000;
break;
default:
break;
}
return (i);
}