Поправил пока легкую работу не отняли www.opentraders.ru/downloads/1466/
//+------------------------------------------------------------------+
//| Month.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int Count=5;
input int Heigth=500;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectsDeleteAll(0,0,OBJ_TEXT);
ObjectsDeleteAll(0,0,OBJ_RECTANGLE);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutRect(string name,datetime t1,double p1,datetime t2,double p2,color clr)
{
ObjectDelete(0,name);
//--- создадим прямоугольник по заданным координатам
ObjectCreate(0,name,OBJ_RECTANGLE,0,t1,p1,t2,p2);
//--- установим цвет прямоугольника
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutText(string name,const string text,double price,datetime time,const color clr)
{
ObjectDelete(0,name);
//--- create a "Text" object
ObjectCreate(0,name,OBJ_TEXT,0,time,price);
//--- set the text
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- set the font of the text
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- set the font size
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,11);
//--- set the method binding
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_UPPER);
//--- set the color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
datetime t1=0,t2=0;
double Hi=0,Lo=0,Mid=0;
for(int i=1;i<=Count;i++)
{
t1=iTime(NULL,PERIOD_MN1,i-1);
t2=iTime(NULL,PERIOD_MN1,i);
Hi=iHigh(NULL,PERIOD_MN1,i);
Lo=iLow(NULL,PERIOD_MN1,i);
Mid+=(Hi-Lo)/_Point;
PutRect("UP"+(string)i,t1,Hi,t2,Hi+Heigth*Point,Red);
PutRect("DN"+(string)i,t1,Lo,t2,Lo-Heigth*Point,Blue);
string txt=(string)(NormalizeDouble((Hi-Lo)/_Point,0));
PutText("TXT"+(string)i,txt,Hi+Heigth*4*Point,t1,Blue);
}
t1=Time[0];
t2=iTime(NULL,PERIOD_MN1,0);
Hi=iHigh(NULL,PERIOD_MN1,0);
Lo=iLow(NULL,PERIOD_MN1,0);
PutRect("UP"+(string)0,t1,Lo+(Mid/Count)*Point,t2,Lo+(Mid/Count)*Point+Heigth*Point,Red);
PutRect("DN"+(string)0,t1,Hi-(Mid/Count)*Point,t2,Hi-(Mid/Count)*Point-Heigth*Point,Blue);
Comment("\n АТР 12 месяцев: ",(int)Mid/Count);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2