ВАЖНО! ПРИ ЗАКРЫТИИ
почему так важно?
ВАЖНО! ПРИ ЗАКРЫТИИ
Да уж надо мне ещё поучится пользоваться форумом
//+------------------------------------------------------------------+
//| Levels.mq5 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property indicator_chart_window
input int count=5;
input double lev1=0.2;
input double lev2=0.4;
input double lev3=0.6;
input color clr1=Blue;
input color clr2=Lime;
input color clr3=Yellow;
double op[];
datetime tm[],t[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
Comment("");
ObjectsDeleteAll(0,0,OBJ_TREND);
ArrayResize(tm,count);
ArrayResize(op,count);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price,datetime time2,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price,time2,price);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,1);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double ND(double price)
{
return(NormalizeDouble(price,_Digits));
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
CopyOpen(_Symbol,PERIOD_D1,0,count,op);
CopyTime(_Symbol,PERIOD_D1,0,count,tm);
CopyTime(_Symbol,PERIOD_CURRENT,0,1,t);
ArraySetAsSeries(op,true);
ArraySetAsSeries(tm,true);
ArraySetAsSeries(t,true);
/**/
for(int i=0;i<count;i++)
{
if(i==0)
{
PutTrendLine("op",tm[0],ND(op[0]),t[0],Red);
PutTrendLine("up",tm[0],ND(op[0]*(1+lev1/100)),t[0],clr1);
PutTrendLine("dn",tm[0],ND(op[0]*(1-lev1/100)),t[0],clr1);
PutTrendLine("1up",tm[0],ND(op[0]*(1+lev2/100)),t[0],clr2);
PutTrendLine("1dn",tm[0],ND(op[0]*(1-lev2/100)),t[0],clr2);
PutTrendLine("2up",tm[0],ND(op[0]*(1+lev3/100)),t[0],clr3);
PutTrendLine("2dn",tm[0],ND(op[0]*(1-lev3/100)),t[0],clr3);
}
if(i>0)
{
PutTrendLine("op"+(string)i,tm[i-1],ND(op[i]),tm[i],Red);
PutTrendLine("1up"+(string)i,tm[i-1],ND(op[i]*(1+lev1/100)),tm[i],clr1);
PutTrendLine("1dn"+(string)i,tm[i-1],ND(op[i]*(1-lev1/100)),tm[i],clr1);
PutTrendLine("2up"+(string)i,tm[i-1],ND(op[i]*(1+lev2/100)),tm[i],clr2);
PutTrendLine("2dn"+(string)i,tm[i-1],ND(op[i]*(1-lev2/100)),tm[i],clr2);
PutTrendLine("3up"+(string)i,tm[i-1],ND(op[i]*(1+lev3/100)),tm[i],clr3);
PutTrendLine("3dn"+(string)i,tm[i-1],ND(op[i]*(1-lev3/100)),tm[i],clr3);
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Кнопочку нажали — исчезла:
Нажали еще раз снова появилась:
www.opentraders.ru/downloads/1848/
AM2