Chart InfoOVERVIEW
What would a general summary of the symbol on the chart look like? Here’s an example: This script was created to help you easily access the essential details of a symbol, which I believe are critical for daily use.
CONCEPTS
When using any indicator or analysing price movement, the characteristics of the chart become important. Each symbol has a unique character and the more we can quickly find out about it, the better. Instead of embedding those details within each individual indicator, it is often more practical to access these data through an external tool. This indicator presents the following results related to the symbol on your chart in a table format:
ID : Ticker ID (Exchange, Base Currency, and Quote Currency)
TIMEFRAME : The chart's time period
START : The starting date of the chart
FINISH : The finishing date of the chart
INTERVAL : The total time between the start and finish dates (based on timeframe). The current bar is not included in the total time until it is closed.
BAR INDEX : The total number of bars on the chart (can also be viewed in both forward and backward directions in the data window as a series type).
VOLATILITY : Percentage ratio of 14-bar ATR to close.
CHANGE : The daily percentage change.
HODL : The percentage return that would be gained if the symbol had been bought and held since the first bar.
DAILY BUY : The percentage return that would be gained if the same amount of buying was made daily (a kind of DCA).
MECHANICS
This is a very simple script. I didn't add user-defined timestamp inputs because I didn’t want to overwhelm the indicator with parameters. However, if requested, i can make improvements in this direction in a second version.
NOTES
I live in Istanbul, so I designed the default timezone offset as GMT+3. Please remember to adjust it according to your own timezone to ensure the date results are accurate.
I hope it helps everyone. Do not forget to manage your risk. And trade as safely as possible. Best of luck!
Pine实用程序
Lost Bar Locator v1 [Yaphott]Lost Bar Locator v1 helps you locate missing data on your chart.
It does this by looking for consecutive bars that have a delta time greater than the current interval.
Two lines are drawn for each group of one or more missing bars:
Bar before the missing bar(s).
Bar after the missing bar(s).
Geo. Geo.
This library provides a comprehensive set of geometric functions based on 2 simple types for point and line manipulation, point array calculations, some vector operations (Borrowed from @ricardosantos ), angle calculations, and basic polygon analysis. It offers tools for creating, transforming, and analyzing geometric shapes and their relationships.
View the source code for detailed documentation on each function and type.
═════════════════════════════════════════════════════════════════════════
█ OVERVIEW
This library enhances TradingView's Pine Script with robust geometric capabilities. It introduces the Point and Line types, along with a suite of functions for various geometric operations. These functionalities empower you to perform advanced calculations, manipulations, and analyses involving points, lines, vectors, angles, and polygons directly within your Pine scripts. The example is at the bottom of the script. ( Commented out )
█ CONCEPTS
This library revolves around two fundamental types:
• Point: Represents a point in 2D space with x and y coordinates, along with optional 'a' (angle) and 'v' (value) fields for versatile use. Crucially, for plotting, utilize the `.to_chart_point()` method to convert Points into plottable chart.point objects.
• Line: Defined by a starting Point and a slope , enabling calculations like getting y for a given x, or finding intersection points.
█ FEATURES
• Point Manipulation: Perform operations like addition, subtraction, scaling, rotation, normalization, calculating distances, dot products, cross products, midpoints, and more with Point objects.
• Line Operations: Create lines, determine their slope, calculate y from x (and vice versa), and find the intersection points of two lines.
• Vector Operations: Perform vector addition, subtraction, multiplication, division, negation, perpendicular vector calculation, floor, fractional part, sine, absolute value, modulus, sign, round, scaling, rescaling, rotation, and ceiling operations.
• Angle Calculations: Compute angles between points in degrees or radians, including signed, unsigned, and 360-degree angles.
• Polygon Analysis: Calculate the area, perimeter, and centroid of polygons. Check if a point is inside a given polygon and determine the convex hull perimeter.
• Chart Plotting: Conveniently convert Point objects to chart.point objects for plotting lines and points on the chart. The library also includes functions for plotting lines between individual and series of points.
• Utility Functions: Includes helper functions such as square root, square, cosine, sine, tangent, arc cosine, arc sine, arc tangent, atan2, absolute distance, golden ratio tolerance check, fractional part, and safe index/check for chart plotting boundaries.
█ HOW TO USE
1 — Include the library in your script using:
import kaigouthro/geo/1
2 — Create Point and Line objects:
p1 = geo.Point(bar_index, close)
p2 = geo.Point(bar_index , open)
myLine = geo.Line(p1, geo.slope(p1, p2))
// maybe use that line to detect a crossing for an alert ... hmmm
3 — Utilize the provided functions:
distance = geo.distance(p1, p2)
intersection = geo.intersection(line1, line2)
4 — For plotting labels, lines, convert Point to chart.point :
label.new(p1.to_chart_point(), " Hi ")
line.new(p1.to_chart_point(),p2.to_chart_point())
█ NOTES
This description provides a concise overview. Consult the library's source code for in-depth documentation, including detailed descriptions, parameter types, and return values for each function and method. The source code is structured with comprehensive comments using the `//@` format for seamless integration with TradingView's auto-documentation features.
█ Possibilities..
Library "geo"
This library provides a comprehensive set of geometric functions and types, including point and line manipulation, vector operations, angle calculations, and polygon analysis. It offers tools for creating, transforming, and analyzing geometric shapes and their relationships.
sqrt(value)
Square root function
Parameters:
value (float) : (float) - The number to take the square root of
Returns: (float) - The square root of the input value
sqr(x)
Square function
Parameters:
x (float) : (float) - The number to square
Returns: (float) - The square of the input value
cos(v)
Cosine function
Parameters:
v (float) : (series float) - The value to find the cosine of
Returns: (series float) - The cosine of the input value
sin(v)
Sine function
Parameters:
v (float) : (series float) - The value to find the sine of
Returns: (series float) - The sine of the input value
tan(v)
Tangent function
Parameters:
v (float) : (series float) - The value to find the tangent of
Returns: (series float) - The tangent of the input value
acos(v)
Arc cosine function
Parameters:
v (float) : (series float) - The value to find the arc cosine of
Returns: (series float) - The arc cosine of the input value
asin(v)
Arc sine function
Parameters:
v (float) : (series float) - The value to find the arc sine of
Returns: (series float) - The arc sine of the input value
atan(v)
Arc tangent function
Parameters:
v (float) : (series float) - The value to find the arc tangent of
Returns: (series float) - The arc tangent of the input value
atan2(dy, dx)
atan2 function
Parameters:
dy (float) : (float) - The y-coordinate
dx (float) : (float) - The x-coordinate
Returns: (float) - The angle in radians
gap(_value1, __value2)
Absolute distance between any two float values
Parameters:
_value1 (float) : First value
__value2 (float)
Returns: Absolute Positive Distance
phi_tol(a, b, tolerance)
Check if the ratio is within the tolerance of the golden ratio
Parameters:
a (float) : (float) The first number
b (float) : (float) The second number
tolerance (float) : (float) The tolerance percennt as 1 = 1 percent
Returns: (bool) True if the ratio is within the tolerance, false otherwise
frac(x)
frad Fractional
Parameters:
x (float) : (float) - The number to convert to fractional
Returns: (float) - The number converted to fractional
safeindex(x, limit)
limiting int to hold the value within the chart range
Parameters:
x (float) : (float) - The number to limit
limit (int)
Returns: (int) - The number limited to the chart range
safecheck(x, limit)
limiting int check if within the chartplottable range
Parameters:
x (float) : (float) - The number to limit
limit (int)
Returns: (int) - The number limited to the chart range
interpolate(a, b, t)
interpolate between two values
Parameters:
a (float) : (float) - The first value
b (float) : (float) - The second value
t (float) : (float) - The interpolation factor (0 to 1)
Returns: (float) - The interpolated value
gcd(_numerator, _denominator)
Greatest common divisor of two integers
Parameters:
_numerator (int)
_denominator (int)
Returns: (int) The greatest common divisor
method set_x(self, value)
Set the x value of the point, and pass point for chaining
Namespace types: Point
Parameters:
self (Point) : (Point) The point to modify
value (float) : (float) The new x-coordinate
method set_y(self, value)
Set the y value of the point, and pass point for chaining
Namespace types: Point
Parameters:
self (Point) : (Point) The point to modify
value (float) : (float) The new y-coordinate
method get_x(self)
Get the x value of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point to get the x-coordinate from
Returns: (float) The x-coordinate
method get_y(self)
Get the y value of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point to get the y-coordinate from
Returns: (float) The y-coordinate
method vmin(self)
Lowest element of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point
Returns: (float) The lowest value between x and y
method vmax(self)
Highest element of the point
Namespace types: Point
Parameters:
self (Point) : (Point) The point
Returns: (float) The highest value between x and y
method add(p1, p2)
Addition
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - the add of the two points
method sub(p1, p2)
Subtraction
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - the sub of the two points
method mul(p, scalar)
Multiplication by scalar
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
scalar (float) : (float) - The scalar to multiply by
Returns: (Point) - the multiplied point of the point and the scalar
method div(p, scalar)
Division by scalar
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
scalar (float) : (float) - The scalar to divide by
Returns: (Point) - the divided point of the point and the scalar
method rotate(p, angle)
Rotate a point around the origin by an angle (in degrees)
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to rotate
angle (float) : (float) - The angle to rotate by in degrees
Returns: (Point) - the rotated point
method length(p)
Length of the vector from origin to the point
Namespace types: Point
Parameters:
p (Point) : (Point) - The point
Returns: (float) - the length of the point
method length_squared(p)
Length squared of the vector
Namespace types: Point
Parameters:
p (Point) : (Point) The point
Returns: (float) The squared length of the point
method normalize(p)
Normalize the point to a unit vector
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to normalize
Returns: (Point) - the normalized point
method dot(p1, p2)
Dot product
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the dot of the two points
method cross(p1, p2)
Cross product result (in 2D, this is a scalar)
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the cross of the two points
method distance(p1, p2)
Distance between two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the distance of the two points
method Point(x, y, a, v)
Point Create Convenience
Namespace types: series float, simple float, input float, const float
Parameters:
x (float)
y (float)
a (float)
v (float)
Returns: (Point) new point
method angle(p1, p2)
Angle between two points in degrees
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - the angle of the first point and the second point
method angle_between(p, pivot, other)
Angle between two points in degrees from a pivot point
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to calculate the angle from
pivot (Point) : (Point) - The pivot point
other (Point) : (Point) - The other point
Returns: (float) - the angle between the two points
method translate(p, from_origin, to_origin)
Translate a point from one origin to another
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to translate
from_origin (Point) : (Point) - The origin to translate from
to_origin (Point) : (Point) - The origin to translate to
Returns: (Point) - the translated point
method midpoint(p1, p2)
Midpoint of two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (Point) - The midpoint of the two points
method rotate_around(p, angle, pivot)
Rotate a point around a pivot point by an angle (in degrees)
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to rotate
angle (float) : (float) - The angle to rotate by in degrees
pivot (Point) : (Point) - The pivot point to rotate around
Returns: (Point) - the rotated point
method multiply(_a, _b)
Multiply vector _a with _b
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The result of the multiplication
method divide(_a, _b)
Divide vector _a by _b
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The result of the division
method negate(_a)
Negative of vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to negate
Returns: (Point) The negated point
method perp(_a)
Perpendicular Vector of _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The perpendicular point
method vfloor(_a)
Compute the floor of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The floor of the point
method fractional(_a)
Compute the fractional part of the elements from vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The fractional part of the point
method vsin(_a)
Compute the sine of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The sine of the point
lcm(a, b)
Least common multiple of two integers
Parameters:
a (int) : (int) The first integer
b (int) : (int) The second integer
Returns: (int) The least common multiple
method vabs(_a)
Compute the absolute of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The absolute of the point
method vmod(_a, _b)
Compute the mod of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_b (float) : (float) The mod
Returns: (Point) The mod of the point
method vsign(_a)
Compute the sign of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The sign of the point
method vround(_a)
Compute the round of argument vector _a
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (Point) The round of the point
method normalize_y(p, height)
normalizes the y value of a point to an input height
Namespace types: Point
Parameters:
p (Point) : (Point) - The point to normalize
height (float) : (float) - The height to normalize to
Returns: (Point) - the normalized point
centroid(points)
Calculate the centroid of multiple points
Parameters:
points (array) : (array) The array of points
Returns: (Point) The centroid point
random_point(_height, _width, _origin, _centered)
Random Point in a given height and width
Parameters:
_height (float) : (float) The height of the area to generate the point in
_width (float) : (float) The width of the area to generate the point in
_origin (Point) : (Point) The origin of the area to generate the point in (default: na, will create a Point(0, 0))
_centered (bool) : (bool) Center the origin point in the area, otherwise, positive h/w (default: false)
Returns: (Point) The random point in the given area
random_point_array(_origin, _height, _width, _centered, _count)
Random Point Array in a given height and width
Parameters:
_origin (Point) : (Point) The origin of the area to generate the array (default: na, will create a Point(0, 0))
_height (float) : (float) The height of the area to generate the array
_width (float) : (float) The width of the area to generate the array
_centered (bool) : (bool) Center the origin point in the area, otherwise, positive h/w (default: false)
_count (int) : (int) The number of points to generate (default: 50)
Returns: (array) The random point array in the given area
method sort_points(points, by_x)
Sorts an array of points by x or y coordinate
Namespace types: array
Parameters:
points (array) : (array) The array of points to sort
by_x (bool) : (bool) Whether to sort by x-coordinate (true) or y-coordinate (false)
Returns: (array) The sorted array of points
method equals(_a, _b)
Compares two points for equality
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (bool) True if the points are equal, false otherwise
method max(origin, _a, _b)
Maximum of two points from origin, using dot product
Namespace types: Point
Parameters:
origin (Point)
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The maximum point
method min(origin, _a, _b)
Minimum of two points from origin, using dot product
Namespace types: Point
Parameters:
origin (Point)
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (Point) The minimum point
method avg_x(points)
Average x of point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The average x-coordinate
method avg_y(points)
Average y of point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The average y-coordinate
method range_x(points)
Range of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The range of x-coordinates
method range_y(points)
Range of y values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The range of y-coordinates
method max_x(points)
max of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The max of x-coordinates
method min_y(points)
min of x values in point array
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (float) The min of x-coordinates
method scale(_a, _scalar)
Scale a point by a scalar
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to scale
_scalar (float) : (float) The scalar value
Returns: (Point) The scaled point
method rescale(_a, _length)
Rescale a point to a new magnitude
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rescale
_length (float) : (float) The new magnitude
Returns: (Point) The rescaled point
method rotate_rad(_a, _radians)
Rotate a point by an angle in radians
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rotate
_radians (float) : (float) The angle in radians
Returns: (Point) The rotated point
method rotate_degree(_a, _degree)
Rotate a point by an angle in degrees
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to rotate
_degree (float) : (float) The angle in degrees
Returns: (Point) The rotated point
method vceil(_a, _digits)
Ceil a point to a certain number of digits
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to ceil
_digits (int) : (int) The number of digits to ceil to
Returns: (Point) The ceiled point
method vpow(_a, _exponent)
Raise both point elements to a power
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_exponent (float) : (float) The exponent
Returns: (Point) The point with elements raised to the power
method perpendicular_distance(_a, _b, _c)
Distance from point _a to line between _b and _c
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
_b (Point) : (Point) The start point of the line
_c (Point) : (Point) The end point of the line
Returns: (float) The perpendicular distance
method project(_a, _axis)
Project a point onto another
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to project
_axis (Point) : (Point) The point to project onto
Returns: (Point) The projected point
method projectN(_a, _axis)
Project a point onto a point of unit length
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to project
_axis (Point) : (Point) The unit length point to project onto
Returns: (Point) The projected point
method reflect(_a, _axis)
Reflect a point on another
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to reflect
_axis (Point) : (Point) The point to reflect on
Returns: (Point) The reflected point
method reflectN(_a, _axis)
Reflect a point to an arbitrary axis
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to reflect
_axis (Point) : (Point) The axis to reflect to
Returns: (Point) The reflected point
method angle_rad(_a)
Angle in radians of a point
Namespace types: Point
Parameters:
_a (Point) : (Point) The point
Returns: (float) The angle in radians
method angle_unsigned(_a, _b)
Unsigned degree angle between 0 and +180 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The unsigned angle in degrees
method angle_signed(_a, _b)
Signed degree angle between -180 and +180 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The signed angle in degrees
method angle_360(_a, _b)
Degree angle between 0 and 360 by given two points
Namespace types: Point
Parameters:
_a (Point) : (Point) The first point
_b (Point) : (Point) The second point
Returns: (float) The angle in degrees (0-360)
method clamp(_a, _vmin, _vmax)
Restricts a point between a min and max value
Namespace types: Point
Parameters:
_a (Point) : (Point) The point to restrict
_vmin (Point) : (Point) The minimum point
_vmax (Point) : (Point) The maximum point
Returns: (Point) The restricted point
method lerp(_a, _b, _rate_of_move)
Linearly interpolates between points a and b by _rate_of_move
Namespace types: Point
Parameters:
_a (Point) : (Point) The starting point
_b (Point) : (Point) The ending point
_rate_of_move (float) : (float) The rate of movement (0-1)
Returns: (Point) The interpolated point
method slope(p1, p2)
Slope of a line between two points
Namespace types: Point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
Returns: (float) - The slope of the line
method gety(self, x)
Get y-coordinate of a point on the line given its x-coordinate
Namespace types: Line
Parameters:
self (Line) : (Line) - The line
x (float) : (float) - The x-coordinate
Returns: (float) - The y-coordinate
method getx(self, y)
Get x-coordinate of a point on the line given its y-coordinate
Namespace types: Line
Parameters:
self (Line) : (Line) - The line
y (float) : (float) - The y-coordinate
Returns: (float) - The x-coordinate
method intersection(self, other)
Intersection point of two lines
Namespace types: Line
Parameters:
self (Line) : (Line) - The first line
other (Line) : (Line) - The second line
Returns: (Point) - The intersection point
method calculate_arc_point(self, b, p3)
Calculate a point on the arc defined by three points
Namespace types: Point
Parameters:
self (Point) : (Point) The starting point of the arc
b (Point) : (Point) The middle point of the arc
p3 (Point) : (Point) The end point of the arc
Returns: (Point) A point on the arc
approximate_center(point1, point2, point3)
Approximate the center of a spiral using three points
Parameters:
point1 (Point) : (Point) The first point
point2 (Point) : (Point) The second point
point3 (Point) : (Point) The third point
Returns: (Point) The approximate center point
createEdge(center, radius, angle)
Get coordinate from center by radius and angle
Parameters:
center (Point) : (Point) - The center point
radius (float) : (float) - The radius of the circle
angle (float) : (float) - The angle in degrees
Returns: (Point) - The coordinate on the circle
getGrowthFactor(p1, p2, p3)
Get growth factor of spiral point
Parameters:
p1 (Point) : (Point) - The first point
p2 (Point) : (Point) - The second point
p3 (Point) : (Point) - The third point
Returns: (float) - The growth factor
method to_chart_point(point)
Convert Point to chart.point using chart.point.from_index(safeindex(point.x), point.y)
Namespace types: Point
Parameters:
point (Point) : (Point) - The point to convert
Returns: (chart.point) - The chart.point representation of the input point
method plotline(p1, p2, col, width)
Draw a line from p1 to p2
Namespace types: Point
Parameters:
p1 (Point) : (Point) First point
p2 (Point) : (Point) Second point
col (color)
width (int)
Returns: (line) Line object
method drawlines(points, col, ignore_boundary)
Draw lines between points in an array
Namespace types: array
Parameters:
points (array) : (array) The array of points
col (color) : (color) The color of the lines
ignore_boundary (bool) : (bool) The color of the lines
method to_chart_points(points)
Draw an array of points as chart points on the chart with line.new(chartpoint1, chartpoint2, color=linecolor)
Namespace types: array
Parameters:
points (array) : (array) - The points to draw
Returns: (array) The array of chart points
polygon_area(points)
Calculate the area of a polygon defined by an array of points
Parameters:
points (array) : (array) The array of points representing the polygon vertices
Returns: (float) The area of the polygon
polygon_perimeter(points)
Calculate the perimeter of a polygon
Parameters:
points (array) : (array) Array of points defining the polygon
Returns: (float) Perimeter of the polygon
is_point_in_polygon(point, _polygon)
Check if a point is inside a polygon
Parameters:
point (Point) : (Point) The point to check
_polygon (array)
Returns: (bool) True if the point is inside the polygon, false otherwise
method perimeter(points)
Calculates the convex hull perimeter of a set of points
Namespace types: array
Parameters:
points (array) : (array) The array of points
Returns: (array) The array of points forming the convex hull perimeter
Point
A Point, can be used for vector, floating calcs, etc. Use the cp method for plots
Fields:
x (series float) : (float) The x-coordinate
y (series float) : (float) The y-coordinate
a (series float) : (float) An Angle storage spot
v (series float) : (float) A Value
Line
Line
Fields:
point (Point) : (Point) The starting point of the line
slope (series float) : (float) The slope of the line
GOMTRY.
EMA TrendsThis script will send alerts when the short ema is bullish, bearish, or countertrend to the long ema.
Set your desired timeframe and add it to your chart with your desired EMA lengths.
This script can be useful for sending webhooks when the EMAs cross (bullish or bearish) or for when the trend starts to reverse (countertrend).
Simply add it to your desired chart and set up your desired alert (email, webhook, sound, etc.).
You can also change the ema plots to a different color etc.
Enjoy this simple alert!
[Helper] Color Table for Manual SelectionThis indicator displays the colors of the color picker from the indicator configuration menu on a large scale. It also shows the RGB values in decimal and as a hexadecimal code for each color. This color table provides a better overview of different colors compared to the color picker built into the Pine Editor, making it a useful alternative. Since cell contents cannot yet be selected with the mouse, the desired color code must be manually transferred to the Pine code.
Point Movement Per Candle (PMPCI) by Jaz Rod1. Counts Overall Candle Movement (tippy tip to bitty bottom)
2. Count live the Points of the Candle
3. Measure the volume of the candle. But you can toggle volume off.
MT5 Period SeparatorMT5 Period Separator.
With this indicator, you can see the daily, weekly, monthly divisions clearly. This will help you understanding market profiles, market cycles etc.
Pivot and Golden Crossover Swing Strategy### Strategy Description:
This **Pivot and Golden Crossover Swing Strategy** combines moving averages and pivot points to identify potential swing trade opportunities. It is designed for traders who want to leverage momentum and key price levels in their decisions.
#### Key Features:
1. **Golden Crossover**:
- A long position is triggered when the short moving average (50-period by default) crosses above the long moving average (200-period by default).
- A short position is triggered when the short moving average crosses below the long moving average.
2. **Pivot Points**:
- Identifies recent high and low pivot levels based on a user-defined lookback period (default is 5 candles).
- Pivot points are used to determine entry levels and calculate stop-loss and take-profit targets.
3. **Risk Management**:
- Stop-loss levels are set relative to pivot points with a user-defined multiplier (default: 1.5x).
- Take-profit targets are based on the distance between moving averages, adjusted by a multiplier (default: 2.0x).
4. **Visual Indicators**:
- Moving averages are plotted on the chart for trend visualization.
- Pivot points are marked with triangle shapes for easy identification.
#### Use Case:
This strategy works well in trending markets where golden crossovers indicate momentum shifts. The pivot points ensure precise trade management, making it suitable for swing traders aiming to capture medium-term price movements.
Let me know if you'd like any further details or adjustments!
TTZConcept GOLD XAUUSD Lot CalculatorThe Gold Lot Size Calculator for XAU/USD on TradingView is a powerful and user-friendly tool designed by TTZ Concept to help traders calculate the optimal lot size for their Gold trades based on their account size, risk tolerance, and the price movement of Gold (XAU/USD). Whether you're a beginner or an experienced trader, this tool simplifies position sizing, ensuring that your trades align with your risk management strategy.
Key Features:
Accurate Lot Size Calculation: Calculates the optimal lot size for XAU/USD trades based on your specified account balance and the percentage of risk per trade.
Flexible Risk Management**: Input your desired risk percentage (e.g., 1%, 2%) to ensure that you are not risking more than you're comfortable with on any single trade.
Customizable Inputs: Enter your account balance, risk percentage, stop loss (in pips), and leverage to get an accurate lot size recommendation.
Real-Time Data The tool uses real-time Gold price data to calculate the position size, ensuring that your risk management is always up to date with market conditions.
-Simple Interface: With easy-to-use sliders and input fields, you can quickly adjust your parameters and get the required lot size in seconds.
No Complicated Calculations Automatically factors in the pip value and contract specifications for XAU/USD, eliminating the need for manual calculations.
How It Works:
1. Input your trading account balance: The tool calculates based on your total equity.
2. Set your risk percentage: Choose how much of your account you want to risk on a single trade.
3. Define your stop loss in pips: Specify the distance of your stop loss from the entry point.
4. Get your recommended lot size: Based on your inputs, the tool will calculate the ideal lot size for your trade.
Why Use This Tool?
Precise Risk Management: Take control of your trading risk by ensuring that each trade is positioned according to your risk tolerance.
Save Time: No need for manual calculations — let the calculator handle the complex math and focus on your strategy.
Adapt to Changing Market Conditions: As the price of Gold (XAU/USD) fluctuates, your lot size adapts to ensure consistent risk management across different market conditions.
Perfect for:
- Gold traders (XAU/USD)
- Beginners seeking to understand position sizing and risk management
- Experienced traders looking to streamline their trading process
- Anyone who trades Gold futures, CFDs, or spot Gold in their trading account
Session Bar/Candle ColoringChange the color of candles within a user-defined trading session. Borders and wicks can be changed as well, not just the body color.
PREFACE
This script can be used an educational resource for those who are interested in learning Pine Script. Therefore, the script is published open source and is organized in a manner that follows the recommended Style Guide .
While the main premise of the indicator is rather simple, the script showcases various things that can be achieved such as conditional plotting, alignment of indicator settings, user input validation, script optimization, and more. The script also has examples of taking into consideration the chart timeframe and/or different chart types (Heikin Ashi, Renko, etc.) that a user might be running it on. Note: for complete beginners, I strongly suggest going through the Pine Script User Manual (possibly more than once).
FEATURES
Besides being able to select a specific time window, the indicator also provides additional color settings for changing the background color or changing the colors of neutral/indecisive candles, as shown in the image below.
This allows for a higher level of customization beyond the TradingView chart settings or other similar scripts that are currently available.
HOW TO USE
First, define the intraday trading session that will contain the candles to modify. The session can be limited to specific days of the week.
Next, select the parts of the candles that should be modified: Body, Borders, Wick, and/or Background.
For each of the candle parts that were enabled, you can select the colors that will be used depending on whether a candle is bullish (⇧), bearish (⇩), or neutral (⇆).
All other indicator settings will have a detailed tooltip to describe its usage and/or effect.
LIMITATIONS
The indicator is not intended to function on Daily or higher timeframes due to the intraday nature of session time windows.
The indicator cannot always automatically detect the chart type being used, therefore the user is requested to manually input the chart type via the " Chart Style " setting.
Depending on the available historical data and the selected choice for the " Portion of bar in session " setting, the indicator may not be able to update very old candles on the chart.
EXAMPLE USAGE
This section will show examples of different scenarios that the indicator can be used for.
Emphasizing a main trading session.
Defining a "Pre/post market hours background" like is available for some symbols (e.g., NASDAQ:AAPL ).
Highlighting in which bar the midnight candle occurs.
Hiding indecision bars (neutral candles).
Showing only "Regular Trading Hours" for a chart that does not have the option to toggle ETH/RTH. To achieve this, the actual chart data is hidden, and only the indicator is visible; alternatively, a 2nd instance of the indicator could change colors to match the chart background.
Using a combination of Bars and Japanese Candlesticks. Alternatively, this could be done by hiding the main chart data and using 2 instances of the indicator (one with " Chart Style " setting as Bars , and the other set to Candles ).
Using a combination of thin and thick bars on Range charts. Note: requires disabling the "Thin Bars" setting for Bar charts in the TradingView chart settings.
NOTES
If using more than one instance of this indicator on the same chart, you can use the TradingView "Save Indicator Template" feature to avoid having to re-configure the multiple indicators at a later time.
This indicator is intended to work "out-of-the-box" thanks to the behind_chart option introduced to Pine Script in October 2024. But you can always manually bring the indicator to the front just in case the color changes are not being seen (using the "More" option in the indicator status line: More > Visual Order > Bring to front ).
Many thanks to fikira for their help and inspiring me to create open source scripts.
Any feedback including bug reports or suggestions for improving the indicator (or source code itself) are always welcome in the comments section.
6 Band Parametric EQThis indicator implements a complete parametric equalizer on any data source using high-pass and low-pass filters, high and low shelving filters, and six fully configurable bell filters. Each filter stage features standard audio DSP controls including frequency, Q factor, and gain where applicable. While parametric EQ is typically used for audio processing, this implementation raises questions about the nature of filtering in technical analysis. Why stop at simple moving averages when you can shape your signal's frequency response with surgical precision? The answer may reveal more about our assumptions than our indicators.
Filter Types and Parameters
High-Pass Filter:
A high-pass filter attenuates frequency components below its cutoff frequency while passing higher frequencies. The Q parameter controls resonance at the cutoff point, with higher values creating more pronounced peaks.
Low-Pass Filter:
The low-pass filter does the opposite - it attenuates frequencies above the cutoff while passing lower frequencies. Like the high-pass, its Q parameter affects the resonance at the cutoff frequency.
High/Low Shelf Filters:
Shelf filters boost or cut all frequencies above (high shelf) or below (low shelf) the target frequency. The slope parameter determines the steepness of the transition around the target frequency , with a value of 1.0 creating a gentle slope and lower values making the transition more abrupt. The gain parameter sets the amount of boost or cut in decibels.
Bell Filters:
Bell (or peaking) filters create a boost or cut centered around a specific frequency. A bell filter's frequency parameter determines the center point of the effect, while Q controls the width of the affected frequency range - higher Q values create a narrower bandwidth. The gain parameter defines the amount of boost or cut in decibels.
All filters run in series, processing the signal in this order: high-pass → low shelf → bell filters → high shelf → low-pass. Each stage can be independently enabled or bypassed.
The frequency parameter for all filters represents the period length of the targeted frequency component. Lower values target higher frequencies and vice versa. All gain values are in decibels, where positive values boost and negative values cut.
The 6-Band Parametric EQ combines these filters into a comprehensive frequency shaping tool. Just as audio engineers use parametric EQs to sculpt sound, this indicator lets you shape market data's frequency components with surgical precision. But beyond its technical implementation, this indicator serves as a thought experiment about the nature of filtering in technical analysis. While traditional indicators often rely on simple moving averages or single-frequency filters, the parametric EQ takes this concept to its logical extreme - offering complete control over the frequency domain of price action. Whether this level of filtering precision is useful for analysis is perhaps less important than what it reveals about our assumptions regarding market data and its frequency components.
Fibonacci Retracement MTF/LOGIn Pine Script, there’s always a shorter way to achieve a result. As far as I can see, there isn’t an indicator among the community scripts that can produce Fibonacci Retracement levels (linear and logarithmic) as multiple time frame results based on a reference 🍺 This script, which I developed a long time ago, might serve as a starting point to fill this gap.
OVERVIEW
This indicator is a short and simple script designed to display Fibonacci Retracement levels on the chart according to user preferences, aiming to build the structure of support and resistance.
ORIGINALITY
This script:
Can calculate 'retracement' results from higher time frames.
Can recall previous time frame results using its reference parameter.
Performs calculations based on both linear and logarithmic scales.
Offers optional multipliers and appearance settings to simplify users’ tasks
CONCEPTS
Fibonacci Retracement is a technical analysis tool used to predict potential reversal points in an asset's price after a significant movement. This indicator identifies possible support and resistance levels by measuring price movements between specific points in a trend, using certain ratios derived from the Fibonacci sequence. It is based on impulsive price actions.
MECHANICS
This indicator first identifies the highest and lowest prices in the time frame specified by the user. Next, it determines the priority order of the bars where these prices occurred. Finally, it defines the trend direction. Once the trend direction is determined, the "Retracement" levels are constructed.
FUNCTIONS
The script contains two functions:
f_ret(): Generates levels based on the multiplier parameter.
f_print(): Handles the visualization by drawing the levels on the chart and positioning the labels in alignment with the levels. It utilizes parameters such as ordinate, confirmation, multiplier, and color for customization
NOTES
The starting bar for the time frame entered by the user must exist on the chart. Otherwise, the trend direction cannot be determined correctly, and the levels may be drawn inaccurately. This is also mentioned in the tooltip of the TimeFrame parameter.
I hope it helps everyone. Do not forget to manage your risk. And trade as safely as possible. Best of luck!
Outside Bar Strategy % (Alessio)Outside Bar Strategy %
This strategy is based on identifying Outside Bars, which occur when the current bar's high is higher than the previous bar's high and its low is lower than the previous bar's low. The strategy enters trades in the direction of the Outside Bar, offering a powerful way to capture price moves following a strong price expansion.
Key Features:
Long and Short Entries: The strategy enters a Long trade when the Outside Bar closes bullish (current close > open), and a Short trade when the Outside Bar closes bearish (current close < open).
Customizable Entry Levels: The entry point is calculated based on a customizable percentage of the Outside Bar's range, allowing flexibility for traders to fine-tune their entries at 50% or 70% of the bar's range.
Stop Loss (SL) and Take Profit (TP):
Stop Loss (SL) is automatically placed at the Outside Bar's low for Long trades and at its high for Short trades.
Take Profit (TP) is calculated as a percentage of the Outside Bar's range, with customizable settings for take-profit levels.
Visual Indicators:
Entry, Stop Loss, and Take Profit levels are plotted as lines on the chart, with customizable colors and widths for easy identification.
Labels are placed on the chart to indicate whether the trade is Long or Short, positioned above or below the Outside Bar's candlestick.
Alerts: Users can enable alerts to receive notifications when a trade is triggered, including details such as entry points and stop loss levels.
Strategy Parameters:
Entry Percentage: Set the entry level as a percentage of the Outside Bar's range (e.g., 50%, 70%).
Take Profit Percentage: Customize the Take Profit level as a percentage of the Outside Bar's range.
Customizable Colors and Line Widths: Adjust the colors and thickness of the entry, stop loss, and take profit lines to fit your preferences.
Alerts: Enable alerts to be notified when a trade is executed or when the entry level is reached.
This strategy is ideal for traders who want to capitalize on significant price moves after a breakout, with clear risk management through Stop Loss and Take Profit levels. The customizable features make it suitable for various market conditions and trading styles.
nifty supertrend tritonTrend based Strategy based on EMA , ATR and supertrend . Currently being used and testing on Nifty and Banknifty with adjusted parameters .
Do backtest before taking any trade
MTF Supertrend and RSI momentum Trendmultiple super trend combine with RSI direction for confirmation
combined MTF Supertrend and RSI Momentum Trend from Tzack88
Thanks and credit to original developers
Bitcoin vs Mag7 Combined IndexThis Mag7 Combined Index script is a custom TradingView indicator that calculates and visualizes the collective performance of the Magnificent 7 (Mag7) stocks—Apple, Microsoft, Alphabet, Amazon, NVIDIA, Tesla, and Meta (red line) compared to Bitcoin (blue line). It normalizes the daily closing prices of each stock to their initial value on the chart, scales them into percentages, and then computes their simple average to form a combined index. The result is plotted as a single line, offering a clear view of the aggregated performance of these influential stocks over time compared to Bitcoin.
This indicator is ideal for analyzing the overall market impact of the Mag7 compared to Bitcoin.
Dynamic Price level ArayPrice lines will move with the chart. Enter the different levels you want to watch. Once entered there is no need to move them. Very useful to have your levels moving on any time frame.
Solid Background for Current CandleWhat Does This Script Do?
Background Reflects Current Candle:
The entire chart background changes to green if the current candle is bullish (close > open).
It changes to red if the current candle is bearish (close < open).
Solid Background Without Per-Candle Behavior:
The background doesn't depend on individual candle colors. It applies one unified color for the entire chart based on the current candle's direction.
Uses a Box to Cover the Chart:
Instead of using bgcolor (which applies per candle), this script creates a large invisible rectangle (box) that spans the entire chart area.
The box dynamically updates its color with each new candle.
Swing Points AlertSwing Points Alert with Adjustable Delay
Description:
This script is designed to detect and alert traders about significant swing highs and lows on the chart. The script is equipped with customizable pivot detection settings and an innovative **Alert Delay** mechanism, allowing users to fine-tune their notifications to reduce noise and focus on key price movements.
Key Features:
1. **Swing High/Low Detection:**
- Identifies swing highs and lows based on user-defined pivot length.
- Visualizes these points with customizable labels for clarity.
2. **Customizable Alerts:**
- Enables real-time alerts for swing highs and lows.
- Users can adjust the delay for alerts to avoid false signals during volatile periods.
3. **Dynamic Label Management:**
- Automatically manages the number of displayed swing point labels.
- Removes crossed or outdated labels based on user preferences.
4. **Flexible Label Styling:**
- Provides multiple label styles (e.g., triangles, circles, arrows) and color customization for both swing highs and lows.
How the Alert Delay Works:
The **Alert Delay** helps filter signals by introducing a delay before triggering alerts. The delay is calculated as follows:
**Alert Delay (%) x Time Frame = Alert Delay in Time Frame Units**
For example:
- If the **Alert Delay** is set to 30% and the timeframe is **15 minutes**, the alert will be triggered after a delay of:
\
This ensures the alert is triggered only if the swing high/low condition remains valid for at least 4.5 minutes.
Important Notes:
1. **Timeframe Sensitivity:**
- This script is optimized for use across various timeframes, but users must adjust the **Alert Delay** percentage to match their trading style and timeframe.
- For example, higher timeframes may require lower delay percentages for timely alerts.
2. **Customization Options:**
- Easily customize pivot detection length, alert delay, label styles, and colors to suit your preferences.
3. **Support:**
- If you encounter any challenges or need help optimizing the script for your specific trading scenario, feel free to reach out for assistance.
Working HoursWorking Hours Visualization
Description:
This script is designed to visually highlight specific "Working Hours" sessions on the chart using background colors. It is tailored and optimized for the 15-minute timeframe, ensuring accurate session representation and proper functionality. If you choose to use this script on other timeframes, adjustments may be necessary to maintain its effectiveness.
Key Features:
Working Hours Highlighting: Displays background colors to mark predefined working hours, helping you focus on specific trading sessions.
Future Session Projection: Highlights working hours for future candles, providing a clear visual guide for planning trades.
Customizable Appearance: Offers adjustable colors, transparency, and session timings to suit individual preferences.
Weekly Separators: Includes optional weekly separators to visually distinguish trading weeks.
Important Notes:
Timeframe Compatibility:
This script is optimized for the 15-minute timeframe.
Using it on other timeframes may require optimization of session inputs and related logic.
Please feel free to reach out if you need assistance with adjustments for different timeframes.
Customization:
You can customize session timings, colors, and transparency levels through the input settings.
Support:
If you encounter any issues or need help optimizing the script for your specific needs, don't hesitate to contact me.
Fibonacci Retracement Strategy for CryptoThe Enhanced Fibonacci Retracement Strategy is designed to help traders capitalize on key Fibonacci levels for both long and short trades. This script automatically identifies significant swing highs and lows within a customizable lookback period and dynamically plots Fibonacci retracement levels (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%) as support and resistance levels.
Key Features:
Automatic Fibonacci Levels:
The script identifies the highest high and lowest low over a user-defined lookback period to calculate Fibonacci retracement levels.
Dual-Directional Trading:
Long Trades: Triggered when the price crosses above the 61.8% retracement level, anticipating a reversal.
Short Trades: Triggered when the price crosses below the 38.2% retracement level, capturing potential downward movement.
Compact Line Option:
Users can toggle "Compact Fibonacci Lines" to reduce visual clutter on the chart, making the lines shorter and easier to interpret.
Dynamic Alerts:
Alerts are embedded directly into the strategy logic for entry and exit points.
Long Entry: Triggered when the price bounces above the 61.8% level.
Long Exit: Triggered when the price reaches the 23.6% level.
Short Entry: Triggered when the price crosses below the 38.2% level.
Short Exit: Triggered when the price reaches the 78.6% level.
Clear Visualization:
Fibonacci levels are plotted with distinct colors and dashed lines (optional compact view),
providing traders with clear and actionable levels to make decisions.
Inputs:
Lookback Period: Number of candles to calculate swing highs and lows.
Plot Fibonacci Levels: Toggle to enable/disable plotting levels.
Compact Fibonacci Lines: Reduce the length of Fibonacci lines for a cleaner chart.
How It Works:
The strategy identifies a high-low range within the lookback period.
Fibonacci levels are calculated based on the range and plotted on the chart.
Long Trade Example:
Enter when the price crosses above the 61.8% level.
Exit when the price reaches the 23.6% level.
Short Trade Example:
Enter when the price crosses below the 38.2% level.
Exit when the price reaches the 78.6% level.
Best Use Cases:
Trending Markets: Use retracements to time entries in the direction of the trend.
Range-Bound Markets: Identify and trade reversals near key Fibonacci levels.
Important Notes:
This strategy is not financial advice and should be backtested thoroughly before live trading.
Risk management is crucial! Consider using stop-loss orders for protection.
Customize inputs to suit your preferred timeframe and trading style.
MAG 7 - Weighted Multi-Symbol Momentum + ExtrasOverview
This indicator aggregates the percentage change of multiple symbols into a single “weighted momentum” value. You can set individual weights to emphasize or de-emphasize particular stocks. The script plots two key items:
The default tickers in the script are:
AAPL (Apple)
AMZN (Amazon)
NVDA (NVIDIA)
MSFT (Microsoft)
GOOGL (Alphabet/Google)
TSLA (Tesla)
META (Meta Platforms/Facebook)
Raw Weighted Momentum (Histogram):
Each bar represents the combined (weighted) percentage change across your chosen symbols for that bar.
Bars are colored green if the momentum is above zero, or red if below zero.
Smoothed Momentum (Yellow Line):
An Exponential Moving Average (EMA) of the raw momentum for a smoother trend view.
Helps visualize when short-term momentum is accelerating or decelerating relative to its average.
Features
Symbol Inputs: Up to seven user-defined tickers, with weights for each symbol.
Smoothing Period: Set a custom lookback length to calculate the EMA (or switch to SMA in the code if you prefer).
Table Display: A built-in table in the top-right corner lists each symbol’s real-time percentage change, plus the total weighted momentum.
Alerts:
Configure alerts for when the weighted momentum crosses above or below user-defined thresholds.
Helps you catch major shifts in sentiment across multiple symbols.
How To Use
Select Symbols & Weights: In the indicator’s settings, specify the tickers you want to monitor and their corresponding weights. Weights default to 1 (equal weighting).
Watch the Bars vs. Zero:
Bars above zero mean a positive weighted momentum (the basket is collectively moving up).
Bars below zero mean negative weighted momentum (the basket is collectively under pressure).
Check the Yellow Line: The EMA of momentum.
If the bars consistently stay above the line, short-term momentum is stronger than its recent average.
If the bars dip below the line, momentum is weakening relative to its average.
Review the Table: Quick snapshot of each symbol’s daily percentage change plus the total basket momentum, all color-coded red or green.
Caution & Tips
This indicator measures rate of change, not absolute price levels. A rising momentum can still be part of a larger downtrend.
Always combine momentum readings with other technical and/or fundamental signals for confirmation.
For better reliability, experiment with different smoothing lengths to suit your trading style (shorter for scalping, longer for swing or positional approaches).
Data TransformerIt is a data transformer. Is something TradingView lacks right now.
It is simple, it lets you transform the symbol of the chart into this options:
% change
change
QoQ change
QoQ change %
YoY change
YoY change %
Drawdawn %
Drawdawn
Cumulative