public TSI(DataSeries ds, int period1, int period2, string description) public static TSISeries(DataSeries ds, int period1, int period2)
TSI(close,r,s) = 100*EMA(EMA(mtm,r),s)/EMA(EMA(|mtm|,r),s)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators; // TSInamespace WealthLab.Strategies { public class ATMag02_2002_TSI : WealthScript { protected override void Execute() { // Plot True Strength Index and Signal Line ChartPane TSIPane = CreatePane( 50, true, true ); SetPaneMinMax( TSIPane, -30, 30 ); DataSeries TSISer = TSI.Series( Close, 25, 13 ); PlotSeries( TSIPane, TSISer, Color.Blue, LineStyle.Solid, 1 ); DataSeries Signal = EMA.Series( TSISer, 7, EMACalculation.Modern ); PlotSeries( TSIPane, Signal, Color.Black, LineStyle.Dashed, 1 ); // Obtain Difference of TSI and Signal Line, Plot it DataSeries Diff = TSISer - Signal; Diff.Description = "TSI/Signal Difference"; ChartPane DiffPane = CreatePane( 35, false, true ); PlotSeries( DiffPane, Diff, Color.Black, LineStyle.Histogram, 2 ); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder( bar, Diff, 0 ) ) SellAtMarket( bar + 1, LastPosition ); } else { if( CrossOver( bar, Diff, 0 ) ) BuyAtMarket( bar + 1 ); } } } } }