Choose | Mastock Help

Short Name: Choose

Definition: Returns a value or an array of values based on a test and a choice of two values or arrays

Usage: choose(test,choice1,choice2)

  • Execute a test and returns a value or an array dependent of the result of the test
  • Returns a scalar value or an array of values.

  • Return value depends on the operands. If one of the operand is an array, then returns an array

  • choose(yes,1,2) always returns 1
  • choose(no,1,2) always returns 2
  • choose(testArray,100,0) look at each value in the test array and returns an array with 100 or 0 depending on each individual results
  • choose(yes,rsi(14),macd(12,26,9)) returns an array with rsi(14) values
  • choose(testArray,rsi(14),50) returns an array where each day is either the RSI for the day or the value 50
  • Signal MACD:
  • test = macd(12,26,9) > macdAvg(12,26,9)
  • indic = choose(test,100,0)
  • notifyResult(indic)