Summary
Dysart's Negative Volume Index assumes that the smart money is active on days when volume decreases and the not-so-smart money is active on days when volume increases (measured by the Positive Volume Index).
Syntax
public interface NegativeVolumeIndex
Members
Name | Type | Summary |
---|---|---|
Result | Property | The time series of the Negative Volume Index indicator. |
Example 1
private NegativeVolumeIndex _negativeVolume; [Parameter] public DataSeries Source { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } protected override void Initialize() { _negativeVolume = Indicators.NegativeVolumeIndex(Source); } public override void Calculate(int index) { // Display Result of Indicator Result[index] = _negativeVolume.Result[index]; }
Example 2
using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Robots { // This sample cBot shows how to use the Positive/Negative Volume Index indicators [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class VolumeIndexSample : Robot { private double _volumeInUnits; private PositiveVolumeIndex _positiveVolumeIndex; private NegativeVolumeIndex _negativeVolumeIndex; private SimpleMovingAverage _simpleMovingAverage; [Parameter("Volume (Lots)", DefaultValue = 0.01)] public double VolumeInLots { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 10)] public double StopLossInPips { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 10)] public double TakeProfitInPips { get; set; } [Parameter("Label", DefaultValue = "Sample")] public string Label { get; set; } public Position[] BotPositions { get { return Positions.FindAll(Label); } } protected override void OnStart() { _volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots); _positiveVolumeIndex = Indicators.PositiveVolumeIndex(Bars.ClosePrices); _negativeVolumeIndex = Indicators.NegativeVolumeIndex(Bars.ClosePrices); _simpleMovingAverage = Indicators.SimpleMovingAverage(Bars.ClosePrices, 20); } protected override void OnBar() { if (Bars.ClosePrices.Last(1) > _simpleMovingAverage.Result.Last(1)) { ClosePositions(TradeType.Sell); if (BotPositions.Length == 0 && _negativeVolumeIndex.Result.Last(1) > _positiveVolumeIndex.Result.Last(1)) { ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips); } } else if (Bars.ClosePrices.Last(1) < _simpleMovingAverage.Result.Last(1)) { ClosePositions(TradeType.Buy); if (BotPositions.Length == 0 && _negativeVolumeIndex.Result.Last(1) > _positiveVolumeIndex.Result.Last(1)) { ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips); } } } private void ClosePositions(TradeType tradeType) { foreach (var position in BotPositions) { if (position.TradeType != tradeType) continue; ClosePosition(position); } } } }