vpirinski

VPQuantLib

Library "VPQuantLib"
Misc of math, position size and consolidation detection functions that can be used accross various scripts.

isPercentAboveReference(current, percent, reference, or_equal)
  Checks if the current value is bigger (or equal) with the provided percent value to the reference
  Parameters:
    current (float): - what to check against the reference
    percent (float): - what is the percent to check for difference
    reference (float): - what to compare against
    or_equal (bool): - enables checking for bigger or equal
  Returns: true if the current is percent bigger (or equal) to the reference

isPercentBelowReference(current, percent, reference, or_equal)
  Checks if the current value is smaller (or equal) with the provided percent value to the reference
  Parameters:
    current (float): - what to check against the reference
    percent (float): - what is the percent to check for difference
    reference (float): - what to compare against
    or_equal (bool): - enables checking for smaller or equal
  Returns: true if the current is percent smaller (or equal) to the reference

isInRange(current, reference, min_percent, max_percent, below)
  Checks if the current value is greater/smaller than the reference value within the provided percent range
  Parameters:
    current (float): - what to check for being in range against the refenence
    reference (float): - what to compare against
    min_percent (float): - the min percent range border
    max_percent (float): - the max percent range border
    below (bool): - check if below or above the reference
@return true if the current is bigger/smaller than the reference withing the percent range provided

GetRiskBasedPositionSize(account_balance, equity_risk_perc, max_loss_per_share)
  Calculates and returns the positins size based on risk of the equity
  Parameters:
    account_balance (float): - total account balance
    equity_risk_perc (int): - percent of equity to risk in the trade
    max_loss_per_share (float): - maximum loss per share (in currency, not in %) that we're willing to loose (calc based on the entry_price-stop_loss_price)
@return number of shares to buy

CheckInRangeConsolidation(consolidation_period, allowed_consolidation_range, ref_high, ref_low, prev_bar_consolidaton, draw_consolidation_lines)
  Checks if the current bar is in a consolidation range
  Parameters:
    consolidation_period (int): - the number of bars to consider for consolidation range calculation
    allowed_consolidation_range (int): - the percentage range allowed for the current consolidation range to be considered valid
    ref_high (float): - the reference high value to use for consolidation range calculation
    ref_low (float): - the reference low value to use for consolidation range calculation
    prev_bar_consolidaton (bool)
    draw_consolidation_lines (bool): - a boolean indicating if consolidation range lines should be drawn on the chart
@return a tuple of three values:
1. _curr_consolidation - a boolean indicating if the current bar is in consolidation range
2. _curr_consolidation_low - the current consolidation low value
3. _curr_consolidation_high - the current consolidation high value

FindBasicConsolidation(loopback_period, consolidation_length, ref_high, ref_low, draw_consolidation_lines)
  Finds a basic consolidation areas, looking back 1000 bars to find the pivot of the trend and checks if the current bar is in consolidation area counting the
number of bars that have not broken the consolidation high/low levels
  Parameters:
    loopback_period (int): - the number of bars to look back to determine the high/low watermark
    consolidation_length (int): - minimum number of bars required to establish a consolidation period
    ref_high (float): - user input for high (can be based on the bar or wicks)
    ref_low (float): - user input for high (can be based on the bar or wicks)
    draw_consolidation_lines (bool): - enable/disable drawing of the consolidation lines
  Returns: _pivot_point - pivot point
파인 라이브러리

트레이딩뷰 정신에 따라 오써는 이 파인 코드를 오픈 소스 라이브러리로 퍼블리쉬하여 당사 커뮤니티의 다른 파인 프로그래머들이 쓸 수 있도록 하였습니다. 오써에게 찬사를! 여러분은 이 라이브러리를 프라이빗 또는 오픈 소스 퍼블리케이션에 쓸 수 있지만 퍼블리케이션에 재사용은 하우스룰을 따릅니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

이 라이브러리를 쓰시겠습니까?

텍스트를 클립보드에 카피한 뒤 님의 스크립트에 붙여 넣기.