[pshaiCmd] Volume Oscillator (SE)

0 249 Views No Comments 10 months ago
  • Volume Oscillator command.

    Parameters:
    * fastPeriod : Period length of fast MA
    * slowPeriod : Period length of slow MA
    * volume : Volume source
    * maType : Type of Moving Average

    Output:
    * Volume Oscillator values

    HaasScript Code
    DefineCommand('VolOsc', 'Volume Oscillator')
    
    local fastPeriod = DefineParameter(NumberType, 'fastPeriod', 'Fast period length', true, 10, 'Input, Number')
    local slowPeriod = DefineParameter(NumberType, 'slowPeriod', 'Slow period length', true, 20, 'Input, Number')
    local volume = DefineParameter(ListNumberType, 'volume', 'Volume source', true, GetVolume(), 'GetVolume')
    local maType = DefineParameter(EnumType, 'maType', 'Moving Average type', false, SmaType, 'InputMaTypes, MAEnums')
    
    local fastVol = MA(volume, fastPeriod, maType)
    local slowVol = MA(volume, slowPeriod, maType)
    local volOsc = (fastVol - slowVol) / slowVol * 100
    
    DefineOutput(ListNumberType, volOsc, 'Volume Oscillator values', 'Plot')
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free