Find time of highest and lowest candles

Amin

I want to draw a box from the highest candle to the lowest in the last 20 candles. Each box has 4 side: top, bottom, left and right. for top and bottom i use highest() and lowest() but for left and right how can i find time for highest and lowest candle?

Rohit Agarwal

You can find the high using highest and low using lowest function. Then you can find the index of them using barssince function. Then you can use them to plot a box at the last bar using barstate.islast. Example below

//@version=5
indicator(title="Highest Lowest Bar", shorttitle="HLB", overlay=true)

hi=ta.highest(high,20)
lo=ta.lowest(low,20)
hiIndex=ta.barssince(high==hi)
loIndex=ta.barssince(low==lo)
var box b=na
if barstate.islast
    box.delete(b)
    b:=box.new(bar_index-hiIndex,hi,bar_index-loIndex,lo,bgcolor=color.new(color.blue,80),border_color=na)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Find the highest and lowest value for a time frame

FIND THE HIGHEST AND LOWEST SALARY

Find the lowest and highest NUMBERS in a collection

Find time difference between highest and lowest value in data frame and sort by factor

Find the lowest / highest key of a distributed map

How to find the highest and lowest number with JS?

Find highest and lowest number from the string of numbers

How to find the highest and lowest product price

LINQ - find between lowest and highest string

find the highest and lowest number in array with JOptionPane

How to find highest and lowest value on substrings?

Find Nth highest/lowest values in Pine

Find the highest and lowest value locations within an interval on a column?

How to find the lowest and highest date based on certain value in another column?

Using loops to find the highest score, lowest score from a list

How to find highest and lowest value and aggregate into a string in Pandas, Pysimplegui

Find 10% highest and lowest values, trim all columns in R

Find out day with highest sales and lowest sales in PHP and MySQL

Find the differrence between employees' salaries and sort by highest to lowest

Find Lowest, Highest, Median and Average Score using findKth

How to I find lowest and highest value of this array (java)

How can I find highest and lowest in an array of objects/ Javascript

Oracle SQL: Find job ID of the job for which the difference between the highest salary and the lowest is the highest one

What is the lowest and highest number of

Pinescript Highest / Lowest Comparision

Highest / Lowest pl/sql

problems with highest and lowest in an array

Sort highest to lowest in a file

How to display an individual with highest number of posts and an individual with lowest number of posts at the same time in SQL Server?