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

파인 라이브러리

진정한 TradingView 정신에 따라, 저자는 이 파인 코드를 다른 파인 프로그래머들이 재사용할 수 있도록 오픈 소스 라이브러리로 공개했습니다. 저자에게 박수를 보냅니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈 소스 출판물에서 사용할 수 있지만, 이 코드를 출판물에서 재사용하는 것은 하우스 룰에 의해 관리됩니다.

면책사항