The day’s opening number is 48786.
To reduce this to a single digit, add all the digits together:
4 + 8 + 7 + 8 + 6 = 33
3 + 3 = 6
So, I want to mark the 6th candle in intraday 5 min time frame. This can be labeled on top of the candle, or the high and low of the 6th candle can be marked with a horizonal ray – line.
logic is if high is broken of 6th number candle i will go long and low broken i will go short
I have tried doing convert number till single digit, but unable to plot lable and horizontal ray
// Function to round off a number
round_off(num) =>
math.round(num)
// Function to sum the digits of a number
sum_digits(num) =>
sum = 0
temp_num = num
while temp_num > 0
sum := sum + (temp_num % 10)
temp_num := math.floor(temp_num / 10)
sum
// Function to reduce to a single digit
reduce_to_single_digit(num) =>
temp = num
while temp >= 10
temp := sum_digits(temp)
temp
// Get the opening price of the day
day_open = request.security(syminfo.tickerid, "D", open)
// Round off the opening price
rounded_open = math.floor(day_open)
// Reduce the rounded opening price to a single digit
single_digit_sum = reduce_to_single_digit(rounded_open)
// Plot the result as a label on the chart
onedigit= label.new( x =start915, y = Upper_ProfitBooking_Level, text = str.tostring(rounded_open)+"=" + str.tostring(single_digit_sum)+"", style = label.style_label_down, color = color.blue, textcolor = color.white,xloc=xloc.bar_time)
label.delete(onedigit[1])
K Karan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.