In part 3 of this series, we discussed the three parts of the code for which we will have to plan. Now, we’re going to take a very simple strategy and discuss how it will fit into our EA.
In programming, just like trading and life in general, a good plan is always the best start for a project. So, we’re going to start right here with a plan for our EA. To start out, we’re not going to look at anything very complex, we’re just going to start with a simple moving average crossover EA. In other words, when one simple moving average (SMA) crosses a second SMA, we’ll take the trade in the direction of the cross. Again, for simplicity’s sake, we’ll set a fixed stop loss (SL) and take profit (TP) on our trade.
The first thing we need to determine is what variables we’ll be making available to the EA user at runtime (runtime is computer-speak and means exactly the way it sounds, the time when we actually run the program.) Making these variables available to the user is called making them External variables or in MT4 parlance, Inputs. Inputs will appear in the dialog box when you add the EA to the chart. They can also be manipulated by the Strategy Tester (we’ll discuss the Strategy Tester in a future Trader’s Tech article) for the purpose of optimizing your EA.
Since we will be allowing this EA to take trades, we’ll need to be able to tell it what size trade to take, so our first External variable needs to be LotSize. We will then need to specify the number of periods in our moving averages, so our next two variables should be MA1 and MA2.
Now we need to specify our stop loss and take profit levels. Since the only practical way to specify our stop loss and take profit is in pips from entry, this brings us to another topic of discussion. The difference between pips and what MT4 calls points. As many of you know, every MT4 platform is different – based on the broker that issues the feeds. That’s not to say the actual software is different, you can actually use a platform from one broker on another broker’s data feed. What makes them different is the data feed itself. Some brokers feed the data in pips (we typically refer to them as 4-digit brokers, even though the JPY pairs only have 2 digits after the decimal) and an increasing number of brokers use 10ths of a pip, sometimes known as pipettes or micro-pips – everyone has their own term for it. We call these 5-digit brokers. In MT4 terminology we call the smallest measurement of price a Point. So, if you have a 4-digit broker, a Point is equal to a Pip. If you have a 5-digit broker, a Point is equal to a 10th of a Pip. I know, it’s all very confusing and annoying. The difference between brokers on MT4 platforms gets even more confusing and annoying. We’ll get into that much later.
So, to keep this simple, we’ll specify the Stop Loss and Take Profit levels in Points. The user will have to know whether their broker uses Pips or Micro-pips. For future reference, the EA can be programmed to figure this out. We’ll discuss that in future articles. So the next two Extermal Variables we need will be SLPoints and TPPoints.
In our next installment, we’ll continue the discussion of planning our new EA. Thanks for your attention. Please follow me on Twitter.
Winner’s Edge Trading, as seen on: