I’m trying to make an EA that can take a short trade when the price is below a certain MA level
How do I get the EA to create one sell order instead of many sell orders?
How do I get the EA to create one sell order instead of many sell orders?
PHP Code
//---- input parameters extern double TakeProfit=130; extern double StopLoss = 100; extern double Lots=1; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int ticket, total; if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } static int isCrossed = 0; if (Close[1] < iMA(NULL, NULL,55,0,MODE_EMA,PRICE_CLOSE,1)) { isCrossed = 1; } total = OrdersTotal(); if(total < 1) { if(isCrossed == 1) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMA",12345,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); return(0); } } }
Blindly following others will make you blind!