extern int EquityRisk = 0; //Стоп по средствам в %
extern int EquityProfit = 0; //Тейк по средствам в %
extern int Profit = 0; //Профит в долларах
extern int EquityRisk = 0; //Стоп по средствам в %
extern int EquityProfit = 0; //Тейк по средствам в %
extern int Profit = 0; //Профит в долларах
Андрей немножечко не так сигнал на покупку или продажу когда два индикатора точнее начало индикаторов появляються в одной точке наодной свече или между двумя свечами также начало индюков может немножечко сдинуты
Осталось только фибо под волны подстроить
//+------------------------------------------------------------------+
//| FiboLevels.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 int StopLoss = 500; //лось
extern int TakeProfit = 500; //язь
extern int Delta = 100; //проход цены
extern int Slip = 10; //проскальзывание
extern int Expiration = 10; //время истечения ордера
extern int Magic = 123; //магик
extern double Lots = 1; //лот
int cross=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=clrNONE;
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*3600,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);
}
//+------------------------------------------------------------------+
//| Cоздает "Уровни Фибоначчи" по заданным координатам |
//+------------------------------------------------------------------+
void FiboLevelsCreate(datetime t1,double p1,datetime t2,double p2)
{
ObjectsDeleteAll(0,OBJ_FIBO);
//--- создадим "Уровни Фибоначчи" по заданным координатам
ObjectCreate(0,"FiboLevels",OBJ_FIBO,0,t1,p1,t2,p2);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CrossUP(double p)
{
int res=0;
if(Open[0]<p && Bid-p>=Delta*Point) res=1;
return(res);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CrossDN(double p)
{
int res=0;
if(Open[0]>p && p-Bid>=Delta*Point) res=1;
return(res);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(IsTesting())
{
double up=iHigh(NULL,PERIOD_D1,1);
double dn=iLow(NULL,PERIOD_D1,1);
FiboLevelsCreate(Time[1],up,Time[15],dn);
}
string name="FiboLevels";
/*
for(int i=ObjectsTotal()-1; i>=0; i--)
{
name=ObjectName(i);
}
*/
double F = ObjectGet(name, OBJPROP_PRICE1);
double S = ObjectGet(name, OBJPROP_PRICE2);
double p0=NormalizeDouble(S,Digits);
double p100 = NormalizeDouble(F, Digits);
double p236 = NormalizeDouble((F-S)*0.236+S, Digits);
double p382 = NormalizeDouble((F-S)*0.382+S, Digits);
double p50=NormalizeDouble((F-S)*0.50+S,Digits);
double p618=NormalizeDouble((F-S)*0.618+S,Digits);
if(High[1]>p50 && Low[1]<p50) cross=1;
if(Hour()==5) cross=0;
if(CountTrades()<1)
{
if(CountOrders(4)<1 && CrossDN(p50)==1) PutOrder(4,p50);
if(CountOrders(5)<1 && CrossUP(p50)==1) PutOrder(5,p50);
}
Comment("\n Fibo 100: ",p100,
"\n Fibo 0: ",p0,
"\n Fibo 236: ",p236,
"\n Fibo 382: ",p382,
"\n Fibo 50: ",p50,
"\n Fibo 618: ",p618,
"\n Name: ",name,
"\n Cross: ",cross,
"\n CrossUP: ",CrossUP(p50),
"\n CrossDN: ",CrossDN(p50));
}
//+------------------------------------------------------------------+
На самом деле все простенько. 1 — фильтр, 1 точка входа, а дальше как и у всех советников ММ, профит, стоплосс…
//+------------------------------------------------------------------+
//| FiboLevels.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 StopLoss = 500; //лось
extern double TakeProfit = 500; //язь
extern int Delta = 100; //проход цены
extern int Slip = 10; //проскальзывание
extern int Expiration = 10; //время истечения ордера
extern int Magic = 123; //магик
extern double Lots = 1; //лот
//+------------------------------------------------------------------+
//| 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=clrNONE;
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*3600,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);
}
//+------------------------------------------------------------------+
//| Cоздает "Уровни Фибоначчи" по заданным координатам |
//+------------------------------------------------------------------+
void FiboLevelsCreate(datetime t1,double p1,datetime t2,double p2)
{
ObjectsDeleteAll(0,OBJ_FIBO);
//--- создадим "Уровни Фибоначчи" по заданным координатам
ObjectCreate(0,"FiboLevels",OBJ_FIBO,0,t1,p1,t2,p2);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(IsTesting())
{
double up=iHigh(NULL,PERIOD_D1,1);
double dn=iLow(NULL,PERIOD_D1,1);
FiboLevelsCreate(Time[1],up,Time[15],dn);
}
string name="FiboLevels";
/*
for(int i=ObjectsTotal()-1; i>=0; i--)
{
name=ObjectName(i);
}
*/
double F = ObjectGet(name, OBJPROP_PRICE1);
double S = ObjectGet(name, OBJPROP_PRICE2);
double p0 = NormalizeDouble(S, Digits);
double p100 = NormalizeDouble(F, Digits);
double p236 = NormalizeDouble((F-S)*0.236+S, Digits);
double p382 = NormalizeDouble((F-S)*0.382+S, Digits);
double p50 = NormalizeDouble((F-S)*0.50+S, Digits);
double p618 = NormalizeDouble((F-S)*0.618+S, Digits);
if(CountTrades()<1)
{
if(CountOrders(4)<1 && p50-Bid>=Delta*Point) PutOrder(4,p50);
if(CountOrders(5)<1 && Bid-p50>=Delta*Point) PutOrder(5,p50);
}
Comment("\n Fibo 100: ",p100,
"\n Fibo 0: ",p0,
"\n Fibo 236: ",p236,
"\n Fibo 382: ",p382,
"\n Fibo 50: ",p50,
"\n Fibo 618: ",p618,
"\n Name: ",name);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Bozy.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 int StopLoss = 2000; // лось
extern int TakeProfit = 300; // язь
extern int TrailingStop = 300; // трал
extern int Slip = 30; // реквот
extern int Shift = 1; // сдвиг
extern int Magic = 123; // магик
extern string IndName1="BBands_Stop_v1";
extern string s=" ------ BBands_Stop_v1 -----";
extern int Length=20; // Bollinger Bands Period
extern int Deviation=2; // Deviation was 2
extern string IndName2="Ozy";
extern string ss=" ------ Ozy -----";
extern int Period_1 = 2;
extern int Period_2 = 2;
extern string sss=" ------------- Настройки 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()
{
//---
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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OpenPos()
{
bool buy,sell;
double BBBlue=iCustom(NULL,0,IndName1,Length,Deviation,0,Shift);
double BBRed=iCustom(NULL,0,IndName1,Length,Deviation,1,Shift);
double BBBlue2=iCustom(NULL,0,IndName1,Length,Deviation,0,Shift+1);
double BBRed2=iCustom(NULL,0,IndName1,Length,Deviation,1,Shift+1);
double OzyBlue=iCustom(NULL,0,IndName2,Period_1,Period_2,0,Shift);
double OzyRed=iCustom(NULL,0,IndName2,Period_1,Period_2,1,Shift);
double macd=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,Shift);
if(MACD==0)
{
buy = BBBlue>0 && BBRed2>0 && OzyBlue>0;
sell = BBRed>0 && BBBlue2>0 && OzyRed>0;
}
if(MACD==1)
{
buy = BBBlue>0 && OzyBlue>0 && BBRed2>0 && macd>0;
sell = BBRed>0 && OzyRed>0 && BBBlue2>0 && macd<0;
}
//--- sell conditions
if(sell)
{
PutOrder(1,Bid);
}
//--- buy conditions
if(buy)
{
PutOrder(0,Ask);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void ClosePos()
{
bool buy,sell;
double BBBlue=iCustom(NULL,0,IndName1,Length,Deviation,0,Shift);
double BBRed=iCustom(NULL,0,IndName1,Length,Deviation,1,Shift);
double BBBlue2=iCustom(NULL,0,IndName1,Length,Deviation,0,Shift+1);
double BBRed2=iCustom(NULL,0,IndName1,Length,Deviation,1,Shift+1);
double OzyBlue=iCustom(NULL,0,IndName2,Period_1,Period_2,0,Shift);
double OzyRed=iCustom(NULL,0,IndName2,Period_1,Period_2,1,Shift);
double macd=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,Shift);
if(MACD==0)
{
buy = BBBlue>0 && BBRed2>0 && OzyBlue>0;
sell = BBRed>0 && BBBlue2>0 && OzyRed>0;
}
if(MACD==1)
{
buy = BBBlue>0 && OzyBlue>0 && BBRed2>0 && macd>0;
sell = BBRed>0 && OzyRed>0 && BBBlue2>0 && macd<0;
}
//---
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(sell)
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slip,White))
Print("OrderClose error ",GetLastError());
}
}
if(OrderType()==OP_SELL)
{
if(buy)
{
if(!OrderClose(OrderTicket(),OrderLots(),Ask,Slip,White))
Print("OrderClose error ",GetLastError());
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
}
}
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Trailing()
{
bool mod;
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
if(Bid-OrderOpenPrice()>TrailingStop*Point)
{
if(OrderStopLoss()<Bid-TrailingStop*Point)
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
if(OrderType()==OP_SELL)
{
if((OrderOpenPrice()-Ask)>TrailingStop*Point)
{
if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double BBBlue=iCustom(NULL,0,IndName1,Length,Deviation,0,Shift);
double BBRed=iCustom(NULL,0,IndName1,Length,Deviation,1,Shift);
double OzyBlue=iCustom(NULL,0,IndName2,Period_1,Period_2,0,Shift);
double OzyRed=iCustom(NULL,0,IndName2,Period_1,Period_2,1,Shift);
double macd=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,Shift);
if(CountTrades()<1)
{
OpenPos();
}
else ClosePos();
if(TrailingStop>0) Trailing();
Comment("\n OzyBlue: ",OzyBlue,
"\n OzyRed: ",OzyRed);
}
//+------------------------------------------------------------------+
условия входа если на одной свече совпадают два сигнала индикаторов BBands_Stop_v1 и Ozy как на скрине
AM2