bonjour,
j'ai préparé un EA sur croisement de moyenne mobile avec prix;
lorsque je fais les tests en mode visuel, des trades ont lieu.
Mais lorsque j'installe l'EA sur graphique (5 mn), le smiley est bien présent (avec sourire dans le bon sens), pourtant rien ne déclenche même après plusieurs jours;
Si qq'un peut m'aider à comprendre, merci d'avance;
Voici copie de l'EA:
#define MAGICMA 20050610
extern double Lots = 0.1;
extern double DecreaseFactor = 1;
extern double MovingPeriod = 7;
extern double MovingShift = 5;
extern int StopLoss = 75;
extern int TakeProfit = 210;
extern int TrailingStop = 10;
extern int period_RSI = 14;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//--------------------
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma;
int res;
double RSI = iRSI(NULL,0,period_RSI,PRICE_OPEN,0);
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_LWMA,P RICE_CLOSE,0);
//---- sell conditions
if(Open[1]>ma && Close[1]<ma && RSI < 50 )
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stop Loss*Point,Bid-TakeProfit*Point,"",MAGICMA,0,Red);
return;
}
//---- buy conditions
if(Open[1]<ma && Close[1]>ma && RSI > 50)
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA,0,B lue);
return;
}
//----
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_LWMA,P RICE_CLOSE,0);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
if(Open[0]>ma && Close[0]<ma) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
if(OrderType()==OP_SELL)
{
if(Open[0]<0 && Close[0]>ma) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
//----
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
//+------------------------------------------------------------------+
![]() |
|


LinkBack URL
About LinkBacks
Répondre avec citation