Но расчёт взять за 10 прошлых лет
пожалуйста проверьте правильность выполнения)
//+------------------------------------------------------------------+
//| ATRM.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsyatems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsyatems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#define KEY_NUMPAD_5 12
#define KEY_LEFT 37
#define KEY_UP 38
#define KEY_RIGHT 39
#define KEY_DOWN 40
#define KEY_NUMLOCK_DOWN 98
#define KEY_NUMLOCK_LEFT 100
#define KEY_NUMLOCK_5 101
#define KEY_NUMLOCK_RIGHT 102
#define KEY_NUMLOCK_UP 104
input int Shift=0;
int atr=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectDelete(0,"L");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string text)
{
ObjectDelete(0,"L");
//--- создадим текстовую метку
ObjectCreate(0,"L",OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,"L",OBJPROP_XDISTANCE,55);
ObjectSetInteger(0,"L",OBJPROP_YDISTANCE,10);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,"L",OBJPROP_CORNER,1);
//--- установим текст
ObjectSetString(0,"L",OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,"L",OBJPROP_FONT,"Arial");
//--- установим размер шрифта
ObjectSetInteger(0,"L",OBJPROP_FONTSIZE,12);
//--- установим цвет
ObjectSetInteger(0,"L",OBJPROP_COLOR,Red);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // идентификатор события
const long& lparam, // параметр события типа long
const double& dparam, // параметр события типа double
const string& sparam // параметр события типа string
)
{
//--- нажатие кнопки на клавиатуре
if(id==CHARTEVENT_KEYDOWN)
{
if(lparam==38) PutLabel((string)atr);
if(lparam==40) ObjectDelete(0,"L");
}
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
atr=(int)((iHigh(NULL,PERIOD_MN1,Shift)-iLow(NULL,PERIOD_MN1,Shift))/_Point);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
В ТЗ чётко написано что мне нужно чтобы появлялось при нажатии на клавиатуру!!!
где рисовать?
AM2