25.10.2016 Views

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Order Conditions and Indicators<br />

You could also generate trade signals when the current price passes above or below an indicator line.<br />

For example, the Bollinger Bands indicator can be used to generate trading signals based on the<br />

location of the price in comparison to the upper and lower bands.<br />

Oscillators<br />

The other major type of indicator is an oscillator. Oscillators are drawn in a separate window, and as<br />

their name suggests, they oscillate between high and low price extremes. Oscillators are either<br />

centered around a neutral axis (generally 0), or they are bound <strong>by</strong> an upper or lower extreme (such<br />

as 0 and 100). Examples of oscillators include momentum, stochastics and RSI.<br />

Oscillators indicate overbought and oversold levels. While they can be used as an indicator of trend,<br />

they are generally used to locate areas of pending reversal. These are used to produce counter-trend<br />

trading signals.<br />

Let's look at a popular oscillator, the stochastic. Stochastics consists of two lines, the stochastic line<br />

(also called the %K line), and the signal line (the %D line). The stochastic oscillates between 0 and<br />

100. When the stochastic is above 70, it is said to be overbought, and pending a possible reversal. If<br />

it is below 30, it is said to be oversold.<br />

Here is the syntax for the stochastic indicator:<br />

double iStochastic(string Symbol, int Timeframe, int KPeriod, int Dperiod, int Slowing,<br />

int MAMethod, int PriceField, int Mode, int Shift)<br />

We're already familiar with the first two parameters, Symbol and Timeframe. Let's examine the<br />

indicator-specific parameters:<br />

• KPeriod – The period for the %K line.<br />

• DPeriod – The period for the %D line.<br />

• Slowing – The slowing value for the stochastic. A lower value indicates a fast stochastic,<br />

while a higher value indicates a slower one.<br />

• MAMethod – The %D line has a moving average method applied to it. This is the same<br />

setting as for the moving average. We'll review the moving average methods shortly.<br />

• PriceField – Determines the price data used for the %K line. This is either 0: Low/High or 1:<br />

Close/Close. A value of 1 makes it more likely that the stochastic will trade at it's extremes.<br />

• Mode – Determines the stochastic line to calculate – 1: %K line, or 2: %D line.<br />

97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!