Log in to see Cloud of Tags

Wealth-Lab Wiki

Consecutive Days Up/Down of some percent

RSS

ConsecDaysDown, ConsecDaysUp: Indicator Documentation

Syntax

Starting from version 2013.01:


DataSeries ConsecDaysDown( DataSeries ds, double pct );
DataSeries ConsecDaysUp( DataSeries ds, double pct );

Parameter Description

bars A Bars object
ds DataSeries that has declined/increased
pct Percentage decline/increase

Description

These indicators, developed by Dion Kurczek, display the number of consecutive days where prices declined (or rose) by a specified percentage or more.

Example

This example illustrates how to create a simple trading system that buys after the closing price has declined 5% or more for 2 days in a row, and shorts when the closing price has increased 5% or more for 2 days in a row. It exits after 5 days in a position at open next bar.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;

namespace WealthLab.Strategies { public class ConsecDaysDemo : WealthScript { protected override void Execute() { ConsecDaysDown cdd = ConsecDaysDown.Series( Close, 5 ); ConsecDaysUp cdu = ConsecDaysUp.Series( Close, 5 ); ChartPane mPane = CreatePane( 20, true, true ); PlotSeries( mPane, cdd, Color.Red, LineStyle.Histogram, 10 ); PlotSeries( mPane, cdu, Color.Blue, LineStyle.Histogram, 10 ); for(int bar = 1; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if ( bar+1 - p.EntryBar >= 5 ) ExitAtMarket( bar+1, p, "Timed" ); } else { if( cdu[bar] >= 2 ) ShortAtMarket( bar+1 ); if( cdd[bar] >= 2 ) BuyAtMarket( bar+1 ); } } } } }

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.