HeadbaY
Почетный гражданин
Кто нибудь может доработать сову, что бы она открывала сделки не на открытии 4 свечи после сигнала, а на первой(тоесть сразу после поступления сигнала)?
Посмотреть вложение Sefc.zip
Или в таком видео, подскажите что поменять?
Заранее спасибо.
Посмотреть вложение Sefc.zip
Или в таком видео, подскажите что поменять?
//+------------------------------------------------------------------+
//| StudySEFC.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern int SEFCPeriod = 32; //Period for SEFC088 indicator
extern int StopLoss = 9999; //Stop in points
extern int TakeProfit = 9999; //Target in points
extern int HourFrom = 0; //Start trade time filter
extern int HourTo = 23; //End trade time filter
extern double Lots = 0.01;
extern int Slippage = 2;
extern int MagicNumber = 101;
int Signal()
{
int Result=-1;
double sefcLime=iCustom(NULL,0,"SEFC088",SEFCPeriod,1,2);
double sefcRed =iCustom(NULL,0,"SEFC088",SEFCPeriod,2,2);
if(sefcLime!=0)
Result=OP_BUY;
else
if(sefcRed!=0)
Result=OP_SELL;
return(Result);
}
int EntrySignal()
{//Check for buy/sell conditions
int Result=Signal();
return(Result);
}
int ExitSignal()
{//Check for exit conditions
int Result=-1;
int st=Signal();
if(st==OP_BUY)
Result=OP_SELL;
else
if(st==OP_SELL)
Result=OP_BUY;
return(Result);
}
bool IsTradeTime()
{//Trade time filter
bool Result=false;
if((HourFrom<=HourTo && Hour()>=HourFrom && Hour()<=HourTo) ||
(HourFrom>HourTo && (Hour()>=HourFrom || Hour()<=HourTo)))
Result=true;
return(Result);
}
int init()
{
Print("Initialization with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
int deinit()
{
Print("Deinitialization with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
int start()
{
if (Digits < 4)
{ double pp = 0.01; double pm = 1;}
else
{ pp = 0.0001;pm = 10;}
static int LastTradeTime=0;
int i;
int PosCount=0;
//Trade only on trade time
if(!IsTradeTime())
{
Comment("\nNo trading time with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
else
Comment("\nTrading time with spread: ",DoubleToStr(Ask-Bid,Digits));
//Check for close
for(i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if((OrderSymbol() == Symbol()) && (OrderMagicNumber() == MagicNumber))
{
PosCount=PosCount+1;
if(ExitSignal()==OrderType())
if(OrderType()==OP_BUY)
{
if(OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,Digits), Slippage, Blue))
PosCount=PosCount-1;
}
else
if(OrderType()==OP_SELL)
{
if(OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,Digits), Slippage, Red))
PosCount=PosCount-1;
}
}
//Check for open
if(PosCount==0 && LastTradeTime!=iTime(NULL,0,1))
{
if(EntrySignal()==OP_BUY)
{
if(0<=OrderSend(Symbol(), OP_BUY, Lots, NormalizeDouble(Ask,Digits), Slippage,0, 0, "", MagicNumber,0,Blue))
LastTradeTime=iTime(NULL,0,1);
}
else
if(EntrySignal()==OP_SELL)
{
if(0<=OrderSend(Symbol(), OP_SELL, Lots, NormalizeDouble(Bid,Digits), Slippage, 0, 0, "", MagicNumber,0,Red))
LastTradeTime=iTime(NULL,0,1);
}
}
double min_rast=MarketInfo(Symbol(),MODE_STOPLEVEL)/pm;
int nnb=0;bool mb=false;int nns=0;bool ms=false;
for( int j=0; j<OrdersTotal(); j++)
{
if(OrderSelect(j, SELECT_BY_POS))
{
if( OrderSymbol() == Symbol()&&OrderMagicNumber( )== MagicNumber)
{
if(StopLoss<min_rast&&StopLoss!=0 ){Alert("увеличьте StopLoss");Sleep(10000);return(0);}
if(TakeProfit<min_rast&&TakeProfit!=0 ){Alert("увеличьте TakeProfit");Sleep(10000);return(0);}
if(OrderType() == OP_BUY)
{ //вычисляем стоплосс и такепрофит
if((OrderStopLoss( )==0&&StopLoss!=0 )||(OrderTakeProfit( )==0&&TakeProfit!=0) )
{double SLb=NormalizeDouble( OrderOpenPrice( )-StopLoss*pp,Digits);
if(StopLoss==0)SLb=OrderStopLoss( ) ;
double TPb=NormalizeDouble( OrderOpenPrice( )+ TakeProfit*pp,Digits);
if(TakeProfit==0)TPb=OrderTakeProfit( ) ;
while ( nnb < 5) {
mb=OrderModify(OrderTicket(), 0,SLb, TPb,Blue) ;
nnb++;
if(mb==true)break;
Sleep(1000);
}
}
}
if(OrderType() == OP_SELL)
{
if((OrderStopLoss( )==0&&StopLoss!=0 )||(OrderTakeProfit( )==0&&TakeProfit!=0) )
{ double SLs=NormalizeDouble( OrderOpenPrice( )+StopLoss*pp,Digits);
if(StopLoss==0)SLs=OrderStopLoss( ) ;
double TPs=NormalizeDouble( OrderOpenPrice( )- TakeProfit*pp,Digits);
if(TakeProfit==0)TPs=OrderTakeProfit( ) ;
while ( nns < 5) {
ms= OrderModify(OrderTicket(), 0, SLs,TPs,0) ;
nns++;
if(ms==true)break;
Sleep(1000);
}
}
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//| StudySEFC.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
extern int SEFCPeriod = 32; //Period for SEFC088 indicator
extern int StopLoss = 9999; //Stop in points
extern int TakeProfit = 9999; //Target in points
extern int HourFrom = 0; //Start trade time filter
extern int HourTo = 23; //End trade time filter
extern double Lots = 0.01;
extern int Slippage = 2;
extern int MagicNumber = 101;
int Signal()
{
int Result=-1;
double sefcLime=iCustom(NULL,0,"SEFC088",SEFCPeriod,1,2);
double sefcRed =iCustom(NULL,0,"SEFC088",SEFCPeriod,2,2);
if(sefcLime!=0)
Result=OP_BUY;
else
if(sefcRed!=0)
Result=OP_SELL;
return(Result);
}
int EntrySignal()
{//Check for buy/sell conditions
int Result=Signal();
return(Result);
}
int ExitSignal()
{//Check for exit conditions
int Result=-1;
int st=Signal();
if(st==OP_BUY)
Result=OP_SELL;
else
if(st==OP_SELL)
Result=OP_BUY;
return(Result);
}
bool IsTradeTime()
{//Trade time filter
bool Result=false;
if((HourFrom<=HourTo && Hour()>=HourFrom && Hour()<=HourTo) ||
(HourFrom>HourTo && (Hour()>=HourFrom || Hour()<=HourTo)))
Result=true;
return(Result);
}
int init()
{
Print("Initialization with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
int deinit()
{
Print("Deinitialization with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
int start()
{
if (Digits < 4)
{ double pp = 0.01; double pm = 1;}
else
{ pp = 0.0001;pm = 10;}
static int LastTradeTime=0;
int i;
int PosCount=0;
//Trade only on trade time
if(!IsTradeTime())
{
Comment("\nNo trading time with spread: ",DoubleToStr(Ask-Bid,Digits));
return(0);
}
else
Comment("\nTrading time with spread: ",DoubleToStr(Ask-Bid,Digits));
//Check for close
for(i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if((OrderSymbol() == Symbol()) && (OrderMagicNumber() == MagicNumber))
{
PosCount=PosCount+1;
if(ExitSignal()==OrderType())
if(OrderType()==OP_BUY)
{
if(OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,Digits), Slippage, Blue))
PosCount=PosCount-1;
}
else
if(OrderType()==OP_SELL)
{
if(OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,Digits), Slippage, Red))
PosCount=PosCount-1;
}
}
//Check for open
if(PosCount==0 && LastTradeTime!=iTime(NULL,0,1))
{
if(EntrySignal()==OP_BUY)
{
if(0<=OrderSend(Symbol(), OP_BUY, Lots, NormalizeDouble(Ask,Digits), Slippage,0, 0, "", MagicNumber,0,Blue))
LastTradeTime=iTime(NULL,0,1);
}
else
if(EntrySignal()==OP_SELL)
{
if(0<=OrderSend(Symbol(), OP_SELL, Lots, NormalizeDouble(Bid,Digits), Slippage, 0, 0, "", MagicNumber,0,Red))
LastTradeTime=iTime(NULL,0,1);
}
}
double min_rast=MarketInfo(Symbol(),MODE_STOPLEVEL)/pm;
int nnb=0;bool mb=false;int nns=0;bool ms=false;
for( int j=0; j<OrdersTotal(); j++)
{
if(OrderSelect(j, SELECT_BY_POS))
{
if( OrderSymbol() == Symbol()&&OrderMagicNumber( )== MagicNumber)
{
if(StopLoss<min_rast&&StopLoss!=0 ){Alert("увеличьте StopLoss");Sleep(10000);return(0);}
if(TakeProfit<min_rast&&TakeProfit!=0 ){Alert("увеличьте TakeProfit");Sleep(10000);return(0);}
if(OrderType() == OP_BUY)
{ //вычисляем стоплосс и такепрофит
if((OrderStopLoss( )==0&&StopLoss!=0 )||(OrderTakeProfit( )==0&&TakeProfit!=0) )
{double SLb=NormalizeDouble( OrderOpenPrice( )-StopLoss*pp,Digits);
if(StopLoss==0)SLb=OrderStopLoss( ) ;
double TPb=NormalizeDouble( OrderOpenPrice( )+ TakeProfit*pp,Digits);
if(TakeProfit==0)TPb=OrderTakeProfit( ) ;
while ( nnb < 5) {
mb=OrderModify(OrderTicket(), 0,SLb, TPb,Blue) ;
nnb++;
if(mb==true)break;
Sleep(1000);
}
}
}
if(OrderType() == OP_SELL)
{
if((OrderStopLoss( )==0&&StopLoss!=0 )||(OrderTakeProfit( )==0&&TakeProfit!=0) )
{ double SLs=NormalizeDouble( OrderOpenPrice( )+StopLoss*pp,Digits);
if(StopLoss==0)SLs=OrderStopLoss( ) ;
double TPs=NormalizeDouble( OrderOpenPrice( )- TakeProfit*pp,Digits);
if(TakeProfit==0)TPs=OrderTakeProfit( ) ;
while ( nns < 5) {
ms= OrderModify(OrderTicket(), 0, SLs,TPs,0) ;
nns++;
if(ms==true)break;
Sleep(1000);
}
}
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Последнее редактирование: