Script: Parameter | Mastock Help



Short Name: Parameter

Definition: Retrieve the value of one of the 5 possible parameters

Usage: parameter(x) where x is 1, 2, 3, 4 or 5

Objective:
  • Returns a value if defined, or 0 if undefined
  • The value of the parameter can be numeric like in RSI(14) or a string like getQuotes(^GDAXI)

Note:
  • Returns zero if the parameter is not defined, after displaying an alert

Examples:
  • notifyResult(RSI(parameter(1))) will display the RSI(14) if parameter 1 is set to 14
  • Correlation Indicator: Parameter 1 can be any stock code already in the base
  • ref = getQuotes(parameter(1))
  • lesClose = close
  • refSquare = ref * ref
  • closeSquare = lesClose * lesClose
  • avgRef = avg(ref,20)
  • avgClose = avg(lesClose,20)
  • avgRefSquare = avg(refSquare,20)
  • avgCloseSquare = avg(closeSquare, 20)
  • mult = ref * lesClose
  • avgMult = avg(mult, 20)
  • varianceClose = avgCloseSquare - (avgClose * avgClose)
  • varianceRef = avgRefSquare - (avgRef * avgRef)
  • covariance = avgMult - (avgRef * avgClose)
  • interVar = varianceClose * varianceRef
  • correlation = covariance / sqrt(interVar)
  • notifyResult(correlation,value(0))