Expert Advisor Strategy Design - In this article learn how to build entry techniques and set-up pending stop entry orders and pending limit entry orders.
All entry techniques are dependent on the three order types: market order, stop order and limit order. As stressed before, most strategies should be constructed and tested using the market entry order. The market order is guaranteed to get you into the market when the conditions of your setup are met, unlike the pending limit entry which does not always get you in, or the pending stop entry order which can get you in too late.
Having traded a long time, I am very market order biased. That being said, it does not hurt to experiment with the two pending order entry techniques (limit and stop) to see if they can enhance your strategy that was initially constructed and tested to be promising with a market order.
As a strategy purist, I think that a good entry technique should could consist of two rules:
Pending Stop entry order: Pros and Cons
By its nature, the pending stop entry order requires the market to pass through a predetermined level above the market for a buy or below the market for a sell.
Pros: The advantage of having such an entry trigger, versus none at all (market order generated from setup), is that you may avoid some false signals. Market orders can get you in early enough, but they can also get you into fake outs. These breakout stop levels are set out to confirm direction of the trending setup, and thus fulfill rule #1 and rule #2 above, increasing trade reliability.
Cons: The disadvantage of having such a strategy is that you might enter the order too late, entering not at the original setup but a distance away from it, after the market had already moved in the direction of the trend or reversal. You are thus gaining a confirmation advantage, which increases trade reliability, but at the cost of losing out on potential pip profit if you had taken an earlier market order.
Pending Limit Entry Order: Pros and Cons:
Limit orders are the opposite of stop orders. The limit buy is priced below the current market and the limit sell is placed above. With trend following strategies, limit orders require prices to be traveling in a direction opposite the set-up. For instance, if you are supposed to be long when the fast moving average crosses above the slow moving average, a limit order requires the market to first retrace for a few pips from point of crossover before you are able to enter the trade.
Pros: Limit oders can get you in at better price than market order and thus can earn you more pips if market retraces back to your limit. The pending limit order can be used in conjunction with a counter-trend or retracement type strategies and be compliant with the rules above. Since both counter-trend and retracement strategies require the market to retract in price before entering, the limit order acts in a complimentary fashion, because it too requires a retracement in price.
Cons: With trend following systems, the limit order violates entry rule #1 because it does not force prices to move in the direction of the set-up before entry. It also violates rule #2 because if the price does not reach the limit, it fails to catch the move it was designed to catch. Because outfitting limit orders on trend based strategies violates entry rules #1 and #2, they generally pollute rather than enhance such strategies. As illustration, I will outfit my trend following MA Crossover strategy with a limit order to show you how it will degrade the strategy.
Before we get into experimenting with two pending entry techniques, it is appropriate to establish the baseline, the strategy results prior to experiments.
Here is the 25-250 SMACross from Jan-1999 to Jan-2012:
For a simple stop and reverse system, performance numbers of this strategy are excellent. With profit factor of 1.76, and total net profit of $8139 with $2243 DD, the strategy is very strong. Let us see if adding a pending stop or limit can improve or hinder the performance.
Pending Stop Entry Order Experiment: Stop Entry Order +/- 20 pip gap in direction established by setup.
There are many different ways to build a pending stop entry order, but we will start with the bare bones: when the strategy setup generates the buy signal, a stop entry order will be placed +20 pips above the current price, to expire in one day (1440 minutes).When the strategy generates a sell signal, a stop entry order will be placed 20 pips below the current price, to expire in one day.The reason why this could be a viable entry is that the stop entry 20 pips above or below confirms the direction of the market as indicated by the setup. It could potentially catch most of the trends and yet avoid some whipsaws.
For a buy signal:
In regular language:
If setup confirms a long signal, then entry technique is buy stop +20 pip gap above ask price.
If setup confirms a short signal, then entry technique is sell stop -20 pip gap above ask price.
In MQL code:
if(stoporders)if(time2!=Time[0]){RefreshRates();ticket=open(OP_BUYSTOP,blots,Ask+
gap*pt,stoploss,takeprofit,expire,Blue);
Note: once the stoporders=true condition has been set, then the strategy will initiate its stop orders +/- 20 pip gap.
Since the buy stop already works with the gap technique, you do not need to program that.
The only customizable features you may want to experiment with are expiration of pending orders and gap pip length.
This is what the external code will like in the properties tab:
Before the instantorders was set to true, and the stoporders and limitorders was false. Now the stoporders is set to true and the instantorders is set to false.
Expiration = 1440 (default – means that pending orders will expire in a day, 240 means they will expire in 4 hours, 60 means in one hour, etc., and 0 means never to expire).
Gap = 20 (default—means that the gap is set for 20 pips above buy ask, or 20 pips below sell bid).
We will keep the expiration and gap defaults as is for now.
Here are the results for the 25-250 SMACross outfitted with the 20pip gap stop from Jan-99 to Jan-2012:
You can see that the performance is cut in half. With the entry technique, the net return is half ($3.1K versus the default of $7434), profit is 30 points less (1.26 versus default of 1.63), and DD had a slight increase (from 1.8K to 2K). It seems that the breakout excluded 22 trades from the history, and some of these excluded trades had a significant impact.
The stop breakout strategy can theoretically aid a strategy by making sure the price confirms the direction of the setup; however, in practice the entry technique undermines these moving average strategies on the H4 timeframe. The market order setup is superior in its simplicity.
Entry Technique Experiment: Limit Order +/- 20 pip gap in direction of MACross
As mentioned before, the limit order technique is not often employed because it often violates the 2 entry rules above. Limit orders do not force prices to move in the direction of the setup, and they sometimes fail to catch the move strategy was designed to catch. Because of these limitations the limit order will generally undermine a trend-following strategy. Let us show you how it does so by turning our 20 pip stop gap into a 20 pip limit gap.
For a buy signal:
In regular language:
If setup confirms a long signal, then entry technique is buy limit -20 pip gap below ask price.
For a sell signal:
In regular language:
If setup confirms a short signal, then entry technique is sell limit +20 pip gap above bid price.
In MQL code:
if(limitorders)if(time3!=Time[0]){RefreshRates();ticket=open(OP_BUYLIMIT,blots,Bid-
gap*pt,stoploss,takeprofit,expire,Blue);
For a sell signal:
In regular language:
If setup confirms a short signal, then entry technique is sell limit +20 pip gap above bid price.
In MQL code:
if(limitorders)if(time5!=Time[0]){RefreshRates();ticket=open(OP_SELLLIMIT,slots,Ask+
gap*pt,stoploss,takeprofit,expire,Red);
Note: once the limitorders=true condition has been set, then the strategy will initiate its limit orders +/- 20 pip gap.
Since the buy limit already works with the gap technique, you do not need to program that.
The only customizable features you may want to experiment with are expiration of pending orders and gap pip length.
This is what the external code will like in the properties tab:
Before the instantorders was set to true, and the stoporders and
limitorders was false. Now the limitorders is set to true and the
instantorders is set to false.
We will keep the expiration and gap defaults as is for now.
Here are the results for the 25-250 SMACross of Method2 outfitted with the 20pip gap limit from 01.01.2000 to 08.20.2010:
You can see that this otherwise excellent strategy was completely gutted with the addition of a simple 20 pip gap limit entry technique. Its 7.4K net profit fell to -1.4K, its strong 1.64 PF turned into an abysmal 0.84, and its maximal drawdown increased by $600. The limit technique took all the good away and made it into a terrible strategy one could trade in reverse.
Conclusion
As we have seen, a setup by itself without the addition of any entry technique is sometimes the most effective approach. In fact, our experimentation with stop and limit entry techniques with our MACross strategies proved that they can severely undermine the original performance. It is our belief that if the strategy cannot be improved by a gap entry on stop or limit, then it cannot be improved by any stop or limit mechanism, no matter how sophisticated.
Some writers on strategy development have thought that that the pending entry mechanism was the forgotten side or missing link in creating a good strategy. Using the gun metaphor, the setup is the scope and the pending entry is the trigger. It is a nice metaphor
but it gives too much credit to the entry technique. I would counter that the the setup in its bare bones simplicity can be the scope and the trigger — you don’t won’t to add any unnecessary components to cause it to backfire.
This does not mean that a sophisticated stop or limit mechanism cannot enhance any strategy. Some stop entry strategies might do best with a trendline based strategy, and some limit entry strategies might do best with counter-trend strategies. Whenever you attempt to build a strategy, you should try an experimentation with various stop or limit mechanisms in order to see if they can enhance the strategy or not.