Прошу доработать советник: 4-7 GMT Breakout
//+------------------------------------------------------------------+
//| Kitai.mq4 |
//| Copyright 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#define MAGIC 20110406
extern int StopLoss = 300; //Стоплосс ордера
extern int TakeProfit = 3000;//Тейкпрофит ордера
extern int Slip = 50; //Проскальзывание
extern int Pos = 0; //0-buy 1-sell
extern int Distance = 200; //Расстояние от цены для установки ордера
extern int Step = 200; //Шаг установки ордеров
extern int Count = 3; //Количество устанавливаемых ордеров
extern double Lots = 0.1; //Лот
int pos=0; //количество поз
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int BuyPos=0,SellPos=0,b=0,s=0,res=0,i;
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MAGIC) continue;
if(OrderType()==OP_BUY) BuyPos++;
if(OrderType()==OP_SELL) SellPos++;
if(OrderType()==OP_BUYSTOP) b++;
if(OrderType()==OP_SELLSTOP) s++;
}
}
if((BuyPos+SellPos)>pos || (BuyPos+SellPos)<pos)//если открылась еще поза или позиций стало меньше(SL,TP), то удаляем старые ордера и ставим новые
{
DelOrder();
if((BuyPos>0 || SellPos>0) && b<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Ask+(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_BUYSTOP,Lots,price,3,price-StopLoss*Point,price+TakeProfit*Point,"",MAGIC,0,Blue);
}
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && s<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Bid-(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_SELLSTOP,Lots,price,3,price+StopLoss*Point,price-TakeProfit*Point,"",MAGIC,0,Red);
}
}
//--------------------------------------------------------------------
}
Comment(
"\n Открыто позиций ",pos,
"\n Buy позиций ",BuyPos,
"\n Sell позиций ",SellPos);
//--------------------------------------------------------------------
if(Pos==0 && pos<1)
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGIC,0,Blue);
}
//--------------------------------------------------------------------
if(Pos==1 && pos<1)
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGIC,0,Red);
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && b<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Ask+(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_BUYSTOP,Lots,price,3,price-StopLoss*Point,price+TakeProfit*Point,"",MAGIC,0,Blue);
}
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && s<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Bid-(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_SELLSTOP,Lots,price,3,price+StopLoss*Point,price-TakeProfit*Point,"",MAGIC,0,Red);
}
}
//--------------------------------------------------------------------
pos=BuyPos+SellPos;
return 0;
}
//+------------------------------------------------------------------+
double fND(double d,int n=-1)
{
if(n<0) return(NormalizeDouble(d, Digits));
return(NormalizeDouble(d, n));
}
//+------------------------------------------------------------------+
void DelOrder()
{
for(int i=OrdersTotal()-1; i>=0; i--)
{
bool del;
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
{
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderType()==OP_BUYSTOP) del=OrderDelete(OrderTicket());
if(OrderType()==OP_SELLSTOP) del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
//---- input parameters
extern int barsToProcess=10; //количество баров для расчета
extern int Dist=10; //расстояние от поддержки в пунктах
extern int Pointer=233; //тип стрелки
Ошибка: 404
К сожалению, такой страницы не существует, либо у Вас недостаточно прав доступа для ее просмотра.
//+------------------------------------------------------------------+
//| Kitai.mq4 |
//| Copyright 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#define MAGIC 20110406
extern int StopLoss = 300; //Стоплосс ордера
extern int TakeProfit = 3000;//Тейкпрофит ордера
extern int Slip = 50; //Проскальзывание
extern int Pos = 0; //0-buy 1-sell
extern int Distance = 200; //Расстояние от цены для установки ордера
extern int Step = 200; //Шаг установки ордеров
extern int Count = 3; //Количество устанавливаемых ордеров
extern double Lots = 0.1; //Лот
/*
1. Кучка ордеров таскается за ценой
2. Если открывается новый ордер удаляем все ордера и ставим на расстоянии от цены заново.
3. Запоминаем количество открытых позиций
4. Если количество открытых позиций больше запомненного то п.2
5. Ордер сработал, поза открылась, перед тем как запомним новое количество поз, нужно удалить старые ордера и установить новые.
*/
int pos=0; //количество поз
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int BuyPos=0,SellPos=0,b=0,s=0,res=0,i;
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MAGIC) continue;
if(OrderType()==OP_BUY) BuyPos++;
if(OrderType()==OP_SELL) SellPos++;
if(OrderType()==OP_BUYSTOP) b++;
if(OrderType()==OP_SELLSTOP) s++;
}
}
if((BuyPos+SellPos)>pos || (BuyPos+SellPos)<pos)//если открылась еще поза или позиций стало меньше(SL,TP), то удаляем старые ордера и ставим новые
{
DelOrder();
if((BuyPos>0 || SellPos>0) && b<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Ask+(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_BUYSTOP,Lots,price,3,price-StopLoss*Point,price+TakeProfit*Point,"",MAGIC,0,Blue);
}
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && s<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Bid-(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_SELLSTOP,Lots,price,3,price+StopLoss*Point,price-TakeProfit*Point,"",MAGIC,0,Red);
}
}
//--------------------------------------------------------------------
}
Comment(
"\n Открыто позиций ",pos,
"\n Buy позиций ",BuyPos,
"\n Sell позиций ",SellPos);
//--------------------------------------------------------------------
if(Pos==0 && OrdersTotal()<1)
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGIC,0,Blue);
}
//--------------------------------------------------------------------
if(Pos==1 && OrdersTotal()<1)
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGIC,0,Red);
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && b<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Ask+(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_BUYSTOP,Lots,price,3,price-StopLoss*Point,price+TakeProfit*Point,"",MAGIC,0,Blue);
}
}
//--------------------------------------------------------------------
if((BuyPos>0 || SellPos>0) && s<1)
for(i=0;i<=Count-1;i++)
{
{
double price=fND(Bid-(Distance*Point+i*Step*Point));
res=OrderSend(Symbol(),OP_SELLSTOP,Lots,price,3,price+StopLoss*Point,price-TakeProfit*Point,"",MAGIC,0,Red);
}
}
//--------------------------------------------------------------------
pos=BuyPos+SellPos;
return 0;
}
//+------------------------------------------------------------------+
double fND(double d,int n=-1)
{
if(n<0) return(NormalizeDouble(d, Digits));
return(NormalizeDouble(d, n));
}
//+------------------------------------------------------------------+
void DelOrder()
{
for(int i=OrdersTotal()-1; i>=0; i--)
{
bool del;
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
{
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderType()==OP_BUYSTOP) del=OrderDelete(OrderTicket());
if(OrderType()==OP_SELLSTOP) del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
project.opentraders.ru/20424.html
AM2