Уважаемый Андрей подправьте пожалуста работу советника один сигнал одна сделка об этом писалось в задании только иными словами
//+------------------------------------------------------------------+
//| ExBB.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "BBands expert advisor"
//--- Inputs
extern double Lots = 0.1; // лот
extern double KLot = 2; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 5000; // лось
extern int TakeProfit = 5000; // язь
extern int StartHour = 0; // час начала торговли
extern int StartMin = 30; // минута начала торговли
extern int EndHour = 23; // час окончания торговли
extern int EndMin = 30; // минута окончания торговли
extern int Shift = 1; // сдвиг
extern int Slip = 30; // реквот
extern int Magic = 20; // магик
extern string IndName = "BBands_Stop_v1";
extern string s="------------- Настройки BBands_Stop_v1 -------------";
extern int Length = 20; // период BB
extern int Deviation = 2; // отклонение ВВ
extern string ss=" ------------- Настройки MACD ------------- ";
extern int MACD = 0; // 0-выкл. 1-вкл.
extern int Fast = 12; //
extern int Slow = 26; //
extern int Signal = 9; //
datetime t=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;
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;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
}
}
if(lot>MaxLot)lot=MaxLot;
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void OpenPos()
{
bool buy,sell;
//--- get Ind
double BBBlue=iCustom(Symbol(),0,IndName,Length,Deviation,0,Shift);
double BBRed=iCustom(Symbol(),0,IndName,Length,Deviation,1,Shift);
double BBBlue2=iCustom(Symbol(),0,IndName,Length,Deviation,0,Shift+1);
double BBRed2=iCustom(Symbol(),0,IndName,Length,Deviation,1,Shift+1);
double macd=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,Shift);
if(MACD==0)
{
buy = BBBlue>0 && BBRed2>0;
sell = BBRed>0 && BBBlue2>0;
}
if(MACD==1)
{
buy = BBBlue>0 && BBRed2>0 && macd>0;
sell = BBRed>0 && BBBlue2>0 && macd<0;
}
//--- sell conditions
if(sell)
{
PutOrder(1,Bid);
}
//--- buy conditions
if(buy)
{
PutOrder(0,Ask);
}
//---
}
//+----------------------------------------------------------------------------+
//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Версия : 30.04.2009 |
//| Описание : Возвращает флаг разрешения торговли по времени. |
//+----------------------------------------------------------------------------+
//| Параметры: |
//| hb - часы времени начала торговли |
//| mb - минуты времени начала торговли |
//| he - часы времени окончания торговли |
//| me - минуты времени окончания торговли |
//+----------------------------------------------------------------------------+
bool isTradeTimeInt(int hb=0,int mb=0,int he=0,int me=0)
{
datetime db, de; // Время начала и окончания работы
int hc; // Часы текущего времени торгового сервера
db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)hb+":"+(string)mb);
de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)he+":"+(string)me);
hc=TimeHour(TimeCurrent());
if(db>=de)
{
if(hc>=he) de+=24*60*60; else db-=24*60*60;
}
if(TimeCurrent()>=db && TimeCurrent()<=de) return(True);
else return(False);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1 && isTradeTimeInt(StartHour,StartMin,EndHour,EndMin))
{
if(t!=Time[0])
OpenPos();
t=Time[0];
}
Comment("\n ");
}
//+------------------------------------------------------------------+
спасибо, но не совсем то. кто-то возьмется написать советника по моему ТЗ?
//+------------------------------------------------------------------+
//| ProboyVol.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // объем позиции
extern int StopLoss = 500; // стоп лосс ордера
extern int TakeProfit = 500; // тейк профит ордера
extern int Delta = 100; // расстояние от вершин
extern int Expiration = 10; // время истечения ордера
extern int Slip = 3; // реквот
extern int BarsCount = 20; // количество баров канала
extern int Count = 5; // количество баров большой волатильности
extern int Magic = 333; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| 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;
datetime expiration=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);
}
if(type>1 && Expiration>0) expiration=TimeCurrent()+Expiration*3600;
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,expiration,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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DelOrder()
{
bool d;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()>1) d=OrderDelete(OrderTicket());
}
}
}
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Vol(int count)
{
double vol=0;
for(int i=1;i<=count;i++)
{
vol+=(High[i]-Low[i])/(Point*count);
}
return((int)vol);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double h=High[iHighest(NULL,0,MODE_HIGH,Count,0)];
double l=Low[iLowest(NULL,0,MODE_LOW,Count,0)];
if(CountTrades()<1 && Vol(Count)>Vol(BarsCount) && t!=Time[0])
{
if(CountOrders(4)<1 && Bid<h) PutOrder(4,h);
if(CountOrders(5)<1 && Bid>l) PutOrder(5,l);
t=Time[0];
}
if(CountTrades()>0) DelOrder();
Comment("\n Vol: ",Vol(BarsCount),
"\n Vol2: ",Vol(Count));
}
//+------------------------------------------------------------------+
extern int Level=2;
//+------------------------------------------------------------------+
//| Gold.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double KLot = 2; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern double Depo = 20000; // увеличенное депо
extern double Sup = 1000; // поддержка низы
extern double Res = 1500; // сопротивление верхи
extern int StopLoss = 5000; // лось
extern int TakeProfit = 5000; // язь
extern int Slip = 30; // реквот
extern int Count = 100; // максимальное количество поз
extern int Magic = 12; // магик
datetime t=0;
double Price=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;
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,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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Last()
{
int result=0;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderProfit()>0)
{
result=1;//tp
}
}
}
return(result);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll()
{
bool cl;
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) cl=OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Blue);
if(OrderType()==OP_SELL) cl=OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red);
}
}
}
return;
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(AccountEquity()>Depo)
{
CloseAll();
return;
}
if(CountTrades()<Count)
{
if(Bid>Sup && Bid<Res)
{
if(CountTrades()<1)
{
PutOrder(1,Bid);
PutOrder(0,Ask);
Price=Bid;
}
if(Last()==1 && (Bid>Price+TakeProfit*Point || Bid<Price-TakeProfit*Point))
{
PutOrder(1,Bid);
PutOrder(0,Ask);
Price=Bid;
}
}
}
Comment("\n Equity: ",DoubleToStr(AccountEquity(),Digits));
}
//+------------------------------------------------------------------+
<
VAHVAH не стой стороны
AM2