public static bool CooledOff(this WealthScript obj, int bar, int time)public bool CooledOff(int bar, int time)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class CooledOffDemo : WealthScript { private StrategyParameter paramBars; public CooledOffDemo() { paramBars = CreateParameter("Delay entry", 20, 1, 50, 1); } protected override void Execute() { for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )[bar] ); else if( this.CooledOff( bar, paramBars.ValueInt ) ) BuyAtStop( bar+1, Highest.Series( High, 20 )[bar] ); } } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class CooledOffDemo : WealthScript { private StrategyParameter paramBars; public CooledOffDemo() { paramBars = CreateParameter("Delay entry", 20, 1, 50, 1); } protected override void Execute() { /* Create an instance of the clas that contains the CooledOff function, passing WealthScript as "this" */ PositionHelper ph = new PositionHelper( this ); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )[bar] ); else if( ph.CooledOff( bar, paramBars.ValueInt ) ) BuyAtStop( bar+1, Highest.Series( High, 20 )[bar] ); } } } }