Wealth-Lab Wiki

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

Navigation


Quick Search
»
Advanced Search »


CIV (Cumulative Intraday Volume)

RSS

Syntax

public CIV(Bars bars, int startTime, int stopTime, string description)
public static CIV Series(Bars bars, int startTime, int stopTime)

Parameter Description

Bars A Bars object
startTime Start time
stopTime Stop time

Description

Sums volume from start to stop times, and holds the result constant until it is reset the following day. CIV is the Cumulative Intraday Volume between the supplied start and stop times. Use in conjunction with SetScaleDaily to determine the average daily volume during a specified time interval, for example.

Note! A problem exists in the SetScale* functions in WL5.6 (and possibly previous versions). Indicators created in the higher scale returns an indicator applied to the data in the lower scale, in effect nullifying the SetScale operation.

Example

The strategy simply buys at 10:30 am if the current price is greater than the opening price, but only if today's CIV volume is greater than the average CIV volume. The example contains a work-around for the SetScale* problem that computes the average volume for a specified number of days (see Note! above).

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components;				// You must install this extension
using Community.Indicators;				// You must install this extension

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { StrategyParameter _days; public MyStrategy() { _days = CreateParameter("Days", 5, 2, 25, 1); } // Returns the daily average volume for the specified DataSeries and period // The average does not include the current day's period private double GetAverage(int bar, DataSeries ds, int period) { double res = 0d; for (int i = 0; i < period; i++) { // This formulation assumes that the current day's volume is not included in the average bar -= Bars.IntradayBarNumber(bar); // first bar of day bar -= 1; // last bar of previous day res += ds[bar]; } res /= period; return res; } protected override void Execute() { Utility u = new Utility( this ); // Intraday support functions here int startTime = 0930; int stopTime = 1030; int days = _days.ValueInt; double avgV = 0d; // Create a cumulative volume indicator for the intraday period (Community.Indicators) DataSeries civ = CIV.Series(Bars, startTime, stopTime); DataSeries dayAvgVol = new DataSeries(Bars, "Average Daily Volume(" + days + ")"); // Run the Strategy for(int bar = u.FirstBarofDay(days + 1); bar < Bars.Count; bar++) { int time = u.GetTime(bar);

if ( time == stopTime ) { // Get the daily average for the period avgV = GetAverage(bar, civ, days); } dayAvgVol[bar] = avgV; if (IsLastPositionActive) { Position p = LastPosition; if ( Bars.IsLastBarOfDay(bar) ) { ExitAtClose(bar, p, "EOD"); } } else if ( time == stopTime && civ[bar] > dayAvgVol[bar] ) { double startPrice = Close[bar - Bars.IntradayBarNumber(bar)]; // Open price today if (Close[bar] > startPrice) BuyAtMarket(bar + 1); } } // Now created, plot the daily average volume series ChartPane dayAvgVolPane = CreatePane(40, false, true); PlotSeries(dayAvgVolPane, dayAvgVol, Color.Blue, LineStyle.Solid, 2); PlotSeries(dayAvgVolPane, civ, Color.Red, LineStyle.Solid, 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.

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


ScrewTurn Wiki. Some of the icons created by FamFamFam.