Skip to content

RoundingMode

Summary

The rounding mode for normalizing trade volume.

Signature

1
public enum RoundingMode

Namespace

cAlgo.API

Examples

1
 volume = Symbol.NormalizeVolume(volume, RoundingMode.Down);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample shows how to normalize volume based on different rounding modes
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class NormalizingVolumeSample : Indicator
     {
         [Parameter("Volume Unit", DefaultValue = VolumeUnit.Units)]
         public VolumeUnit VolumeUnit { get; set; }
         [Parameter("Volume Amount", DefaultValue = 0.01)]
         public double VolumeAmount { get; set; }
         [Parameter("Rounding Mode", DefaultValue = RoundingMode.ToNearest)]
         public RoundingMode RoundingMode { get; set; }
         protected override void Initialize()
         {
             double volumeInUnits = VolumeUnit == VolumeUnit.Units ? VolumeAmount : Symbol.QuantityToVolumeInUnits(VolumeAmount);
             double normalizedVolume = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode);
             Print(normalizedVolume);
         }
         public override void Calculate(int index)
         {
         }
     }
     public enum VolumeUnit
     {
         Units,
         Lots
     }
 }

Fields

ToNearest

Summary

Round value to the nearest tradable volume.

Signature

1
public static RoundingMode ToNearest;

Return Value

RoundingMode

Examples

1
 var volume = Symbol.NormalizeVolume(calculatedVolume, RoundingMode.ToNearest);

Down

Summary

Round value down to tradable volume.

Signature

1
public static RoundingMode Down;

Return Value

RoundingMode

Examples

1
 var volume = Symbol.NormalizeVolume(calculatedVolume, RoundingMode.Down);

Up

Summary

Round value up to tradable volume.

Signature

1
public static RoundingMode Up;

Return Value

RoundingMode

Examples

1
 var volume = Symbol.NormalizeVolume(calculatedVolume, RoundingMode.Up);