Buying climax and Selling climax
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Shauryam_or
//@YaheeSweety is writer of Boring and Explosive Candles -
//@version=5
//Modified on 20180913
//Defining Title and Name of Pine Script
indicator('buying climax and selling climax', overlay=true)

rsi = ta.rsi(close, 14)

//-------------------------------------------------------------
// Script for Explosive Candles  
//          Part 1: taking user input  
//          Part 2: Defining Variable and performing calculation 
//          Part 3: giving BLUE color to candle based on calculation
mp = input(2.0, title='Multiplier for Explo.Mov.')
ratio = input(50, title='Range-Body Ratio for Explo.Mov.')
cand = input(100, title='Average Number of Candles for Explo.Mov.')

range_1 = ta.atr(cand)
candr = math.abs(high - low)
bodyr = math.abs(open - close)

prev = math.abs(high[1] - low[1])
nextabs = math.abs(high - low)
explose = bodyr / candr >= ratio / 100 and candr >= range_1 * mp and volume > 2 * volume[3] and nextabs > 2 * prev
barcolor(explose ? color.black : na, title='Explosive Move')

var line l1 = na
var line l2 = na

price1 = high
price2 = low
dS1 = true

if explose
    l1 := line.new(bar_index[1], price1, bar_index, price1, color=color.red, style=line.style_solid, width=1, extend=dS1 ? extend.right : extend.both)
    l2 := line.new(bar_index[1], price2, bar_index, price2, color=color.green, style=line.style_solid, width=1, extend=dS1 ? extend.right : extend.both)
    line.delete(l1[1])
    line.delete(l2[1])

alertcondition(explose, "Climax bar",  "New Climax Found")
