Log in to see Cloud of Tags

Wealth-Lab Wiki

Syntax

public static SMA Series(WealthLab.DataSeries ds, int period) public SMA(DataSeries ds, int period, string description) public static double Value(int bar, DataSeries ds, int period)

Parameter Description

ds The source DataSeries
period Indicator calculation period

Description

SMA returns the Simple Moving Average indicator. Moving averages are some of the core indicators in technical analysis, and there are a variety of different versions (EMA, WMA, WilderMA, etc. SMA is the easiest moving average to construct. It is simply the average price over the specified period. The average is called "moving" because it is plotted on the chart bar by bar, forming a line that moves along the chart as the average value changes over the most-recent period.

Interpretation

  • SMAs are often used to determine Trend Direction. If the SMA is moving up, the trend is up, moving down and the trend is down. A 200 bar SMA is common proxy for the long term trend. 60 bar SMAs are typically used to gauge the intermediate trend. Shorter period SMAs can be used to determine shorter term trends.
  • SMAs are commonly used to smooth price data and technical indicators. Applying an SMA smoothes out choppy data. The longer the period of the SMA, the smoother the result, but the more lag that is introduced between the SMA and the source.
  • SMA Crossing Price is often used to trigger trading signals. When prices cross above the SMA go long, when they cross below the SMA go short.
  • SMA Crossing SMA is another common trading signal. When a short period SMA crosses above a long period SMA, go long. Go short when the short term SMA crosses back below the long term.

Calculation

SMA is simply the mean, or average, of the values in a DataSeries over the specified period.

Example

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // An SMA Crossover system int FastPer = 40; int SlowPer = 100; DataSeries hFast = SMA.Series( Close, FastPer ); DataSeries hSlow = SMA.Series( Close, SlowPer );

PlotSeries( PricePane, hFast, Color.Red, WealthLab.LineStyle.Solid, 1 ); PlotSeries( PricePane, hSlow, Color.Blue, WealthLab.LineStyle.Solid, 1 ); for(int bar = SlowPer; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder( bar, hFast, hSlow ) ) SellAtMarket( bar+1, LastPosition ); } else { if( CrossOver( bar, hFast, hSlow ) ) BuyAtMarket( bar+1 ); } } } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.