Download MetaTrader 5

What is wrong with my OrderSend ?

To add comments, please log in or register
SteelAce
202
SteelAce  

My code is (in attachment also):


//+------------------------------------------------------------------+
//|                                                     MakeDeal.mq5 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void MakeDeal(string Side) {
   double Volume=10.0;
   MqlTradeRequest Request;
   MqlTradeResult Result;
   Request.action=TRADE_ACTION_DEAL;
   Request.symbol="EURUSD";
   Request.type_filling=ORDER_FILLING_FOK;
   Request.volume=Volume;
   Request.tp=Volume/10;
   Request.sl=Volume/10;
   Request.price=14.0;
   Request.deviation=0.0;
   Request.type_time=ORDER_TIME_SPECIFIED;
   Request.expiration=6*60;
   if(Side=="Up")     {Request.type=ORDER_TYPE_BUY;}
   if(Side=="Down") {Request.type=ORDER_TYPE_SELL;}
   if (!OrderSend(Request,Result)) {
     Print(" error: order rejected : " + IntegerToString(Result.retcode));
     }
   }
void OnStart()
  {
//---
   MakeDeal("Up");
   }

//+------------------------------------------------------------------+


It gives error Result.retcode : 10016 - Invalid stops in the request. Can anybody explain what it means or simply say what is wrong with my OrderSend?


In other words I need just working simple OrderSend sample. I have seen samples but I want to start with easiest one. Because I didn't find easy one I am trying to create it myself.

Thanks!

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
MakeDeal.mq5 2 kb
Alain Verleyen
Moderator
32811
Alain Verleyen  

Why are you thinking you can set sl/tp this way ?

   Request.tp=Volume/10;
   Request.sl=Volume/10;
To add comments, please log in or register