v3
Added:
zeroOne(cond)
Converts a "bool" cond to 1 when it is `true`, 0 when it's false.
Parameters:
cond (bool): (bool) The "bool" value to be converted.
Returns: (int) 1 when `cond` is `true`, `false` otherwise.
addTextIf(cond, msg, txt, sep)
Appends `sep` and `txt` to `msg` when `cond` is true.
Parameters:
cond (bool): (bool) The condition determining if text will be added.
msg (string): (string) The string to which we add text.
txt (string): (string) The text to be added.
sep (string): (string) A separator string to be added before `txt` when `msg` already contains text.
Returns: (int) The modified `msg` string if `cond` is `true`. Returns `msg` unchanged if `cond` is `false`.
gradientAdvDecPro(source, center, steps, bearWeakColor, bearStrongColor, bullWeakColor, bullStrongColor)
Calculates a gradient between two bull or two bear colors, depending on whether the source signal is above/below the centerline.
The gradient is proportional to the current qty of advances/declines of the `source`.
The count of advances/declines resets to one when the `source` crosses the `center` and is limited by `steps`.
Parameters:
source (float): (float) input signal.
center (float): (float) (- ∞ to ∞) centerline used to determine if signal is bullish/bearish.
steps (float): (float) Maximum number of steps in the gradient from the weak color to the strong color.
bearWeakColor (color): (color) bear color at adv/dec qty of 1.
bearStrongColor (color): (color) bear color at adv/dec qty of `steps`.
bullWeakColor (color): (color) bull color at adv/dec qty of 1.
bullStrongColor (color): (color) bull color at adv/dec qty of `steps`.
Returns: (color) The calculated color.
upDnIntrabarVolumesByPolarity()
Determines if the volume for an intrabar is up or down.
Returns: ([float, float]) A tuple of two values, one of which contains the bar's volume. `upVol` is the positive volume of up bars. `dnVol` is the negative volume of down bars.
Note that when this function is designed to be called with `request.security_lower_tf()`,
which will return a tuple of "array<float>" arrays containing up and dn volume for all the intrabars in a chart bar.