Log in to see Cloud of Tags

Wealth-Lab Wiki


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

Parameter Description

source The source DataSeries
period Indicator calculation period


Median returns the Median value of the source DataSeries based on the specified period. Median sorts the values and returns the value occupying the "middle" slot of the group. When there is an odd number of values, the median is simply the middle value. For example, the median of 2, 4, and 7 is 4. When there is an even number of values, the median is the average of the two middle numbers. Thus, the median of the numbers 2, 4, 7, 12 is (4+7)/2 = 5.5.


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() { DataSeries hMedFast = Median.Series( Close, 13 ); DataSeries hMedSlow = Median.Series( Close, 25 ); PlotSeries( PricePane, hMedFast, Color.Brown, WealthLab.LineStyle.Solid, 2 ); PlotSeries( PricePane, hMedSlow, Color.Black, WealthLab.LineStyle.Solid, 2 );

for(int bar = 25; bar < Bars.Count; bar++) { if( CrossOver( bar, hMedFast, hMedSlow ) ) BuyAtMarket( bar+1 ); else if( CrossUnder( bar, hMedFast, hMedSlow ) ) SellAtMarket( bar+1, Position.AllPositions ); } } } }

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.