Var
 

Short Name: Var

Definition: Returns a specific value from an array

Usage: var(array,index)

Objective:
  • Returns the specific value corresponding to the index in an array
  • Returns a scalar value

Note:
  • This is a very useful instruction as it avoids useless calculations in a loop. Var just read a specific value from an array pre-stored in memory
  • In a for loop, if you pass var(array,0), it will return the value corresponding to the current loop index. var(array,1) is the day before current.

Examples:
  • OBV:
  • leVol = reverse(volume)
  • leClose = reverse(close)
  • leClose1 = shiftedRight(leClose,1)
  • test = leClose < leClose1
  • accumulate(obv0,0)
  • for(0,histoRange)
  • if(var(test,0)) then
  • dummyPlus = var(leVol,0) + var(obv0,0)
  • accumulate(obv0,dummyPlus)
  • else
  • dummyMoins = 0 - var(leVol,0) + var(obv0,0)
  • accumulate(obv0,dummyMoins)
  • endif
  • endfor
  • notifyresult(reverse(obv0))