PINE LIBRARY

LibraryBitwiseOperands

Library "LibraryBitwiseOperands"

Description: When you need more space for your data you can use bitwise operations. For example if you are creating an Order Block indicator and you have multiple types then you can define variables for each type with only one bit set like these:
const int TYPE_OB = 1
const int TYPE_HH = 2
const int TYPE_LH = 4
const int TYPE_HL = 8
const int TYPE_LL = 16
const int TYPE_BOS = 32
const int TYPE_CHOCH = 64

bitwise_shift_left(x, y)
  bitwise_shift_left(): Bitwise left shift: x << y
  Parameters:
    x (int)
    y (int)
  Returns: : The left operand’s value is moved toward left by the number of bits specified by the right operand.

bitwise_shift_right(x, y)
  bitwise_shift_right(): Bitwise right shift: x >> y
  Parameters:
    x (int)
    y (int)
  Returns: : The left operand’s value is moved toward right by the number of bits specified by the right operand.

bitwise_not(x)
  bitwise_not(): Bitwise NOT: ~x
  Parameters:
    x (int)
  Returns: : Inverts individual bits.

bitwise_and(x, y)
  bitwise_and(): Bitwise AND: x & y
  Parameters:
    x (int)
    y (int)
  Returns: : Result bit 1, if both operand bits are 1; otherwise results bit 0.

bitwise_or(x, y)
  bitwise_or(): Bitwise OR: x | y
  Parameters:
    x (int)
    y (int)
  Returns: : Result bit 1, if any of the operand bit is 1; otherwise results bit 0.

bitwise_xor(x, y)
  bitwise_xor(): Bitwise (exclusive OR) XOR: x ^ y
  Parameters:
    x (int)
    y (int)
  Returns: : Result bit 1, if any of the operand bit is 1 but not both, otherwise results bit 0.

logical_xor(x, y)
  logical_xor(): Logical (exclusive OR) XOR: x xor y
  Parameters:
    x (bool)
    y (bool)
  Returns: : Result true, if any of the operand bit are different, otherwise results bit 0.

bit_check(x, y)
  bit_check(): Bitwise Checks the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns True if the bit is set.

bit_set(x, y)
  bit_set(): Bitwise Sets the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the bit set.

bit_clear(x, y)
  bit_clear(): Bitwise Clears the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the bit cleared.

bit_flip(x, y)
  bit_flip(): Bitwise Inverts the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the bit inverted.

bitmask_check(x, mask)
  bitmask_check(): Bitwise Checks the specified Mask
  Parameters:
    x (int)
    mask (int)
  Returns: : Returns True if the mask is set.

bitmask_set(x, mask)
  bitmask_set(): Bitwise Sets the specified Mask
  Parameters:
    x (int)
    mask (int)
  Returns: : Returns a value with the mask set.

bitmask_clear(x, mask)
  bitmask_clear(): Bitwise Clears the specified Mask
  Parameters:
    x (int)
    mask (int)
  Returns: : Returns a value with the mask cleared.

bitmask_flip(x, mask)
  bitmask_flip(): Inverts the specified Mask
  Parameters:
    x (int)
    mask (int)
  Returns: : Returns a value with the mask inverted.

math_bit_check(x, y)
  math_bit_check(): Fast arithmetic bitwise Checks the specified Mask
  Parameters:
    x (int)
    y (int)
  Returns: : Returns True if the mask is set.

math_bit_set(x, y)
  math_bit_set(): Fast arithmetic bitwise Sets the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the bit set.

math_bit_clear(x, y)
  math_bit_clear(): Fast arithmetic bitwise Clears the specified bit
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the bit cleared.

math_bitmask_check(x, y)
  math_bitmask_check(): Fast arithmetic bitwise Checks the specified Mask
  Parameters:
    x (int)
    y (int)
  Returns: : Returns True if the mask is set.

math_bitmask_set(x, y)
  math_bitmask_set(): Fast arithmetic bitwise Sets the specified Mask
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the mask set.

math_bitmask_clear(x, y)
  math_bitmask_clear(): Fast arithmetic bitwise Clears the specified Mask
  Parameters:
    x (int)
    y (int)
  Returns: : Returns a value with the mask cleared.
bitwiseMATH

Pine脚本库

本着真正的TradingView精神,作者将此Pine代码发布为开源脚本库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私下或在其它开源出版物中使用此脚本库,但在出版物中重复使用此代码受网站规则约束。

免责声明