In Part 96 we wrapped our discussion of the OrderReliable group of functions. This time we’ll discuss the validation of your entry, TP & SL levels and trade sizes before you place your order.
There are many factors that go into validating your numbers before you place your order. Every broker has different minimums and maximums for trade size and the nearness of the SL and TP to the current price action. If you place a pending order too close to the market or the SL or TP is too close to the market or to your entry, the order will be rejected – which will require additional error trapping. I usually just validate the numbers before attempting to place the order instead of using error trapping. That’s not to say that I don’t do ANY error trapping. I just don’t trap for orders rejected due to any of the numbers being too close to the current market levels. I’ve never run into a problem doing things this way, but your mileage may vary. It can never hurt to have too much error trapping – as long as you’re wise about your error trapping techniques and don’t cause unnecessary error alerts.
The first thing I do is validate the trade size. The reason for starting here is that the trade size is unlikely to change dramatically in the few seconds you’re EA is doing the price calculations. Most of the necessary broker information needed for all this validation can be retrieved via the MarketInfo() function. The MarketInfo() function:
double MarketInfo(string symbol, int type);
returns a double value based upon the string symbol and integer type parameters you send it. The various values of type that pertain to the trade size are:
MODE_LOTSIZE – Lot size in the base currency (the first named currency in a currency pair.) This is usually 100,000, but may vary by broker.
MODE_MINLOT – Smallest lot size allowed. Some brokers will only allow a minimum of a minilot (0.10), but have a lot step of a microlot (0.01.)
MODE_MAXLOT – Maximum lot size allowed.
MODE_LOTSTEP – The lot size increment allowed (most often a microlot – 0.01.)
So, after you have determined the maximum size you can trade, you will need to run it through these filters to determine whether you have a valid trade size. If you try to execute a trade with an invalid trade size, it will just kick out an error, so you definitely want them validated before you start.
In our next installment, we’ll discuss sizing trades and looking at the code necessary to filter your trade sizes. Thanks for your attention and please follow me on Twitter and LinkedIn.
Latest posts by admin (see all)
- How To Plan a Trade From Start to Finish - May 3, 2016
- How To Trade The Eur/Usd Right Now - April 29, 2016
- Eur/Usd Could Move Higher Based off of Support Pin Bar - February 19, 2016
Winner’s Edge Trading, as seen on: