Download MetaTrader 5

how to know what is the minimum of stoploss

To add comments, please log in or register
Fa Cao
1141
Fa Cao 2013.11.14 03:20 

when I use "ordersend" to open orders as below:

OrderSend(Symbol(),OP_BUY,lots,OrderClosePrice()+100*Point,3,0,0,0,0,0,0);

Sometime MT4 will complain that the stoploss is too little, but I don't know how to know what is the minimum for some pair's stoploss.

another question: about messagebox

#property show_inputs
#include <WinUser32.mqh>

extern int open_time=0; // time of opening orders
extern int lots=0; // lots of new orders
extern int trade_sign=0; //mark "buy" or "sell" of new orders


int start()
  {
//warning if time of opening is not set at the beginning.
   if (open_time==0||lots==0)
   int note=MessageBox("Please set opening time and lots at first!","Alert Message",MB_YESNO|MB_ICONEXCLAMATION);
   if (note==IDOK) 
   return (0);
........
   }

when I execute this EA and without any assignment, then the messagebox will come out for complaining that"please set opening time and lots at first", then I click OK button and then i will get the complain again.

so my question is how I shall have a chance to assign variable--"open_time" and "lots" again after I have attached this EA.

Keith Watford
Moderator
9639
Keith Watford 2013.11.14 06:04  
vx0532:


so my question is how I shall have a chance to assign variable--"open_time" and "lots" again after I have attached this EA.


Click on the smiley face and amend the input parameters
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.11.14 08:34  
vx0532:

when I use "ordersend" to open orders as below:

OrderSend(Symbol(),OP_BUY,lots,OrderClosePrice()+100*Point,3,0,0,0,0,0,0);

Sometime MT4 will complain that the stoploss is too little, but I don't know how to know what is the minimum for some pair's stoploss.

You need your code to check the open price, SL and TP comply with these requirements, that way you avoid errors rather than having to retry or miss a trade: Requirements and Limitations in Making Trades
whroeder1
14742
whroeder1 2013.11.14 13:55  
vx0532: when I use "ordersend" to open orders as below:
OrderSend(Symbol(),OP_BUY,lots,OrderClosePrice()+100*Point,3,0,0,0,0,0,0);
when I execute this EA and without any assignment, then the messagebox will come out for complaining that"please set opening time and lots at first", then I click OK button and then i will get the complain again.
  1. You can NOT use OrderClosePrice() until you do a successful OrderSelect. How do you expect to select the order, when you haven't even sent it yet?
  2. Of course you get the complaint again. A tick comes in, lots=0, you put up the message. Once you press the OK button you have to call up the EA's parameters to change them BEFORE the next tick or you are right back at the message box. A) Add a time stamp on when you received the OK and stop opening the box to give the human time to do it, or B) have the EA open the parameter box via postMessage.
  3.    if (open_time==0||lots==0)
    {
       int note=MessageBox("Please set opening time and lots at first!","Alert Message",MB_YESNO|MB_ICONEXCLAMATION);
       if (note==IDOK) 
       return (0);
    }
    
    Missing braces
Fa Cao
1141
Fa Cao 2013.11.15 01:35  
WHRoeder:
  1. You can NOT use OrderClosePrice() until you do a successful OrderSelect. How do you expect to select the order, when you haven't even sent it yet?
  2. Of course you get the complaint again. A tick comes in, lots=0, you put up the message. Once you press the OK button you have to call up the EA's parameters to change them BEFORE the next tick or you are right back at the message box. A) Add a time stamp on when you received the OK and stop opening the box to give the human time to do it, or B) have the EA open the parameter box via postMessage.
  3. Missing braces


yes, you are right.

but I can't understand "B) ", shall I get detail code for this?

To add comments, please log in or register