StyleLibraryLibrary "StyleLibrary"
A small library of Pine Script functions that return built-in style variables.
method sizeStyle(size)
Takes a `string` that returns the corresponding built-in size style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
size (string) : A `string` representing a built-in size style: `"Tiny"`, `"Small"`, `"Normal"`, `"Large"`,
`"Huge"`, `"Auto"`.
Returns: The respective built-in size style variable.
method sizeStyle(size)
Takes a `sizeStyle` that returns the corresponding built-in size style variable.
Namespace types: series sizeStyle
Parameters:
size (series sizeStyle) : A `sizeStyle` representing a built-in size style variable.
Returns: The respective built-in size style variable.
method lineStyle(style)
Takes a `string` that returns the corresponding built-in line style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in line style: `"Dashed"`, `"Dotted"`, `"Solid"`.
Returns: The respective built-in line style variable.
method lineStyle(style)
Takes a `lineStyle` that returns the corresponding built-in line style variable.
Namespace types: series lineStyle
Parameters:
style (series lineStyle) : A `lineStyle` representing a built-in line style variable.
Returns: The respective built-in line style variable.
method labelStyle(style)
Takes a `string` that returns the corresponding built-in label style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in label style:
`"Arrow Down"`, `"Arrow Up"`, `"Circle"`, `"Cross"`, `"Diamond"`, `"Flag"`,
`"Label Center"`, `"Label Down"`, `"Label Left"`, `"Label Lower Left"`,
`"Label Lower Right"`, `"Label Right"`, `"Label Up"`, `"Label Upper Left"`,
`"Label Upper Right"`, `"None"`, `"Square"`, `"Text Outline"`, `"Triangle Down"`,
`"Triangle Up"`, `"XCross"`.
Returns: The respective built-in label style variable.
method labelStyle(style)
Takes a `labelStyle` that returns the corresponding built-in label style variable.
Namespace types: series labelStyle
Parameters:
style (series labelStyle) : A `labelStyle` representing a built-in label style variable.
Returns: The respective built-in label style variable.
method fontStyle(font)
Takes a `string` that returns the corresponding built-in font style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
font (string) : A `string` representing a built-in font style: `"Default"`, `"Monospace"`.
Returns: The respective built-in font style variable.
method positionStyle(position)
Takes a `string` that returns the corresponding built-in position style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
position (string) : A `string` representing a built-in position style:
`"Bottom Center", `"Bottom Left", `"Bottom Right", `"Middle Center", `"Middle Left",
`"Middle Right", `"Top Center", `"Top Left", `"Top Right".
Returns: The respective built-in position style variable.
method displayStyle(display)
Takes a `simple string` that returns the corresponding built-in display style variable.
Namespace types: simple string, input string, const string
Parameters:
display (simple string) : A `simple string` representing a built-in display style: `"All"`, `"Data Window"`,
`"None"`, `"Pane"`, `"Price Scale"`, `"Status Line"`.
Returns: The respective built-in display style variable.
LINE
Sticky Moving AverageThe Sticky Moving Average is a custom indicator designed to provide a unique smoothing effect by combining different moving averages derived from a single base period. This indicator creates a single line on the chart, representing the average of the following three moving averages:
1. X-period Simple Moving Average (SMA): A traditional moving average that smooths the price data over the full period.
2. X/2-period Simple Moving Average (SMA): A faster-moving average that smooths the price data over half of the base period.
3. X/4-period Exponential Moving Average (EMA): An exponential moving average that gives more weight to recent prices, calculated over one-fourth of the base period.
The result is a moving average that "sticks" to price action by considering both short-term and long-term trends, offering a balanced view of market momentum.
This indicator is ideal for traders looking to gain a nuanced understanding of price movements by incorporating multiple smoothing periods into a single, easy-to-use line. Adjust the `X` value to suit your trading strategy and enjoy the clarity this composite moving average can bring to your charts.
Time Vertical LineThis indicator is designed to plot vertical lines at specified hourly intervals on a trading chart. The indicator includes default settings to draw vertical lines at every hour of the day and provides users with the flexibility to customize up to six additional vertical lines at specified times.
Traders can use the vertical lines to segment the trading day, making it easier to analyze market movements within specific hours.
Customizable lines allow traders to mark important times such as market openings, closings, and economic news releases.
This indicator is a powerful tool for traders who need to keep track of specific times and events during the trading day, providing a clear and customizable visual representation of time on their charts.
The indicator allows you to easily customize the appearance of the 24 default vertical lines that mark each hour of the day. You can change the color by adjusting the Color input, modify the transparency using the Transparency input, and set the line width with the Line Width input.
Each of custom lines can have its own color, transparency, and line width, giving you full control over their appearance. By default, these custom vertical lines are turned off. To activate them, go to the "Style" tab in the settings menu of the indicator.
The time for each vertical line is based on the exchange's timezone. You can set the time for each of the 6 custom vertical lines using decimal notation. For example:
Input 9.1 to display a vertical line at 9:10.
Input 9.15 to display a vertical line at 9:15.
The indicator should only be displayed in time frames less than 15 minutes. Go to "Visibility" in settings for options.
DeleteArrayType█ OVERVIEW
Here are common functions usually delete drawing once array of drawing is recall.
Method is used as in pine script version 5 instead of custom function.
It is an upgrade from DeleteArrayObject , which may not support overload parameter in future.
Library "DeleteArrayType"
TODO: Delete array type especially for drawings
method deleteLabel(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: label.delete()
method deleteLine(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: line.delete()
method deleteLineFill(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: linefill.delete()
method deletePolyLine(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: polyline.delete()
method deleteBox(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: box.delete()
method deleteTable(id)
TODO: Delete array
Namespace types: array
Parameters:
id (array)
Returns: TODO: table.delete()
Price Cross Time Custom Range Interactive█ OVERVIEW
This indicator was a time-based indicator and intended as educational purpose only based on pine script v5 functions for ta.cross() , ta.crossover() and ta.crossunder() .
I realised that there is some overlap price with the cross functions, hence I integrate them into Custom Range Interactive with value variance and overlap displayed into table.
This was my submission for Pinefest #1 , I decided to share this as public, I may accidentally delete this as long as i keep as private.
█ INSPIRATION
Inspired by design, code and usage of CAGR. Basic usage of custom range / interactive, pretty much explained here . Credits to TradingView.
█ FEATURES
1. Custom Range Interactive
2. Label can be resize and change color.
3. Label show tooltip for price and time.
4. Label can be offset to improve readability.
5. Table can show price variance when any cross is true.
6. Table can show overlap if found crosss is overlap either with crossover and crossunder.
7. Table text color automatically change based on chart background (light / dark mode).
8. Source 2 is drawn as straight line, while Source 1 will draw as label either above line for crossover, below line for crossunder and marked 'X' if crossing with Source 2's line.
9. Cross 'X' label can be offset to improve readability.
10. Both Source 1 and Source 2 can select Open, Close, High and Low, which can be displayed into table.
█ LIMITATIONS
1. Table is limited to intraday timeframe only as time format is not accurate for daily timeframe and above. Example daily timeframe will give result less 1 day from actual date.
2. I did not include other sources such external source or any built in sources such as hl2, hlc3, ohlc4 and hlcc4.
█ CODE EXPLAINATION
I pretty much create custom function with method which returns tuple value.
method crossVariant(float price = na, chart.point ref = na) =>
cross = ta.cross( price, ref.price)
over = ta.crossover( price, ref.price)
under = ta.crossunder(price, ref.price)
Unfortunately, I unable make the labels into array which i plan to return string value by getting the text value from array label, hence i use label.all and add incremental int value as reference.
series label labelCross = na, labelCross.delete()
var int num = 0
if over
num += 1
labelCross := label.new()
if under
num += 1
labelCross := label.new()
if cross
num += 1
labelCross := label.new()
I realised cross value can be overlap with crossover and crossunder, hence I add bool to enable force overlap and add additional bools.
series label labelCross = na, labelCross.delete()
var int num = 0
if forceOverlap
if over
num += 1
labelCross := label.new()
if under
num += 1
labelCross := label.new()
if cross
num += 1
labelCross := label.new()
else
if cross and over
num += 1
labelCross := label.new()
if cross and under
num += 1
labelCross := label.new()
if cross and not over and not under
num += 1
labelCross := label.new()
█ USAGE / EXAMPLES
Extended Parallel ChannelsThis indicator provides an enhanced version of the popular Parallel Channel tool by allowing channel boundaries to be extended above and below the primary channel. It can also serve as a general tool for drawing parallel lines and grid lines to aid technical analysis.
🟠 Application
There are two primary ways extended channels can provide valuable insights:
🔵 Support and Resistance Levels
When prices break out of a channel, they often encounter strong resistance at approximately the 100% extension point. Breakout traders can utilize the extended channel boundary to place take-profit orders. Meanwhile, reversal traders can look for entry opportunities at this level.
🔵 Grid / Martingale Trading
Grid Trading and Martingale Trading strategies rely heavily on grid lines. This indicator streamlines that process by enabling traders to effortlessly plot grid lines across the chart.
🟠 Instructions
Upon adding the indicator, the user will be prompted to set the channel boundaries by placing three anchor points on the chart. The first two anchors determine one boundary line, while the third anchor determine the other boundary line.
Once the three anchors are positioned, the indicator automatically plots the resulting channel as well as the extended lines. The anchor points are highlighted as movable blue circles, allowing the user to dynamically adjust the channel formation by dragging the anchors to new locations as needed.
Polyline PlusThis library introduces the `PolylinePlus` type, which is an enhanced version of the built-in PineScript `polyline`. It enables two features that are absent from the built-in type:
1. Developers can now efficiently add or remove points from the polyline. In contrast, the built-in `polyline` type is immutable, requiring developers to create a new instance of the polyline to make changes, which is cumbersome and incurs a significant performance penalty.
2. Each `PolylinePlus` instance can theoretically hold up to ~1M points, surpassing the built-in `polyline` type's limit of 10K points, as long as it does not exceed the memory limit of the PineScript runtime.
Internally, each `PolylinePlus` instance utilizes an array of `line`s and an array of `polyline`s. The `line`s array serves as a buffer to store lines formed by recently added points. When the buffer reaches its capacity, it flushes the contents and converts the lines into polylines. These polylines are expected to undergo fewer updates. This approach is similiar to the concept of "Buffered I/O" in file and network systems. By connecting the underlying lines and polylines, this library achieves an enhanced polyline that is dynamic, efficient, and capable of surpassing the maximum number of points imposed by the built-in polyline.
🔵 API
Step 1: Import this library
import algotraderdev/polylineplus/1 as pp
// remember to check the latest version of this library and replace the 1 above.
Step 2: Initialize the `PolylinePlus` type.
var p = pp.PolylinePlus.new()
There are a few optional params that developers can specify in the constructor to modify the behavior and appearance of the polyline instance.
var p = pp.PolylinePlus.new(
// If true, the drawing will also connect the first point to the last point, resulting in a closed polyline.
closed = false,
// Determines the field of the chart.point objects that the polyline will use for its x coordinates. Either xloc.bar_index (default), or xloc.bar_time.
xloc = xloc.bar_index,
// Color of the polyline. Default is blue.
line_color = color.blue,
// Style of the polyline. Default is line.style_solid.
line_style = line.style_solid,
// Width of the polyline. Default is 1.
line_width = 1,
// The maximum number of points that each built-in `polyline` instance can contain.
// NOTE: this is not to be confused with the maximum of points that each `PolylinePlus` instance can contain.
max_points_per_builtin_polyline = 10000,
// The number of lines to keep in the buffer. If more points are to be added while the buffer is full, then all the lines in the buffer will be flushed into the poylines.
// The higher the number, the less frequent we'll need to // flush the buffer, and thus lead to better performance.
// NOTE: the maximum total number of lines per chart allowed by PineScript is 500. But given there might be other places where the indicator or strategy are drawing lines outside this polyline context, the default value is 50 to be safe.
lines_bffer_size = 50)
Step 3: Push / Pop Points
// Push a single point
p.push_point(chart.point.now())
// Push multiple points
chart.point points = array.from(p1, p2, p3) // Where p1, p2, p3 are all chart.point type.
p.push_points(points)
// Pop point
p.pop_point()
// Resets all the points in the polyline.
p.set_points(points)
// Deletes the polyline.
p.delete()
🔵 Benchmark
Below is a simple benchmark comparing the performance between `PolylinePlus` and the native `polyline` type for incrementally adding 10K points to a polyline.
import algotraderdev/polylineplus/2 as pp
var t1 = 0
var t2 = 0
if bar_index < 10000
int start = timenow
var p = pp.PolylinePlus.new(xloc = xloc.bar_time, closed = true)
p.push_point(chart.point.now())
t1 += timenow - start
start := timenow
var polyline pl = na
var points = array.new()
points.push(chart.point.now())
if not na(pl)
pl.delete()
pl := polyline.new(points)
t2 += timenow - start
if barstate.islast
log.info('{0} {1}', t1, t2)
For this benchmark, `PolylinePlus` took ~300ms, whereas the native `polyline` type took ~6000ms.
We can also fine-tune the parameters for `PolylinePlus` to have a larger buffer size for `line`s and a smaller buffer for `polyline`s.
var p = pp.PolylinePlus.new(xloc = xloc.bar_time, closed = true, lines_buffer_size = 500, max_points_per_builtin_polyline = 1000)
With the above optimization, it only took `PolylinePlus` ~80ms to process the same 10K points, which is ~75x the performance compared to the native `polyline`.
Zigzag Chart Points█ OVERVIEW
This indicator displays zigzag based on high and low using latest pine script version 5 , chart.point which using time, index and price as parameters.
Pretty much a strip down using latest pine script function, without any use of library .
This allow pine script user to have an idea of simplified and cleaner code for zigzag.
█ CREDITS
LonesomeTheBlue
█ FEATURES
1. Label can be show / hide including text can be resized.
2. Hover to label, can see tooltip will show price and time.
3. Tooltip will show date and time for hourly timeframe and below while show date only for day timeframe and above.
█ NOTES
1. I admit that chart.point just made the code much more cleaner and save more time. I previously using user-defined type(UDT) which quite hassle.
2. I have no plan to extend this indicator or include alert just I thinking to explore log.error() and runtime.error() , which I may probably release in other publications.
█ HOW TO USE'
Pretty much similar inside mentioned references, which previously I created.
█ REFERENCES
1. Zigzag Array Experimental
2. Simple Zigzag UDT
3. Zig Zag Ratio Simplified
4. Cyclic RSI High Low With Noise Filter
5. Auto AB=CD 1 to 1 Ratio Experimental
Line Colorizer - DurbtradeThe Line Colorizer is a simple indicator that can plot up/down-colorized lines for up to 10 unique individual sources!
Plot up/down colors are based on whether the current value is above or below the previous value.
Also included is a separate color for when the current value is equal to the previous value.
All colors can be modified, along with the plot styles.
--------------------------------------------
--------------------------------------------
Here is the Inputs tab of the Settings menu :
As you can see, you can plot a colorized line of up to 10 individual sources!
Checking the checkbox turns on that particular colorized plot,
and clicking on the drop down menu allows you select the source for that plot.
The plot styles, up/equal/down colors, and opacities
are customizable under the Style tab within the Settings menu :
Overall, it is pretty easy to use.
--------------------------------------------
Let's look at some examples of the Line Colorizer being used...
Colorize a basic Bollinger Bands indicator :
Want to colorize 3 EMA's? Go for it :
Spice up the standard MACD salad :
Customize the colors of your RSI's :
Try using the Line Colorizer on all of your favorite indicators.
--------------------------------------------
Script Stats :
Pinescript Version : 5
Code Length : 44 Lines
Max Unique Input Sources : 10
Max Visible Plots : 10
Total Colors/Opacities : 30
--------------------------------------------
Tips :
Typically you will want this indicator to be on a layer above (in front of) the source plot layer.
Stay mindful of line thicknesses,
and whether the original source plot is still visible or not.
The final output of the colorized plots are drawn in numerical order,
so, Colorized Source #1 is drawn first, and will appear below Colorized Source #2 on the chart...
and so on, with Colorized Source #10 being drawn last, at the very top.
Final Thoughts :
I like having this indicator.
The idea and script is simple, and the indicator is practical.
It's one method of easily separating some of the aspects of color from your favorite indicators and scripts,
and then customizing those aspects to your liking.
Especially practical for those who do not want to learn about writing their own scripts.
I think that this indicator can be a useful tool in the shed,
used for customizing the visuals of multiple unique sources
that are all on the same price/value scale.
It can help increase chart clarity and/or detail...
whether using it on top of a main chart that is simple,
or on top of a standalone indicator that is crowded with oscillating information.
I hope that you enjoy it and find it useful!
- Please feel free to comment your thoughts, critiques, or suggestions. They are all very helpful!
- Also, please feel free to comment any positive feedback, or awesome screencaps/ideas of the indicator in action!
- Check out my other Pinescript indicators if you like this one... they work well together.
- May your trades be successful!
--------------------------------------------
// Durbtrade
ObjectHelpersLibrary "ObjectHelpers"
Line | Box | Label | Linefill -- Maker, Setter, Getter Library
TODO: add table functionality
set(object)
set all params for `line`, `box`, `label`, `linefill` objects with 1 function
***
## Overloaded
***
```
method set(line Line, int x1=na, float y1=na, int x2=na, float y2=na,string xloc=na,string extend=na,color color=na,string style=na,int width=na,bool update=na) => line
```
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1
- **y1** `float` - value to set y1
- **x2** `int` - value to set x2
- **y2** `float` - value to set y2
- **xloc** `int` - value to set xloc
- **yloc** `int` - value to set yloc
- **extend** `string` - value to set extend
- **color** `color` - value to set color
- **style** `string` - value to set style
- **width** `int` - value to set width
- **update** `bool` - value to set update
***
```
method set(box Box,int left=na,float top=na,int right=na, float bottom=na,color bgcolor=na,color border_color=na,string border_style=na,int border_width=na,string extend=na,string txt=na,color text_color=na,string text_font_family=na,string text_halign=na,string text_valign=na,string text_wrap=na,bool update=false) => box
```
### Params
- **Box** `box` - box object
- **left** `int` - value to set left
- **top** `float` - value to set top
- **right** `int` - value to set right
- **bottom** `float` - value to set bottom
- **bgcolor** `color` - value to set bgcolor
- **border_color** `color` - value to set border_color
- **border_style** `string` - value to set border_style
- **border_width** `int` - value to set border_width
- **extend** `string` - value to set extend
- **txt** `string` - value to set _text
- **text_color** `color` - value to set text_color
- **text_font_family** `string` - value to set text_font_family
- **text_halign** `string` - value to set text_halign
- **text_valign** `string` - value to set text_valign
- **text_wrap** `string` - value to set text_wrap
- **update** `bool` - value to set update
***
```
method set(label Label,int x=na,float y=na, string txt=na,string xloc=na,color color=na,color textcolor=na,string size=na,string style=na,string textalign=na,string tooltip=na,string text_font_family=na,bool update=false) => label
```
### Paramas
- **Label** `label` - label object
- **x** `int` - value to set x
- **y** `float` - value to set y
- **txt** `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
- **textcolor** `color` - value to set textcolor
- **size** `string` - value to set size
- **style** `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
- **text_font_family** `string` - value to set text_font_family
- **textalign** `string` - value to set textalign
- **tooltip** `string` - value to set tooltip
- **update** `bool` - update label to next bar
***
```
method set(linefill Linefill=na,line line1=na,line line2=na,color color=na) => linefill
```
### Params
- **linefill** `linefill` - linefill object
- **line1** `line` - line object
- **line2** `line` - line object
- **color** `color` - color
Parameters:
object (obj)
Returns: `line`, `box`, `label`, `linefill`
method set(Line, x1, y1, x2, y2, xloc, extend, color, style, width, update)
set the location params of a line with 1 function auto detects time or bar_index for xloc param
Namespace types: series line
Parameters:
Line (line) : `line` - line object | `required`
x1 (int) : `int` - value to set x1
y1 (float) : `float` - value to set y1
x2 (int) : `int` - value to set x2
y2 (float) : `float` - value to set y2
xloc (string) : `int` - value to set xloc
extend (string) : `string` - value to set extend
color (color) : `color` - value to set color
style (string) : `string` - value to set style
width (int) : `int` - value to set width
update (bool) : `bool` - value to set update
Returns: `line`
method set(Box, left, top, right, bottom, bgcolor, border_color, border_style, border_width, extend, txt, text_color, text_font_family, text_halign, text_valign, text_wrap, update)
set the location params of a box with 1 function
Namespace types: series box
Parameters:
Box (box) : `box` - box object | `required`
left (int) : `int` - value to set left
top (float) : `float` - value to set top
right (int) : `int` - value to set right
bottom (float) : `float` - value to set bottom
bgcolor (color) : `color` - value to set bgcolor
border_color (color) : `color` - value to set border_color
border_style (string) : `string` - value to set border_style
border_width (int) : `int` - value to set border_width
extend (string) : `string` - value to set extend
txt (string) : `string` - value to set _text
text_color (color) : `color` - value to set text_color
text_font_family (string) : `string` - value to set text_font_family
text_halign (string) : `string` - value to set text_halign
text_valign (string) : `string` - value to set text_valign
text_wrap (string) : `string` - value to set text_wrap
update (bool) : `bool` - value to set update
Returns: `box`
method set(Label, x, y, txt, xloc, color, textcolor, size, style, textalign, tooltip, text_font_family, update)
set the location params of a label with 1 function auto detects time or bar_index for xloc param
Namespace types: series label
Parameters:
Label (label) : `label` | `required`
x (int) : `int` - value to set x
y (float) : `float` - value to set y
txt (string) : `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
xloc (string)
color (color)
textcolor (color) : `color` - value to set textcolor
size (string) : `string` - value to set size
style (string) : `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
textalign (string) : `string` - value to set textalign
tooltip (string) : `string` - value to set tooltip
text_font_family (string) : `string` - value to set text_font_family
update (bool) : `bool` - update label to next bar
Returns: `label`
method set(Linefill, line1, line2, color)
change the 1 or 2 of the lines in a linefill object
Namespace types: series linefill
Parameters:
Linefill (linefill)
line1 (line) : `line` - line object
line2 (line) : `line` - line object
color (color) : `color` - color
Returns: `linefill`
get(object)
get all of the location variables for `line`, `box`, `label` objects or the line objects from a `linefill`
***
## Overloaded
***
```
method get(line Line) =>
```
### Params
- **Line** `line` - line object | `required`
***
```
method get(box Box) =>
```
### Params
- **Box** `box` - box object | `required`
***
```
method get(label Label) =>
```
### Paramas
- **Label** `label` - label object | `required`
***
```
method get(linefill Linefill) =>
```
### Params
- **Linefill** `linefill` - linefill object | `required`
Parameters:
object (obj)
Returns: ` `
method get(Line)
Gets the location paramaters of a Line
Namespace types: series line
Parameters:
Line (line) : `line` - line object
Returns:
method get(Box)
Gets the location paramaters of a Box
Namespace types: series box
Parameters:
Box (box) : `box` - box object
Returns:
method get(Label)
Gets the `x`, `y`, `text` of a Label
Namespace types: series label
Parameters:
Label (label) : `label` - label object
Returns:
method get(Linefill)
Gets `line 1`, `line 2` from a Linefill
Namespace types: series linefill
Parameters:
Linefill (linefill) : `linefill` - linefill object
Returns:
method set_x(Line, x1, x2)
set the `x1`, `x2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1 | `required`
- **x2** `int` - value to set x2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
x1 (int) : `int` - value to set x1
x2 (int) : `int` - value to set x2
Returns: `line`
method set_y(Line, y1, y2)
set `y1`, `y2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **y1** `float` - value to set y1 | `required`
- **y2** `float` - value to set y2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
y1 (float) : `float` - value to set y1
y2 (float) : `float` - value to set y2
Returns: `line`
method Line(x1, y1, x2, y2, extend, color, style, width)
Similar to `line.new()` but can detect time or bar_index for xloc param and has defaults for all params but `x1`, `y1`, `x2`, `y2`
***
### Params
- **x1** `int` - value to set
- **y1** `float` - value to set
- **x2** `int` - value to set
- **y2** `float` - value to set
- **extend** `string` - extend value to set line
- **color** `color` - color to set line
- **style** `string` - style to set line
- **width** `int` - width to set line
Namespace types: series int, simple int, input int, const int
Parameters:
x1 (int) : `int` - value to set
y1 (float) : `float` - value to set
x2 (int) : `int` - value to set
y2 (float) : `float` - value to set
extend (string) : `string` - extend value to set line
color (color) : `color` - color to set line
style (string) : `string` - style to set line
width (int) : `int` - width to set line
Returns: `line`
method Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() with the but can detect xloc param and has defaults for everything but location params
***
### Params
- **left** `int` - value to set
- **top** `float` - value to set
- **right** `int` - value to set
- **bottom** `float` - value to set
- **extend** `string` - extend value to set box
- **border_color** `color` - color to set border
- **bgcolor** `color` - color to set background
- **text_color** `color` - color to set text
- **border_width** `int` - width to set border
- **border_style** `string` - style to set border
- **txt** `string` - text to set
- **text_halign** `string` - horizontal alignment to set text
- **text_valign** `string` - vertical alignment to set text
- **text_size** `string` - size to set text
- **text_wrap** `string` - wrap to set text
Namespace types: series int, simple int, input int, const int
Parameters:
left (int) : `int` - value to set
top (float) : `float` - value to set
right (int) : `int` - value to set
bottom (float) : `float` - value to set
extend (string) : `string` - extend value to set box
border_color (color) : `color` - color to set border
bgcolor (color) : `color` - color to set background
text_color (color) : `color` - color to set text
border_width (int) : `int` - width to set border
border_style (string) : `string` - style to set border
txt (string) : `string` - text to set
text_halign (string) : `string` - horizontal alignment to set text
text_valign (string) : `string` - vertical alignment to set text
text_size (string) : `string` - size to set text
text_wrap (string) : `string` - wrap to set text
Returns: `box`
method Label(txt, x, y, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
Similar to label.new() but can detect time or bar_index for xloc param and has defaults for all params but x, y, txt, tooltip
***
### Params
- **txt** `string` - string to set
- **x** `int` - value to set
- **y** `float` - value to set
- **yloc** `string` - y location to set
- **color** `color` - label color to set
- **textcolor** `color` - text color to set
- **style** `string` - style to set
- **size** `string` - size to set
- **textalign** `string` - text alignment to set
- **text_font_family** `string` - font family to set
- **tooltip** `string` - tooltip to set
Namespace types: series string, simple string, input string, const string
Parameters:
txt (string) : `string` - string to set
x (int) : `int` - value to set
y (float) : `float` - value to set
yloc (string) : `string` - y location to set
color (color) : `color` - label color to set
textcolor (color) : `color` - text color to set
style (string) : `string` - style to set
size (string) : `string` - size to set
textalign (string) : `string` - text alignment to set
text_font_family (string) : `string` - font family to set
tooltip (string) : `string` - tooltip to set
Returns: `label`
obj
Fields:
obj (series__string)
RS RatingHello everyone.
The RS Rating (or Relative Strenght Rating) is a metric that tracks a stock's price performance relative to the rest of the market. Specifically, it looks at a stock's relative strength over the last 52 weeks.
It allows you to identify at a glance stocks that are outperforming the market and may be poised for further gains.
Designed for break-out traders, trend follower, value investors, the RS Rating can help you identify promising opportunities and make informed investment decisions.
The Rating stands as follow:
- From 1 (worst) to 99 (best)
- 99 rating means the stock is outperforming 99% of all stocks in terms of relative share price performance over the last 52 weeks.
The RS Rating is accompanied by the RS line which is a representation of the progress of the asset against the comparative symbol. (Here SP500)
Of course this script is inspired by the IBD rating system.
The results may be equivalent but it is not guaranteed.
This indicator proposes a scoring system in the style of the one proposed by IBD.
Indeed for an optimal result, it would be necessary to compare the relative performance of all actions, which is not yet possible on PineScript.
Here is the formula for calculating the score:
RS Score = 40% * P3 + 20% * P6 + 20% * P9 + 20% * P12
With
P3 = Performance over the last 3 months
P6 = Performance over the last 6 months
P9 = Performance over the last 9 months
P12 = Performance over the last 12 months
There is no equivalent solution for the moment on TradingView.
The rating score will only appear on the daily timeframe.
For now it's my pleasure to share!
Vertical Lines 2A vertical line plotting function is missing in Pinescript. This is another method to plot vertical line on a chart, and an improvement on my previous script "vertical lines" .
The script hacks the plotcandle function to display just the wicks without the body. This hack simulates a vertical line. The body of the candle is non-existing since the open and close are the same and its color is set to null. The wicks are abutting resulting in a continuous vertical line.
Drawbacks include inability to set width and transparency of the lines. The plotcandle function does not allow setting the width and transparency of the wicks. This feature would be desirable.
The crossing of the RSI of overbought and undersold zones is used as an example in this published script. Any indicator can be used and this script can be executed on any other indicator by using "add indicator" on the desired indicator, and selecting the indicator as the source. I added crossover lines on the plotted RSI as an example.
//////////////////////////////////////////////////////Breakdown of the script////////////////////////////////////////////////////////
The src input determines which price data is used for the highest value calculation. By default, it is set to the close price.
The length input determines the length of the RSI calculation. By default, it is set to 14.
The mult input determines the multiplier of the highest value that is used to determine the height of the vertical lines. By default, it is set to 100%, meaning the lines will reach the highest value in the dataset.
The top and bot inputs determine the overbought and oversold levels for the RSI. By default, they are set to 70 and 30, respectively.
The current_rsi and previous_rsi variables calculate the RSI values for the current bar and the previous bar, respectively.
The hi_value variable finds the highest value in the dataset, and the hi variable calculates the height of the vertical lines based on the highest value and the user-defined multiplier. The lo variable calculates the distance between the highest value and the current price data.
The uph, dnh, upl, and dnl variables determine the height and low of the vertical lines for when the RSI crosses overbought or oversold levels.
The if statements check if the RSI has crossed overbought or oversold levels and set the uph, dnh, upl, and dnl variables accordingly.
Finally, the plotcandle() function is used to plot the vertical lines on the chart. The open and close values are set to the src input, and the high and low values are set to the uph, dnh, upl, and dnl variables. The bordercolor argument is set to na to hide the borders of the lines, and the wickcolor argument is set to green or red, depending on whether the line is an overbought or oversold crossover.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Vector2DrawLineLibrary "Vector2DrawLine"
Extends line type with methods for Vector2 and Segment2.
new(origin, target, xloc, extend, color, style, width)
Draws a line using Segment type to hold its coordinate properties..
Parameters:
origin : Vector2 . Origin vector of the line.
target : Vector2 . Target vector of the line.
xloc : string
extend : string
color : color
style : string
width : int
Returns: line object
new(segment, xloc, extend, color, style, width)
Draws a line using Segment type to hold its coordinate properties..
Parameters:
segment : Segment2 . Segment with positional coordinates.
xloc : string
extend : string
color : color
style : string
width : int
Returns: line object
rotate_around(this, center, angle)
Instance method to rotate line around center vector (modifies input line).
Parameters:
this : line . Line object.
center : Vector2 . Center of rotation.
angle : float . Rotation angle in degrees.
Returns: line. Rotated line object.
FOREX MASTER PATTERN Value Lines by nnamThe Forex Master Pattern is form of technical analysis that provides a framework for spotting hidden price patterns that reveal the true movement of the market. The Forex Master Pattern Value Lines Indicator helps to identify this Phase 1 contraction of the Forex Master Pattern cycle.
HOW THIS INDICATOR WORKS
This indicator looks for a sustained contraction in price initially indicated by TWO contraction bars in a row, thus detecting a contraction point and a potential new master pattern origin point.
Once a contraction point is detected, a blue box will appear on the chart with a thick solid blue line projecting from its center. These are potential "Points of Origin" and "Value Lines" that institutional traders use to balance their books.
As shown above, when price begins to move (detected by engulfing and/or expansion candles), an Arrow is plotted to the chart identifying a possible expansion.
As shown above, previous Value Lines typically serve as future support / resistance points, however, due to the unique location of these lines, they are not typically identified as support or resistance levels on standard S/R indicators.
Color Coded Candles assist the user in quickly identifying contraction and expansion areas as well as trends away from the value-line. The expansion candles, Up/Down candles, and contraction BARS are all inspired by the STRAT (Rob Smith) and are specifically incorporated into this indicator to assist the user in finding potential reversals during the expansion phase. This helps to avoid the whiplash typically associated with the first phase of Forex Master Pattern.
USER DEFINED SETTINGS
- Line Settings Section -
#Max Lines to Show
This limits or extends the total number of lines shown on the chart. The Default is 12 (minimum is 1, maximum is 499).
#Show Lines on Chart
This setting turns all lines ON or OFF on the chart
#Show Value-Lines on Chart
This setting turns the Value Lines ON or OFF on the chart
#Set Value-Line Width
This setting sets the width of the value-line displayed on the chart
#Only show last value-line on the chart
This setting removes all but the most recent value-line from the chart
- Box Settings Section -
#Show Last Box Only
This setting turns OFF all previous boxes and only shows the most recent contraction box on the chart
- Expansion Area Settings Section -
#Show Expansion Area
This setting turns ON or OFF the expansion area fill
#Show Expansion Guidelines on Chart
This setting turns ON or OFF the guidelines that show the current direction of the price via an extended line.
- Candle Colors Section -
#Color Code the Candles
This setting turns on Color Coding for the Candles which changes the colors of each candle type:
1. Contraction Candle
2. Expansion Candle
3. Up Candle
4. Down Candle
5. Engulfing Candles (engulfing candles override other candle settings if turned ON)
- Engulfing Patterns Section -
#Show Engulfing Patterns
This setting turns ON or OFF engulfing candle plots globally
#Show Bullish Engulfing Candles
This setting allows the user to turn Bullish Engulfing signals ON or OFF
#Show Bearish Engulfing Candles
This setting allows the user to turn Bearish Engulfing signals ON or OFF
I hope you enjoy this indicator and that it provides some value. Please reach out to me with any suggestions or need training on the indicator.
Real Price Line + Dots (for Heikin Ashi)Real Price Line + Dots (for Heikin Ashi)
This indicator is designed for use on Heikin Ashi charts. Its purpose is to enable traders to benefit from price averaging and smoothing effects of Heikin Ashi candles whilst also enabling them to see the current real price line, and optionally, real price close dots on the Heikin Ashi candlesticks.
Features include:
- Optional real price line
- Optional real price close dots
- Customisable colours
- Customisable line style
- Customisable line width
What are Heikin Ashi candles?
Heikin Ashi means 'average bar' in Japanese, Heikin Ashi charts do not show real price as standard, due to the way the Open, High, Low and Close values are calculated using averages, This is done in order to create a smoother appearance and reduce the market 'noise'.
You can read more about Heikin Ashi candlesticks here.
NOTE:
- If real price dots appear behind the candles, you may need to select the triple dot menu on the indicator then select "Visual order" > "Bring to front" , so that the dots are shown above the candles.
- When using this indicator on a Heikin Ashi chart, the standard Tradingview price line will not show accurate real price. Therefore when using the price line in this indicator, the standard price line should be disabled within the Tradingview 'Chart settings' dialog > 'Symbol' tab > uncheck 'Last', under the 'Price line' section.
Wicked Good S&R Zones// Hello tradeurs, ChasinAlts here with a script you've DEFINITELY never seen before. Hope everyone is well. Ok, so heres the low-down...When a wick's
// % size is above the threshold set by the user it is plotted with light blue (these aren't really the significant ones) and are put into an array.
// These large wick lines are great S&R lines but we're looking to filter out to only the best ones. So, after all the large wicks are recorded for the
// chart and lines drawn, it then calculates the area between each of these lines in % (you can think of the lines as the upper and lower lines to a box
// if you'd like...ie. it is one of the ways to view the final BEST S&R lines). What we are want is the largest of ALL the % areas between lines and to
// use these as our ultimate S&R Areas. Depending on the Min % Wick size that is chosen, you will find price usually either bouncing between these levels or
// that price will keep bouncing off of the same level until a large spike (up or down) occurs in price and the price will finally breach the level its been
// testing over and over. Once this DOES occur the level that was just broken many times will be the furthest point back for the retest. Now, as stated
// before there are 2 ways to view the output data. Either way it will show the largest % area between the lines as it is developing down the line of
// progressing bars on the chart (that means it WILL change but usually a portion of the previous area/box will be used for the newer smaller box or that
// the area/box will jump back and forth between the same few areas every now and again). Viewing it as a box will show the updated largest box
// (as stated twice now) but viewing it in it's S&R Line form will draw a new S&R line at the top and bottom of where the box would be if it was selected
// EXCEPT that these lines will persist across bars and you will continuously see how these levels will continue to be revisited and constantly used
// as S&R Lines as time progresses. (SO box only show the largest area and lines draws line at the top and bottom of box and persists across bars).
// There is not repainting that can occur. I hope you all enjoy this as I've found it EXTREMELY beneficial bc it's rare that when price first gets to a
// printed S&R level that it will shoot through it so you can depend on it bouncing off the the levels often multiple times. I've included comments in all
// of the code for your convenience. Also, the higher subscription plan you have (thus the more bars/data you have access to...the more S&R Lines will be drawn).
// Wish you all the best in your endeavors and may the force be with your trades, and as ALWAYS...Peace and Love people....Peace and Love. -ChasinAlts out.
Moving Average - fade when crossed [cajole]This indicator simply provides a moving average (SMA, EMA, etc. can be selected) which hides itself when touched by the price.
Two potential uses:
Set the growth rate to be slow, to highlight only very rapid moves on a chart.
Use the default settings and change the averaging period until the MA line remains bright. This MA can then act as a good trailing stop for the specific security.
TradingView does not remember indicator settings for specific charts. Consider adding a text label to your chart after you identify the ideal trailing stop. Similar trailing-stop methods are recommended by Kristjan Qullamagie is identical to Jesse Stine's "magic line" concept .
Educational: lines, linefill, labels & boxesThis educational script contains different examples regarding lines , linefill , labels & boxes
First part shows the use of array.new() without first
retrieving line.new() which then are put in a linefill.new()
At every start of the week a linefill.new() is added with the top line being
previous Weekly high , and the bottom line being previous Weekly low ,
if close doesn't go above top line, or below bottom line, both lines will be made longer
with 1 bar_index ( line.set_x2 ), otherwise the lines stop, and change color
Please read the comments in the script as well
Cheers!
intersectLibrary "intersect"
Find Line Intersection X/Y coordinates.
Simple to use, will find intersection if it exists on the segments
if the line segments do not cross on segment, an 'na' value will be returned
if you plot new items with the output coords, they still plot.
avoid this by setting a na(x) condition before plotting new items
get(l1, l2, ( optional _round) )
line intersection coordinates
Parameters:
l1 : (line) first line
l2 : (line) second line
_round : True to make an INT for plotting
if not used, will not round ( overload loophole)
Returns: with x as int if bool is used
[FFriZz]Priceline/TicksFFriZz | FrizLabz -- Priceline/Ticks
Due to TradingView not allowing us to change the size or style of the Priceline I decided to make this
You can change the style, size, color of the Price line with this Script
There is also an option for the closing price to be plotted on the Priceline
-- Colors --
You can have the Line and/or the Closing price change colors with the price movements
both are adjustable to your preference
-- Ticks --
Will show the difference in price from tick to tick
when Volume moves but price doesn't it will show '▲▼'
-- Adjustments --
The offset of the Close and Ticks can be adjusted from left to right
Can Extend Priceline in all directions
Can change the Line style and Width
Can change all the Text sizes and Colors
Can also Change Colors to change with Price movements
Can Change number of Ticks to show
-- Priceline --
You don't have to but I suggest going to the settings of your Chart and turning off the Priceline
-- Challenge --
There is Some code at the bottom that will move the Label and Ticks to the x% of your screen in from the right once
the last bar is no longer visible. I decided not to use it because even when the feature is turned off any movement of the
chart resets the Ticks. If you find out a way to have it not reset the Ticks Let me know!
If you find any bugs or have any suggestions feel free to DM me or leave a comment!
Hope you Enjoy! -- FFriZz | FrizLabz
AlgebraLibrary "Algebra"
Algebra functions.
line_fromXy(x1, y1, x2, y2)
Get line slope and y-intercept from coordinates
Parameters:
x1 : x coordinate 1 (int - bar index)
y1 : y coordinate 1 (float - price/value)
x2 : x coordinate 2 (int - bar index)
y2 : y coordinate 2 (float - price/value)
Returns: of line
line_getPrice(x, slope, yInt)
Get line slope and y-intercept from coordinates
Parameters:
x : x coordinate to solve for y (int - bar index)
slope : slope of line (float)
yInt : y-intercept of line (float)
Returns: y (price/value)
Line Chart with circles on sub chart / LineChart no CandlesLine Chart with circles as a subchart. The circle will appear only after the candle has been confirmed.
Things you can change:
- Source: open, high, low, close, hl2, hlc3, ohlc4, hlcc4
- Color: change the color of the line and the circles
have fun with it!
BoxLine_LibLibrary "BoxLine_Lib"
personal Library for line and box built in functions
lineXY(x)
get x1,y1,x2,y2 in a tuple
Parameters:
x : TODO: line
Returns: tuple of x1,y1,x2,y2
line(x)
Create line with only the y1 value(when line == na) or all
when line != na set x1,y1,x2,y2 individually just 1 or all
- use just the line value to set the x2 to current bar or time will set to time
- will auto pick xloc.bar_index or xloc.bar_time if not used
Parameters:
x : (line line,int x1,float y1,int x2,float y2,
string xloc,string extend,color color,string style,int width)
Returns: Line
boxXY(x)
get left,top,right,bottom in a tuple
Parameters:
x : box
Returns: tuple of left,top,right,bottom
box(x)
Create line with only the top,bottom value(when line == na) or all
when box != na set left,top,right,bottom individually just 1 or all
- use just the box value to set the right to current bar or time will set to time
- if right is above a number that a bar_index wouldnt be
Parameters:
x : box box,int left,float top,int right,
float bottom,color border_color, int border_width,
string border_style,string extend,string xloc,
color bgcolor,string text,string text_size, color text_color,
string text_halign,string text_valign,string text_wrap)
Returns: TODO: Box