Bottom Line: A zero line with changing colors based on the dominance of heat or cold power.
Weather Symbols: Visual indicators ("β" for hot weather and "β" for cold weather) appear on the chart when the heat and cold powers crossover, helping traders quickly identify trend changes.
The `Show Weather?` function enhances the VST indicator by displaying weather symbols ("β" for hot and "β" for cold) when there are significant crossovers between heat power and cold power. This feature adds a visual cue for potential market tops and bottoms. When the market heats to a high temperature, it often indicates a potential top, signaling traders to consider exiting long positions or preparing for a reversal.
// This Pine Scriptβ’ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© ChartPrime
//@version=5
indicator("Volume Storm Trend [ChartPrime]", shorttitle = "Storm Trend [ChartPrime]", overlay = false)
import TradingView/ta/7
// ---------------------------------------------------------------------------------------------------------------------}
// ππππ ππππππ
// ---------------------------------------------------------------------------------------------------------------------{
int len             = input.int(40, "Median Length", 1, group = "β")
int n               = input.int(3, "Volume Length", 1, group = "β")
bool show_whether   = input.bool(false, "Show Weather?", group = "β")
bool show_heat      = input.bool(false, "Show HeatMap?", group = "β")
string c_f          = input.string("Β°c", "Temperature Type's", ["Β°c", "Β°f"])
// Colors
var color colorDn   = #072f64
var color colorUp   = #25b0e7
var color color     = na
// Arrays
var heat            = array.new_float(n, 0)
var cold            = array.new_float(n, 0)
// ---------------------------------------------------------------------------------------------------------------------}
// πππΏππΎπΌπππ πΎπΌππΎπππΌπππππ
// ---------------------------------------------------------------------------------------------------------------------{
max_val = 1000
src     = close
source  = ta.median(src, len)
// Heat and Cold Arrays
heat.push(src > source ? (volume > max_val ? max_val : volume)  : 0)
heat.remove(0)
cold.push(src < source ? (volume > max_val ? max_val : volume) : 0)
cold.remove(0)
heat_power = ta.ema(heat.median(), 10)
cold_power = ta.ema(cold.median(), 10)
// ---------------------------------------------------------------------------------------------------------------------}
// πππππΌππππΌππππ
// ---------------------------------------------------------------------------------------------------------------------{
// Colors
heat_color = show_whether ? 
                 (
                   heat_power > 0   and heat_power < 900 
                 ? color.from_gradient(heat_power, 0, max_val, color(na), colorUp) 
                 : heat_power > 900 and heat_power < 999.9
                 ? color.from_gradient(heat_power, 900, max_val, colorUp, color.yellow) 
                 : heat_power > 999.9
                 ? color.from_gradient(heat_power, 999.9, max_val, color.yellow, #ff7300) 
                 : na
                 ) 
                 : color.from_gradient(heat_power, 0, max_val, color(na), colorUp)
cold_color = show_whether ? color.from_gradient(cold_power, 0, max_val, colorUp, colorDn) 
              : color.from_gradient(cold_power, 0, max_val, color(na), colorDn) 
// Bars Fill Color
p3 = plot(high, color = color(na), force_overlay = true)
p4 = plot(low,  color = color(na), force_overlay = true)
fill(
     plot1 = p3, 
     plot2 = p4, 
     color = show_heat ? (heat_power > cold_power ? heat_color : cold_color) : na
     )
barcolor(show_heat ? color.new(color.white, 100) : na)
// Bottom Line
plot(series = 0, color = heat_power > cold_power ? heat_color : cold_color, linewidth = 5)
// Plot Weather
plotchar(
         series   = show_whether ? (ta.crossover(heat_power, cold_power) ? heat_power[1] : na) : na,
         title    = "Hot Weather", 
         char     = "β", 
         size     = size.small, 
         location = location.absolute, 
         color    = color.orange, 
         offset   = -1
         )
plotchar(
         series   = show_whether ? (ta.crossunder(heat_power, cold_power) ? cold_power[1] : na) : na,
         title    = "Cold Weather", 
         char     = "β", 
         size     = size.small, 
         location = location.absolute, 
         color    = color.aqua, 
         offset   = -1
         )
plotchar(
         series        = show_whether ? (ta.crossover(heat_power, cold_power) ? low[1]*0.95 : na) : na,
         title         = "Hot Weather Chart", 
         char          = "β",
         size          = size.tiny, 
         location      = location.absolute, 
         color         = color.orange, 
         offset        = -1, 
         force_overlay = true
         )
plotchar(
         series        = show_whether ? (ta.crossunder(heat_power, cold_power) ? high[1]*1.05 : na) : na, 
         title         = "Cold Weather Chart",
         char          = "β", 
         size          = size.tiny, 
         location      = location.absolute,
         color         = color.aqua, 
         offset        = -1, 
         force_overlay = true
         )
// Plot Stoβm Trend
p1 = plot(heat_power, color = colorUp, display = display.none)
p2 = plot(cold_power, color = colorDn, display = display.none)
p0 = plot(0, display = display.none)
fill(p0, p1, heat_power, 0, heat_color, color(na))
fill(p0, p2, cold_power, 0, cold_color, color(na))
// Show Temperature
// To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32
FtoC(F)=>
    c = math.round(F > 0 ? (F/1.8-32) : (F/1.8+32), 2)
temp = math.round((heat_power > cold_power ? heat_power : -cold_power)/6.775, 2)
if barstate.islast and show_whether 
    var tabl = table.new(position.middle_right, 10, 10)
    tabl.cell(0, 0, "Temperature:", text_color = chart.fg_color, text_size = size.large)
    temper = c_f == "Β°c" ? str.tostring(FtoC(temp)) + "Β°C" : str.tostring(temp) + "Β°F"
    tabl.cell(0, 1, temper, text_color = heat_power > cold_power ? heat_color : cold_color, text_size = size.large)
// ---------------------------------------------------------------------------------------------------------------------}