It is a better idea to indent your brackets then you can see what's wrong.
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money");
return(0);
OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
OrderSend("USDCHF",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
}
trying to send order when there is no money.
It is a better idea to indent your brackets then you can see what's wrong.
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money");
return(0);
OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
OrderSend("USDCHF",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
}
trying to send order when there is no money.
Unfortunately, nothing is happening, after activation EA just sits there and laughs at me with the smiley face but does not open any trades
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want my EA to place both EURUSD and USDCHF buy orders simultaneously, then close when it's in profit (in any way) by 10 pips and then immediately place two new buy orders and so on. However, it wouldn't do anything when I place EA on a EURUSD chart. Could anybody provide some insight?
extern double TakeProfit = 10;
extern double Lots = 0.1;
double Points;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init ()
{
Points = MarketInfo (Symbol(), MODE_POINT);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int cnt=0, total;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(OrdersTotal()<1)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money");
return(0);
OrderSend("EURUSD",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
OrderSend("USDCHF",OP_BUY,Lots,Ask,3,0,"Hedge",16384,0,Red);
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0);
}
return(0);
}
total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_BUY &&
OrderSymbol()=="EURUSD" && OrderSymbol()=="USDCHF")
{
if(((iClose("EURUSD",PERIOD_M1,0))-(iClose("USDCHF",PERIOD_M1,0))>TakeProfit*Point) ||
((iClose("USDCHF",PERIOD_M1,0))-(iClose("EURUSD",PERIOD_M1,0))>TakeProfit*Point) ||
((iClose("USDCHF",PERIOD_M1,0))+(iClose("EURUSD",PERIOD_M1,0))>TakeProfit*Point))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(0);
}
}
}
return(0);
}