# NEOTICKER DATA BEGIN
ScriptType=Indicator
Description=TASC VBScript Relative Vigor Index
Name=tasc_vbs_rvi
Language=VBScript
Links=1
MinBars=0
TimerInterval=100
EarlyBinding=0
MetaStyle=Normal
ValueRange=Same as Source
Placement=New Pane
Multiplot_num_plots=2
Multiplot_color_0=50266292
Multiplot_style_0=Line
Multiplot_width_0=1
Multiplot_enabled_0=1
Multiplot_breakstyle_0=0
Multiplot_color_1=255
Multiplot_style_1=Line
Multiplot_width_1=1
Multiplot_enabled_1=1
Multiplot_breakstyle_1=0
UpdateByTick=0
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.1
Param_default_0=10
Explanation_Lines=0
# NEOTICKER DATA END

function tasc_vbs_rvi()
   dim Denom
   dim v1, v2

   if itself.firstcall then
      heap.allocatereallist "Value1", param1.int
      heap.allocatereallist "Value2", param1.int
   end if

   data1.makevalidarray op, "O", 5, false
   data1.makevalidarray hp, "H", 5, false
   data1.makevalidarray lp, "L", 5, false
   data1.makevalidarray cp, "C", 5, false

   if not data1.valid (0) then
      itself.successall = false
      exit function
   end if

   v1 = ((cp (0) - op (0)) + _
          2 * (cp (1) - op (1)) + _
          2 * (cp (2) - op (2)) + _
         (cp (3) - op (3)))/6
   heap.listpush "Value1", v1

   v2 = ((hp (0) - lp (0)) + _
          2 * (hp (1) - lp (1)) + _
          2 * (hp (2) - lp (2)) + _
         (hp (3) - lp (3)))/6
   heap.listpush "Value2", v2

   if data1.barsnum (0) < param1.int then
      itself.successall = false
      exit function
   end if

   Denom = heap.listsum("Value2")

   if Denom <> 0 then
      itself.plot (1) = heap.listsum("Value1")/Denom
      itself.plot (2) = (Itself.value (0) + 2 * itself.value (1) + _
                         2 * itself.value (2) + itself.value (3))/6
   else
      itself.successall = false
   end if

end function

