сетка на подобие той что у меня на всех графиках
//+------------------------------------------------------------------+
//| CloseProfit.mq4 |
//| Copyright 2017, AM2. |
//| http://www.forexsyatems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2."
#property link "http://www.forexsyatems.biz"
#property version "1.00"
#property strict
input double Profit=30;
double equity=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
equity=AccountEquity();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
{
double pr=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==0 && (ot==0 || ot==-1))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| Закрытие позиции по типу ордера |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
{
bool cl;
int dig=0;
double bid=0,ask=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==0 && (ot==0 || ot==-1))
{
RefreshRates();
bid=MarketInfo(OrderSymbol(),MODE_BID);
dig=(int)MarketInfo(OrderSymbol(),MODE_DIGITS);
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(bid,dig),33,White);
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
RefreshRates();
ask=MarketInfo(OrderSymbol(),MODE_ASK);
dig=(int)MarketInfo(OrderSymbol(),MODE_DIGITS);
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(ask,dig),33,White);
}
}
}
}
//+------------------------------------------------------------------+
//| Установка ордера |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
}
r=OrderSend(NULL,type,1,NormalizeDouble(price,Digits),33,0,0,"",0,0,clr);
return;
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==type) count++;
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(IsTesting() && CountOrders(4)<1)
{
for(int i=1;i<11;i++) PutOrder(4,Bid+300*_Point*i);
}
if(AccountEquity()-equity>Profit)
{
CloseAll();
equity=AccountEquity();
}
Comment("\n First Equity: ",equity,
"\n Profit: ",AllProfit(),
"\n Orders: ",CountOrders(0)+CountOrders(1),
"\n Buy: ",CountOrders(0),
"\n Sell: ",CountOrders(1));
}
//+------------------------------------------------------------------+
Вы сделали, что бы ордера закрывались, на всех инструментах?
//+------------------------------------------------------------------+
//| FL33.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_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red
double up[];
double dn[];
double mid[];
double mid2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//--- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(0,up);
SetIndexBuffer(1,dn);
SetIndexBuffer(2,mid);
SetIndexBuffer(3,mid2);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
for(int i=1;i<1000;i++)
{
up[i]=iCustom(NULL,0,"FL20",1,i)/50;
dn[i]=iCustom(NULL,0,"FL20",2,i)/50;
mid[i]=iCustom(NULL,0,"FL22",0,i);
mid2[i]=iCustom(NULL,0,"FL22",1,i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2