
Как ты и советовал — пролистал 10 страниц группы. Даже близко нет такого комплекса — который я прошу. Есть отдельные элементы, типа: сов — сеточник на мувингах, отложенные ордера есть (много)))))… но вот с таким набором параметров НЕТ!
extern int BUType = 0; // 0-оба 1-бай 2-селл
//+------------------------------------------------------------------+
//| TrendLimit.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
extern double Lots = 0.1; // лот
extern int StopLoss = 200; // лось
extern int TakeProfit = 300; // язь
extern int BULevel = 0; // уровень БУ
extern int BUPoint = 30; // пункты БУ
extern int Delta = 30; // дельта
extern int Points = 30; // размер свечи
extern int MAPeriod = 20; // период МА
extern int Expiration = 44; // истечение в минутах
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*60,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void BU()
{
bool m;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
{
m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
if(OrderType()==OP_SELL)
{
if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
{
m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma=iMA(NULL,0,MAPeriod,0,0,0,0);
if(BULevel>0) BU();
if(OrdersTotal()<1 && TimeCurrent()>Time[0]+(PeriodSeconds()-5*60))
{
if(MathAbs(Open[0]-Close[0]>Points*Point))
{
if(Bid>ma)
{
PutOrder(2,Bid-Delta*Point);
}
if(Bid<ma)
{
PutOrder(3,Bid+Delta*Point);
}
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| LossClose.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
input double Profit=10;
double LastEquity=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
if(type==1 || type==3 || type==5)
{
clr=Red;
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
}
r=OrderSend(NULL,type,0.1,NormalizeDouble(price,Digits),5,0,0,"",0,0,clr);
return;
}
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера |
//+------------------------------------------------------------------+
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(OrderSymbol()==Symbol())
{
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 CloseLastMinus()
{
bool cl;
for(int i=0;i<=OrdersTotal()-1;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==0)
{
if(OrderProfit()<0) cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),5,White);
break;
}
if(OrderType()==1)
{
if(OrderProfit()<0) cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),5,White);
break;
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(IsTesting() && OrdersTotal()<1)
{
for(int i=1;i<=5;i++) PutOrder(2,Ask-200*Point*i);
for(int i=1;i<=3;i++) PutOrder(5,Ask-150*Point*i);
}
if(AccountEquity()-LastEquity>Profit)
{
CloseLastMinus();
LastEquity=AccountEquity();
}
Comment("\n Profit: ",AllProfit(),
"\n Account Equity: ",AccountEquity(),
"\n Last Equity: ",LastEquity);
}
//+------------------------------------------------------------------+
AM2