"//@version=5 indicator("20.1) Refined Flower tbl", overlay=true, maxbarsback=500) //…
- User
"//@version=5 indicator("20.1) Refined Flower tbl", overlay=true, max_bars_back=500)
// Calculate RSI with different periods rsi9 = ta.rsi(close, 9) rsi14 = ta.rsi(close, 14)
// Calculate WMA, VWMA, and EMA of RSI (9 and 14) wma_rsi21 = ta.wma(rsi9, 21) vwma_rsi21 = ta.vwma(rsi9, 21) ema_rsi3 = ta.ema(rsi9, 3)
wma_rsi48 = ta.wma(rsi14, 48) vwma_rsi48 = ta.vwma(rsi14, 48) ema_rsi5 = ta.ema(rsi14, 5)
// Calculate EMA and RMA of high and low prices ema20_high = ta.ema(high, 20) rma20_low = ta.rma(low, 20)
// Define the conditions Flower = (ta.crossover(rsi9, 30)) and (ema20_high < rma20_low) Fire = (ta.crossover(rsi9, 90))
// Plot flower symbol when condition is met plotshape(series=Flower, location=location.belowbar, color=color.yellow, style=shape.labelup, text="🌸", title="Flower")
// Plot fire symbol when condition is met plotshape(series=Fire, location=location.abovebar, color=color.red, style=shape.labelup, text="🔥", title="Fire")
// Create a table var table flowerTable = table.new(position.top_right, 3, 2, bgcolor=color.white, frame_color=color.black, frame_width=1)
// Function to format date and time getDateTime() => ts = time yr = year(ts) mnth = month(ts) day = dayofmonth(ts) hr = hour(ts) min = minute(ts) str.tostring(day) + "-" + str.tostring(mnth) + "-" + str.tostring(yr) + " " + str.tostring(hr) + ":" + str.tostring(min)
// Variables to store the last "Flower" occurrence data var string lastFlowerTime = na var float lastFlowerPrice = na var int lastFlowerBarIndex = na
// Update the variables when the "Flower" condition is met if (Flower) lastFlowerTime := getDateTime() lastFlowerPrice := close lastFlowerBarIndex := bar_index
// Update the table with the latest "Flower" occurrence if (not na(lastFlowerBarIndex) and bar_index == lastFlowerBarIndex) table.cell(flowerTable, 0, 1, "F", text_color=color.black, text_size=size.small) table.cell(flowerTable, 1, 1, lastFlowerTime, text_color=color.black, text_size=size.small) table.cell(flowerTable, 2, 1, str.tostring(lastFlowerPrice), text_color=color.black, text_size=size.small)
// Add table headers if (bar_index == 0) table.cell(flowerTable, 0, 0, "Event", text_color=color.black, bgcolor=color.gray) table.cell(flowerTable, 1, 0, "Date/Time", text_color=color.black, bgcolor=color.gray) table.cell(flowerTable, 2, 0, "LTP", text_color=color.black, bgcolor=color.gray) "
what does this code do
- Assistant