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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Order Conditions and Indicators<br />

• PRICE_LOW – 3: Low price.<br />

• PRICE_MEDIAN – 4: Median price, (High+Low)/2.<br />

• PRICE_TYPICAL – 5: Typical price, (High+Low+Close)/3.<br />

• PRICE_WEIGHTED – 6: Weighted price, (High+Low+Close+Close)/4.<br />

Moving Average Methods<br />

Indicators that use a moving average as part of their calculation may have a parameter to adjust the<br />

moving average calculation method. The moving average line will be drawn differently depending on<br />

the calculation method. Here are the moving average method constants with their corresponding<br />

integer values:<br />

• MODE_SMA – 0: Simple moving average. Calculates the mean of the price data.<br />

• MODE_EMA – 1: Exponential moving average. Gives more weight to recent price data, and<br />

exponentially less weight to older price data. A very popular moving average.<br />

• MODE_SMMA – 2: Smoothed moving average. A simple moving average calculated with a<br />

smoothing equation. Creates a smooth, but less responsive line.<br />

• MODE_LWMA – 3: Linear weighted moving average. Similar to the exponential moving<br />

average, but gives increased weight to the most current price.<br />

Evaluating Trade Conditions<br />

We use the conditional operators if and else to evaluate our trading conditions. You've already seen<br />

these used in this book, but for you new programmers, a quick review is in order.<br />

The if operator evaluates a true or false condition. If the condition is true, the code immediately<br />

after the if statement is executed. If the condition is false, it will skip ahead to the code following<br />

the if block:<br />

if(BuyCondition == true)<br />

{<br />

OpenBuyOrder(...);<br />

}<br />

If there is only one statement following the if operator, it can be written like this:<br />

if(BuyCondition == true) OpenBuyOrder(...);<br />

103

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

Saved successfully!

Ooh no, something went wrong!