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程式設計師可以重複使用它。請向作者致敬!您可以私下使用這個函式庫,或在其他開源出版品中使用,但在出版物中再次使用這段程式碼將受到網站規則的約束。

免責聲明