//+------------------------------------------------------------------+
//| DealsInfo.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int days=11;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string name,string text,int x,int y)
{
ObjectDelete(0,name);
//--- создадим текстовую метку
ObjectCreate(0,name,OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,name,OBJPROP_CORNER,0);
//--- установим текст
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,name,OBJPROP_FONT,"Verdana");
//--- установим размер шрифта
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,10);
//--- установим цвет
ObjectSetInteger(0,name,OBJPROP_COLOR,Lime);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double DaysProfit()
{
double pr=0,point=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderCloseTime()>(TimeCurrent()-60*60*24*days))
{
if(OrderProfit()>0)
{
point=MarketInfo(OrderSymbol(),MODE_POINT);
if(OrderType()==0)
{
pr+=(OrderClosePrice()-OrderOpenPrice())/point;
}
if(OrderType()==1)
{
pr+=(OrderOpenPrice()-OrderClosePrice())/point;
}
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double DaysLosses()
{
double pr=0,point=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderCloseTime()>(TimeCurrent()-60*60*24*days))
{
if(OrderProfit()<0)
{
point=MarketInfo(OrderSymbol(),MODE_POINT);
if(OrderType()==0)
{
pr+=(OrderOpenPrice()-OrderClosePrice())/point;
}
if(OrderType()==1)
{
pr+=(OrderClosePrice()-OrderOpenPrice())/point;
}
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
PutLabel("profit","Прибыль: "+(string)NormalizeDouble(DaysProfit(),2)+" пунктов",12,22);
PutLabel("loss","Убыток: "+(string)NormalizeDouble(DaysLosses(),2)+" пунктов",12,40);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ZZLevels.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int count=5;
input int depth=12;
input int dev=5;
input int back=3;
input int width=1;
input int style=2;
input color clr=Red;
input ENUM_TIMEFRAMES tf=PERIOD_D1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price1,datetime time2,double price2)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,style);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutRightLabel(string name,datetime time,double price)
{
ObjectDelete(0,name);
//--- создадим текстовую метку
ObjectCreate(0,name,OBJ_ARROW_RIGHT_PRICE,0,time,price);
//--- установим размер метки
ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
//--- установим цвет
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double ZZPrice(int n=0)
{
double zz=0;
int k=0;
for(int i=0;i<Bars; i++)
{
zz=iCustom(NULL,tf,"ZigZag",depth,dev,back,0,i);
if(zz!=0)
{
k++;
if(k>n) return(zz);
}
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int ZZBar(int n=0)
{
double zz=0;
int k=0;
for(int i=0;i<Bars;i++)
{
zz=iCustom(NULL,tf,"ZigZag",depth,dev,back,0,i);
if(zz!=0)
{
k++;
if(k>n) return(i);
}
}
Print("GetExtremumZZBar(): Экстремум ЗигЗага номер ",n," не найден");
return(-1);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
int k=PERIOD_D1/Period();
for(int i=0;i<count;i++)
{
PutTrendLine("Line"+(string)i,time[0],ZZPrice(i),time[ZZBar(i)*k],ZZPrice(i));
PutRightLabel("Label"+(string)i,time[0],ZZPrice(i));
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Dim777777