Modified on 2008/05/03 10:19 by Administrator — Categorized as: Standard Indicators


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


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.



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


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 ); } } } } }