[go: up one dir, main page]

0% found this document useful (0 votes)
139 views5 pages

Pine Script For SL and Target

The document provides a Pine Script that compares the current candle's closing price to the highest price of previous candles of the current day, excluding the current candle's high. If the closing price exceeds this highest price, a green label with an up arrow is created at the top of the current candle, displaying the closing price, the lowest price of the second last candle, and the difference between the closing price and the second last candle's low. The script includes various iterations and improvements for clarity and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views5 pages

Pine Script For SL and Target

The document provides a Pine Script that compares the current candle's closing price to the highest price of previous candles of the current day, excluding the current candle's high. If the closing price exceeds this highest price, a green label with an up arrow is created at the top of the current candle, displaying the closing price, the lowest price of the second last candle, and the difference between the closing price and the second last candle's low. The script includes various iterations and improvements for clarity and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

write a pine script that compares the current candle's closing price to the

highest price of the previous candles of current day ( other than the highest
price of current candle) . When the closing price of the current candle is greater
than the highest price of the previous candles of current day ( other than the
highest price of current candle), a label is created at the top of the current
candle . The label uses an up arrow (↑) and is colored green to visually highlight
the condition.
Also display the lowest price of the second last candle to the candle on which the
label is formed,
also display the closing price of the current candle on the label, also display
difference of (closing price of the current candle) minus (lowest price of the
second last candle to the candle on which the label is formed)

Complete Script with all custom features is this on the top >

//@version=5
indicator("Close Above Previous Highest Price with Additional Info", overlay=true)

// Variable to store the highest price of previous candles in the current day
(excluding current candle)
var float highestPricePrev = na

// Calculate the highest price of the previous candles of the current day
(excluding current candle)
if (dayofweek != dayofweek[1]) // Check for a new day
highestPricePrev := na // Reset on a new day

// Update the highest price from previous candles (not including current candle's
high)
if (dayofweek == dayofweek[1]) // Current day
highestPricePrev := na(highestPricePrev) ? high[1] : math.max(highestPricePrev,
high[1])

// Calculate the lowest price of the second last candle


secondLastLow = low[1]

// Compare the close with the highest price of the previous candles
if close > highestPricePrev
// Calculate the difference between the current closing price and the second
last low
priceDifference = close - secondLastLow
target1 = close + priceDifference
target2 = close + priceDifference + priceDifference
target3 = close + priceDifference + priceDifference + priceDifference
target4 = close + priceDifference + priceDifference + priceDifference +
priceDifference
target5 = close + priceDifference + priceDifference + priceDifference +
priceDifference + priceDifference

// Create label text with the closing price, second last low, and the
difference
//labelText = "↑ Close: " + str.tostring(close) + "\nSL: " +
str.tostring(secondLastLow) + "\nTarget 1: " + str.tostring(target1)
labelText = "SL: " + str.tostring(secondLastLow) + "\nTarget 1: " +
str.tostring(target1) + "\nTarget 2: " + str.tostring(target2)+ "\nTarget 3: " +
str.tostring(target3)+ "\nTarget 4: " + str.tostring(target4)

// Create the label at the top of the current candle with the specified text
label.new(bar_index, low - 3, labelText, color=#83b784,
style=label.style_label_upper_left, size=size.normal, textcolor=color.white)

===================================================================================
===========
other concept base other scripts are below
===================================================================================
===========

//@version=5
indicator("Close Above Previous Highest Price with Additional Info", overlay=true)

// Variable to store the highest price of previous candles in the current day
(excluding current candle)
var float highestPricePrev = na

// Calculate the highest price of the previous candles of the current day
(excluding current candle)
if (dayofweek != dayofweek[1]) // Check for a new day
highestPricePrev := na // Reset on a new day

// Update the highest price from previous candles (not including current candle's
high)
if (dayofweek == dayofweek[1]) // Current day
highestPricePrev := na(highestPricePrev) ? high[1] : math.max(highestPricePrev,
high[1])

// Calculate the lowest price of the second last candle


secondLastLow = low[2]

// Compare the close with the highest price of the previous candles
if close > highestPricePrev
// Create a label with an up arrow (↑) at the top of the current candle
labelText = "↑ Close: " + str.tostring(close) + "\n2nd Last Low: " +
str.tostring(secondLastLow)
label.new(bar_index, high, labelText, color=color.green,
style=label.style_label_up, size=size.normal, textcolor=color.white)

===========================================================================

write a pine script that compares the current candle's closing price to the
highest price of the previous candles of current day ( other than the highest
price of current candle) . When the closing price of the current candle is greater
than the highest price of the previous candles of current day ( other than the
highest price of current candle), a label is created at the top of the current
candle . The label uses an up arrow (↑) and is colored green to visually highlight
the condition.
Also display the lowest price of the second last candle to the candle on which the
label is formed

//@version=5
indicator("Close Above Previous Highest Price with Lowest Price", overlay=true)

// Variable to store the highest price of previous candles in the current day
(excluding current candle)
var float highestPricePrev = na

// Calculate the highest price of the previous candles of the current day
(excluding current candle)
if (dayofweek != dayofweek[1]) // Check for a new day
highestPricePrev := na // Reset on a new day

// Update the highest price from previous candles (not including current candle's
high)
if (dayofweek == dayofweek[1]) // Current day
highestPricePrev := na(highestPricePrev) ? high[1] : math.max(highestPricePrev,
high[1])

// Calculate the lowest price of the second last candle


secondLastLow = low[1]

// Compare the close with the highest price of the previous candles
if close > highestPricePrev
// Create a label with an up arrow (↑) at the top of the current candle
label.new(bar_index, high, "↑", color=color.green, style=label.style_label_up,
size=size.normal, textcolor=color.white)

// Display the lowest price of the second last candle near the candle with the
label
label.new(bar_index, low, "2nd Last Low: " + str.tostring(secondLastLow),
color=color.blue, style=label.style_label_left, size=size.normal,
textcolor=color.white)

-------
latest till now 14:39
//@version=5
indicator("Close Above Previous Highest Price with Lowest Price", overlay=true)

// Variable to store the highest price of previous candles in the current day
(excluding current candle)
var float highestPricePrev = na

// Calculate the highest price of the previous candles of the current day
(excluding current candle)
if (dayofweek != dayofweek[1]) // Check for a new day
highestPricePrev := na // Reset on a new day

// Update the highest price from previous candles (not including current candle's
high)
if (dayofweek == dayofweek[1]) // Current day
highestPricePrev := na(highestPricePrev) ? high[1] : math.max(highestPricePrev,
high[1])
// Calculate the lowest price of the second last candle
secondLastLow = low[1]

// Compare the close with the highest price of the previous candles
if close > highestPricePrev
// Create a label with an up arrow (↑) at the top of the current candle
label.new(bar_index, low - 2, "SL: " + str.tostring(secondLastLow),
color=#8dc0ba, style=label.style_label_upper_left, size=size.normal,
textcolor=#000000)

// Display the lowest price of the second last candle near the candle with the
label
//label.new(bar_index, low, "2nd Last Low: " + str.tostring(secondLastLow),
color=color.blue, style=label.style_label_left, size=size.normal,
textcolor=color.white)

========================

// this script is good and works fine //

write a pine script that compares the current candle's closing price to the
highest price of the previous candles of current day ( other than the highest
price of current candle) . When the closing price of the current candle is greater
than the highest price of the previous candles of current day ( other than the
highest price of current candle), a label is created at the top of the current
candle . The label uses an up arrow (↑) and is colored green to visually highlight
the condition.

//@version=5
indicator("Close Above Previous Highest Price", overlay=true)

// Variable to store the highest price of previous candles in the current day
var float highestPricePrev = na

// Calculate the highest price of the previous candles of the current day (not
including the current candle)
if (dayofweek != dayofweek[1]) // Check for a new day
highestPricePrev := na // Reset on a new day

// Update the highest price from previous candles (not including current candle's
high)
if (dayofweek == dayofweek[1]) // Current day
highestPricePrev := na(highestPricePrev) ? high[1] : math.max(highestPricePrev,
high[1])

// Compare the close with the highest price of the previous candles
if close > highestPricePrev
label.new(bar_index, high + 10, "↑", color=color.rgb(129, 208, 132),
style=label.style_label_down, size=size.normal, textcolor=color.white)

=========================================================
// for last 10 candle comparison //

to create a arrow on top of a candle if the closing price of candle is more than
the the highest price among previous 10 candle on a 1 minute candles

write a pine script to create a arrow on top of a candle if the closing price of
candle is more than the the highest price among previous 10 candle on a 1 minute
candles

ta.highest(high[1], 10): The ta.highest() function calculates the highest high from
the previous 10 candles (excluding the current candle). The [1] in high[1] ensures
that we look at the highs of the previous candles, not including the current
candle.

Condition: The script compares the current candle's closing price (close) to the
highest price (highestPrice) from the previous 10 candles.

Label Creation: When the closing price is greater than the highest price of the
last 10 candles, a label is created at the top of the current candle (high). The
label uses an up arrow (↑) and is colored green to visually highlight the
condition.

label.new: This function creates the label on the chart at the current bar_index
and positions it at the high of the candle. The label style and size are
adjustable.

//@version=5
indicator("Arrow on Close > Highest of Previous 10 Candles", overlay=true)

// Calculate the highest price among the previous 10 candles


highestPrice = ta.highest(high[1], 300)

// Compare the close price to the highest price of the last 10 candles
if close > highestPrice
label.new(bar_index, high + 10, "↑", style=label.style_label_down,
color=color.green, size=size.small)

You might also like