need help in my code "sell limit decreasing"

 

hello everyone, i'm trying to write  EA that decrease the current sell limit price every minute by one tick volume. but i  get errors always can anyone help.

the errors are:

'slippage' - undeclared identifier      bbbb.mq5        33      12
return value of 'OrderSend' should be checked   bbbb.mq5        37      4
'TRADE_RETCODE_DONE_REMAINDER' - undeclared identifier  bbbb.mq5        39      65

and the code is

input double Lots = 0.5;
input int Slippage = 2;
input int MagicNumber = 1234;

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

void OnTick()
  {
   static datetime lastExecution = 0;
   if(TimeCurrent() - lastExecution < 60)
      return;

   double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   double currentAsk = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double currentSellLimit = NormalizeDouble(currentAsk - tickSize, _Digits);

   MqlTradeRequest request;
   MqlTradeResult result;

   ZeroMemory(request);
   request.action = TRADE_ACTION_REMOVE;
   request.magic = MagicNumber;
   request.symbol = _Symbol;
   request.volume = Lots;
   request.price = currentSellLimit;
   request.slippage = Slippage;
   request.type = ORDER_TYPE_SELL_LIMIT;
   request.deviation = Slippage;

   OrderSend(request, result);

   if(result.retcode == TRADE_RETCODE_DONE || result.retcode == TRADE_RETCODE_DONE_REMAINDER)
     {
      lastExecution = TimeCurrent();
      Print("Sell limit order placed at ", currentSellLimit, " with ticket #", result.order);
     }
   else
     {
      Print("OrderSend error: ", GetLastError());
     }
  }
//+------------------------------------------------------------------+
 
Ali Thaer Tarteeb Tarteeb:

hello everyone, i'm trying to write  EA that decrease the current sell limit price every minute by one tick volume. but i  get errors always can anyone help.

the errors are:

and the code is


I change your code into this:

input double Lots = 0.5;
input int Slippage = 2;
input int MagicNumber = 1234;

void OnTick()
  {
   static datetime lastExecution = 0;
   if(TimeCurrent() - lastExecution < 60)
      return;

   double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   double currentAsk = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double currentSellLimit = NormalizeDouble(currentAsk - tickSize, _Digits);

   MqlTradeRequest request;
   MqlTradeResult result;

   ZeroMemory(request);
   request.action = TRADE_ACTION_REMOVE;
   request.magic = MagicNumber;
   request.symbol = _Symbol;
   request.volume = Lots;
   request.price = currentSellLimit;
   request.type = ORDER_TYPE_SELL_LIMIT;
   request.deviation = Slippage;

   if(OrderSend(request, result)) 
     {
      lastExecution = TimeCurrent();
      Print("Sell limit order placed at ", currentSellLimit, " with ticket #", result.order);
     }
   else
     {
      Print("OrderSend error: ", GetLastError());
     }
  }

And no error message on compiling.

Have a nice coding :-)