Library "cphelper" ACPU helper library - for private use. Not so meaningful for others.
calculate_rr(targetArray, rrArray, breakevenOnTarget1) calculates risk reward for given targets Parameters: targetArray (float[]): array of targets rrArray (float[]): array of risk reward breakevenOnTarget1 (simple bool): option to breakeven Returns: array<float> rrArray
trendPairs(l1StartX, l1StartY, l1EndX, l1EndY, l2StartX, l2StartY, l2EndX, l2EndY, zgColor) creates trendline pairs Parameters: l1StartX (int): startX of first line l1StartY (float): startY of first line l1EndX (int): endX of first line l1EndY (float): endY of first line l2StartX (int): startX of second line l2StartY (float): startY of second line l2EndX (int): endX of second line l2EndY (float): endY of second line zgColor (color): line color Returns: [line, line]
find_type(l1t, l2t, channelThreshold) Finds type based on trendline pairs Parameters: l1t (line): line1 l2t (line): line2 channelThreshold (simple float): theshold for channel identification Returns: [int, array<bool>] pattern type and flags
getType(typeNum) Get type based on type number Parameters: typeNum (int): number representing type Returns: String value of type
getStatus(status, maxStatus) Get status based on integer value representations Parameters: status (int): integer representing current status maxStatus (int): integer representing max status Returns: String status value
calculate_simple_targets(trendLines, settingsMatrix, patternTypeMapping, patternType) Calculate targets based on trend lines Parameters: trendLines (line[]): trendline pair array settingsMatrix (matrix<float>): matrix containing settings patternTypeMapping (string[]): array containing pattern type mapping patternType (int): pattern type Returns: [array<float>, array<float>] arrays containing long and short calculated targets
recalculate_position(patternTypeAndStatusMatrix, targetMatrix, index, pIndex, status, maxStatus, targetValue, stopValue, dir, breakevenOnTarget1) Recalculate position values Parameters: patternTypeAndStatusMatrix (matrix<int>): matrix containing pattern type and status targetMatrix (matrix<float>): matrix containing targets index (int): current index pIndex (int): pattern index status (int): current status maxStatus (int): max status reached targetValue (float): current target value stopValue (float): current stop value dir (int): direction breakevenOnTarget1 (simple bool): flag to breakeven upon target1 Returns: [int, int] new status and maxStatus values
draw_targets(longTargets, shortTargets, index, labelColor, patternName, positionIndex, longMaxStatus, longStatus, shortMaxStatus, shortStatus, tempBoxes, tempLines, tempLabels) Draw targets on chart Parameters: longTargets (matrix<float>): matrix containing long targets shortTargets (matrix<float>): matrix containing short targets index (int): current index labelColor (color): color of lines and labels patternName (string): Pattern name positionIndex (int): position on the chart longMaxStatus (int): max status for long longStatus (int): long status value shortMaxStatus (int): max status for short shortStatus (int): short status value tempBoxes (box[]): temporary box array tempLines (line[]): temporary lines array tempLabels (label[]): temporary labels array Returns: void
populate_open_stats(patternIdArray, barMatrix, patternTypeAndStatusMatrix, patternColorArray, longTargets, shortTargets, patternRRMatrix, OpenStatPosition, lblSizeOpenTrades) Populate open stats table Parameters: patternIdArray (int[]): pattern Ids barMatrix (matrix<int>): matrix containing bars patternTypeAndStatusMatrix (matrix<int>): matrix containing pattern type and status patternColorArray (color[]): array containing current patter colors longTargets (matrix<float>): matrix of long targets shortTargets (matrix<float>): matrix of short targets patternRRMatrix (matrix<float>): pattern risk reward matrix OpenStatPosition (simple string): table position lblSizeOpenTrades (simple string): text size Returns: void
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.