|
My first EA
Thanks to Eaglehawk for his help.
For a first EA, I have tried to begin very simple.
Buy if last bar close is higher than previous close.No sell, no Takeprofit, no stoploss and no trailing stop, thinking I will see the backtest chart full with buys, but nothing.
The EA was compiled without mistakes, and I have not any message of error.
What is wrong.
Thanks for help.
extern double MaxOpenTrade=4;
extern double Lots = 0.1;
extern double TakeProfit=25;
int start()
{
double CloseCurrent,ClosePrevious;
int total,ticket;
if(Bars<100)
{
Print("Moins de 100 bougies !");
return(0);
}
CloseCurrent= iClose(NULL,PERIOD_M15,0);
ClosePrevious=iClose(NULL,PERIOD_M15,1);
{
total=OrdersTotal();
if(OrdersTotal()<MaxOpenTrade)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("Il n y a pas suffisamment d argent. La marge disponible est ", AccountFreeMargin());
return(0);
}
if(CloseCurrent> ClosePrevious)
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,"Example Achat ",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("Ordre d ACHAT exécuté à : ",OrderOpenPrice());
}
else Print("Erreur à la création de l ordre ACHAT : ",GetLastError());
return(0);
return(0);
}
}}
|