Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation


Quick Search
»
Advanced Search »


Syntax


public static bool CooledOff(this WealthScript obj, int bar, int time)

public bool CooledOff(int bar, int time)

Parameter Description

barBar number
timeThe number of bars since last position is exited to inhibit a new entry

Description

This function, created by Dion Kurczek, will cause a Strategy to wait for a certain period of time before entering a new position once the preceding position is closed.

Example

Below is a demo Strategy that shows how to use the function. Drag the StrategyParameter slider to vary the number of bars since last position is exited.

Example using C# extension methods:


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

Legacy syntax example:


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

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.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki. Some of the icons created by FamFamFam.