
Мне нужно что бы индикатор показывал только сумму ВСЕХ ПРОФИТНЫХ ОРДЕРОВ!!!
//+------------------------------------------------------------------+
//| Profit.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 corner=0;
input color clr=Red;
input string fnt="Arial";
input int size=12;
input int x=22;
input int y=22;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string text)
{
ObjectDelete(0,"L");
//--- создадим текстовую метку
ObjectCreate(0,"L",OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,"L",OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,"L",OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,"L",OBJPROP_CORNER,corner);
//--- установим текст
ObjectSetString(0,"L",OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,"L",OBJPROP_FONT,fnt);
//--- установим размер шрифта
ObjectSetInteger(0,"L",OBJPROP_FONTSIZE,size);
//--- установим цвет
ObjectSetInteger(0,"L",OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double AllProfit()
{
double profit=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()<2 && OrderProfit()>0) profit+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
return (profit);
}
//+------------------------------------------------------------------+
//| 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(AllProfit(),2)));
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Profit.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 corner=0;
input color clr=Red;
input string fnt="Arial";
input int size=12;
input int x=22;
input int y=22;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string text)
{
ObjectDelete(0,"L");
//--- создадим текстовую метку
ObjectCreate(0,"L",OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,"L",OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,"L",OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,"L",OBJPROP_CORNER,corner);
//--- установим текст
ObjectSetString(0,"L",OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,"L",OBJPROP_FONT,fnt);
//--- установим размер шрифта
ObjectSetInteger(0,"L",OBJPROP_FONTSIZE,size);
//--- установим цвет
ObjectSetInteger(0,"L",OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double AllProfit()
{
double profit=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()<2 && OrderProfit()>0) profit+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
return (profit);
}
//+------------------------------------------------------------------+
//| 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(AllProfit(),2)));
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
думаю пока хватит
Думаю, PDF тоже смогу разобрать.
Это сложнее, подумаю как сделать в следующем топе. Пауза работает только в реале.
AM2