
if(Low[2]<Low[1] && Close[1]-Open[1]>Delta*_Point && Close[2]-Open[2]>Delta*_Point && Close[1]-Open[2]>Sigma*_Point)
{
}
if(High[2]>High[1] && Open[1]-Close[1]>Delta*_Point && Open[2]-Close[2]>Delta*_Point && Open[2]-Close[1]>Sigma*_Point)
Если в настройках стоп=0, тогда, например, открылась сделка селл, но цена развернулась и пошла против вверх, ждётся второй паттерн на селл, открывается второй ордер селл и общий тейк будет равен: уровень БУ + меньшая сумма тел.
Например, сумма телл свечей ордера 1 равно 1000, а ордера 2 равна 1500.Тогда тейк будет равен уровень БУ двух ордеров + 1000.
extern double BULevel = 50; // сколько до тейка
extern double BUPoint = 100; // пункты от тейка
Не работает у меня( В чем может быть проблема?
//+------------------------------------------------------------------+
//| ZZ2.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double KLot = 1; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern int Delta = 100; // расстояние от цены
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
extern int Depth = 12;
extern int Dev = 5;
extern int Back = 3;
double zz0=0,zz1=0,zz2=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()>0)
break;
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
break;
}
}
}
if(lot>MaxLot)
lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double ZZPrice(int ne=0)
{
double zz;
int i,k=iBars(NULL,0),ke=0;
for(i=1; i<k; i++)
{
zz=iCustom(NULL,0,"ZigZag",Depth,Dev,Back,0,i);
if(zz!=0)
{
ke++;
if(ke>ne)
return(zz);
}
}
Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
return(0);
}
//+------------------------------------------------------------------+
//| Горизонтальная линия |
//+------------------------------------------------------------------+
void PutHLine(string name,double p,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_HLINE,0,0,p);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int BarsCount(int type)
{
int bars=0;
if(type==0)//buy
{
for(int i=0; i<Bars; i++)
{
if(Close[i]>zz2 && Bid>zz2 && zz0>zz2)
{
bars++;
}
}
}
if(type==1)
{
for(int i=0; i<Bars; i++)
{
if(Close[i]<zz2 && Bid<zz2 && zz0<zz2)
{
bars++;
}
}
}
return(bars);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
zz0=ZZPrice(0);
zz1=ZZPrice(1);
zz2=ZZPrice(2);
if(CountTrades()<1)
{
if(zz1>zz2)
{
PutHLine("UP",zz1,Blue);
PutHLine("DN",zz2,Red);
}
if(zz1<zz2)
{
PutHLine("UP",zz2,Blue);
PutHLine("DN",zz1,Red);
}
}
Comment("\n ZZ0: ",zz0,
"\n ZZ1: ",zz1,
"\n ZZ2: ",zz2,
"\n Buy Bars: ",BarsCount(0),
"\n Sell Bars: ",BarsCount(1));
}
//+------------------------------------------------------------------+
Андрей, здравствуйте, обрисовалась проблема с переходом за полночь, не корректно рассчитывает время, когда полные сутки наступили(GMT, по терминалу, локальное...)всё нормально.., а вот в тот момент когда идёт «разнобой», чё попало получается
AM2