# NEOTICKER DATA BEGIN
ScriptType=Indicator
Description=Example VBScript Buff Average
Name=ex_vbs_baverage
Language=VBScript
Links=1
MinBars=0
TimerInterval=100
EarlyBinding=0
MetaStyle=Normal
ValueRange=Same as Source
Placement=Smart
Multiplot_num_plots=1
Multiplot_color_0=255
Multiplot_style_0=Line
Multiplot_width_0=1
Multiplot_enabled_0=1
Multiplot_breakstyle_0=0
UpdateByTick=1
FloatMarker=1
DepthData=0
TradingSystemUI=0
PrimaryLinkOnly=0
NotifyOnRemoval=0
Param_count=1
Param_name_0=Period
Param_inuse_0=1
Param_type_0=integer.gte.0
Param_default_0=5
Explanation_Lines=0
# NEOTICKER DATA END

'NeoTicker Additional Indicator
'written by Kenneth, May 2001
'Copyright by TickQuest Inc.
'All right reserved

'Buff Average
'Stock & Commodities Magzine.

Function ex_vbs_baverage ()

dim i

if heap.size = 0 then
   heap.allocate(2)
   heap.value(0) = 0
   heap.value(1) = 0
end if

if Data1.BarsNum(0) > Param1.int then

   heap.value(0) = heap.Value(0) - _
                   Data1.Value(Param1.int)*Data1.Volume(Param1.int)
   heap.value(1) = heap.Value(1) - Data1.Volume(Param1.int)

   heap.value(0) = heap.Value(0) + Data1.Value(0)*Data1.Volume(0)
   heap.value(1) = heap.Value(1) + Data1.Volume(0)

   ex_vbs_baverage = heap.value(0)/heap.value(1)

elseif Data1.BarsNum(0) = Param1.int then

   for i = 0 to Param1.int-1
      heap.value(0) = heap.value(0) + Data1.Value(i)*Data1.Volume(i)
      heap.value(1) = heap.value(1) + Data1.Volume(i)
   next

   ex_vbs_baverage = heap.value(0)/heap.value(1)

else
   itself.success = false
end if

End Function
