using System; using finantic.TL; // WealthScriptT using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators; using WealthLab.Rules; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.IO; using WealthLab.Rules.Candlesticks; using System.Net; // accestochiastick the Internet using System.Text.RegularExpressions; // regular expressions using Community.Indicators; using System.Threading; // Sleep() using Community.Components; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using WealthLab.ChartStyles.Trending; namespace WealthLab.Strategies { public class simple : WealthScript { StrategyParameter _INC; StrategyParameter _DEC; StrategyParameter _Pos; public simple() { //Default,Begining,End,Increments _INC = CreateParameter("Increase%", 0.010, 0.000, 0.050, 0.005); _DEC = CreateParameter("Decrease%", 0.010, 0.000, 0.050, 0.005); _Pos = CreateParameter("+P/-N/Both", 1, 0, 2, 1); } protected override void Execute() { // Clear Debug only for the first symbol in the DataSet if (Bars.Symbol == DataSetSymbols[0]) ClearDebug(); //http://www2.wealth-lab.com/WL5WIKI/TASCMay2015.ashx?HL=list var Yc = Close[Bars.Count - 2]; var Tc = Close[Bars.Count - 1]; var Th = High[Bars.Count - 1]; var Tl = Low[Bars.Count - 1]; var To = Open[Bars.Count - 1]; var Dc = Tc - Yc; //Difference from Yesterdays Close var Do = Tc - To; //Difference from Today's open var YCpct = 100 * (Dc) / Yc; //Dc % from Todays Close var Topct = 100 * (Do) / To; //Do % from Todays Open double _INCrease = _INC.Value;// Don't use ValueInt unless you want an integer value double _DECrease = _DEC.Value;// Don't use ValueInt unless you want an integer value //double INCrease = Math.Round((1+_INCrease/1000),4); DrawText(PricePane, String.Format("{0:0.000}", YCpct), 1410, 25, Color.White, Color.Black); // DrawText(PricePane, String.Format("{0:0.000}", 1+_INCrease/1000), 1410, 25, Color.White, Color.Black); if (YCpct > 0 ) { DrawText(PricePane, String.Format("{0:0.000}", _INCrease*100), 1470, 25, Color.White, Color.Black); } else if (YCpct <= 0 ) { DrawText(PricePane, String.Format("{0:0.000}", -_DECrease*100), 1470, 25, Color.White, Color.Red); } int bar = Bars.Count - 1; // the last chart bar number if ((_Pos.Value == 0 | _Pos.Value == 2)) { if (YCpct > 0 && Close[bar] > (1 + _INCrease) * Close[bar - 1]) { // PrintDebug(Bars.Symbol + "\t" + YCpct.ToString("N2")); //PrintDebug(Bars.Symbol); BuyAtMarket(bar + 1, "Positive"); PrintDebug(Bars.Symbol + "\t" + YCpct.ToString("N2")); } } if ((_Pos.Value == 1 | _Pos.Value == 2)) { //if (RunDEC == 1 && YCpct < 0 && Close[bar] < (1 - _INCrease) * Close[bar - 1]) if (YCpct < 0 && Close[bar] <= (1 - _DECrease) * Close[bar - 1]) { // PrintDebug(Bars.Symbol); BuyAtMarket(bar + 1, "Negative"); PrintDebug(Bars.Symbol + "\t" + YCpct.ToString("N2")+"%"); } } } } }