// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SiberCoderSRZ Webhookbot.net


//This indicator has been reconfigured for automatic trading.
//All you have to do is write the url you got from the webhookbot.net site in the webhookurl section while setting up the alarm.


//@version=5
indicator("Supertrend Auto Buy/Sell Binance [Webhookbot]", overlay=true, timeframe="", timeframe_gaps=true)


// - TRADING AMOUNT AND STOP LOSS SETTINGS IN THE INDIKATOR SETTINGS - //
balance = 0.0
balance := input.float(98, 'Get how much (%) of your balance', step=0.1, minval=0.0, group="Set Balance")
plotshape(balance, display=display.none)  //{{plot_0}}

balancestatic = 0.0
balancestatic := input.float(0, 'Or how many USDT to buy (you will use above, type 0 here)', step=0.1, minval=0.0, group="Set Balance")
plotshape(balancestatic, display=display.none)  //{{plot_1}}

sl = 0.0
sl := input.float(7.5, 'Stop Loss (%) SL', step=0.1, minval=0.0, group="Stop Loss Settings")
plotshape(sl, display=display.none)  //{{plot_2}}

// - TRADING AMOUNT AND STOP LOSS SETTINGS IN THE INDIKATOR SETTINGS - //



float factor = input.float(3)
int pd = input.int(7, minval=1, maxval=100)
float up = hl2 - factor * ta.atr(pd)
dn = hl2 + factor * ta.atr(pd)
float trendup = 0.0
trendup := close[1] > trendup[1] ? math.max(up, trendup[1]) : up
float trenddown = 0.0
trenddown := close[1] < trenddown[1] ? math.min(dn, trenddown[1]) : dn
float trend = 0.0
trend := close > trenddown[1] ? 1 : close < trendup[1] ? -1 : nz(trend[1], 1)
float tsl = trend == 1 ? trendup : trenddown
color linecolor = trend == 1 ? color.green : color.red


plot(tsl, color=linecolor, style=plot.style_line, linewidth=2, title='supertrend')
plotshape(ta.cross(close, tsl) and close > tsl, 'up arrow', shape.triangleup, location.belowbar, color.new(color.green, 0), 0)
plotshape(ta.cross(tsl, close) and close < tsl, 'down arrow', shape.triangledown, location.abovebar, color.new(color.red, 0), 0)
plotarrow(trend == 1 and trend[1] == -1 ? trend : na, title='up entry arrow', colorup=color.new(color.lime, 0), maxheight=60, minheight=50)
plotarrow(trend == -1 and trend[1] == 1 ? trend : na, title='down entry arrow', colordown=color.new(color.red, 0), maxheight=60, minheight=50)


alertcondition(ta.cross(close, tsl) and close > tsl, title='supertrend long', message='supertrend: long ')
alertcondition(ta.cross(tsl, close) and close < tsl, title='supertrend short', message='supertrend: short ')

LONG = trend == 1 and trend[1] == -1
SHORT = trend == -1 and trend[1] == 1


plotshape(LONG, style=shape.labelup, location=location.belowbar, color=color.blue, size=size.tiny, title="Al/Buy/Long", text="BUY", textcolor=color.white)
plotshape(SHORT, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, title="Sat/Sell/Short", text="SELL", textcolor=color.white)


// - CODES FOR AUTOMATIC BUYING AND SELLING IN WHEN THE ALARM RUN - //
alertcondition(LONG, title='BUY', message='webhookbot=cancelorder symbol={{ticker}} | webhookbot=buy symbol={{ticker}} amount={{plot_0}}% amount_price={{plot_1}} | webhookbot=stoploss type=MARKET symbol={{ticker}} size=-{{plot_2}}%')
alertcondition(SHORT, title='SELL', message='webhookbot=cancelorder symbol={{ticker}} | webhookbot=sell symbol={{ticker}} amount=100%')
// - CODES FOR AUTOMATIC BUYING AND SELLING IN WHEN THE ALARM RUN - //




				
			
            // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SiberCoderSRZ Webhookbot.net


//This indicator has been reconfigured for automatic trading.
//All you have to do is write the url you got from the webhookbot.net site in the webhookurl section while setting up the alarm.


//@version=5
indicator("Supertrend Auto Buy/Sell Binance [Webhookbot]", overlay=true, timeframe="", timeframe_gaps=true)


// - TRADING AMOUNT AND STOP LOSS SETTINGS IN THE INDIKATOR SETTINGS - //
balance = 0.0
balance := input.float(98, 'Get how much (%) of your balance', step=0.1, minval=0.0, group="Set Balance")
plotshape(balance, display=display.none)  //{{plot_0}}

balancestatic = 0.0
balancestatic := input.float(0, 'Or how many USDT to buy (you will use above, type 0 here)', step=0.1, minval=0.0, group="Set Balance")
plotshape(balancestatic, display=display.none)  //{{plot_1}}

sl = 0.0
sl := input.float(7.5, 'Stop Loss (%) SL', step=0.1, minval=0.0, group="Stop Loss Settings")
plotshape(sl, display=display.none)  //{{plot_2}}

// - TRADING AMOUNT AND STOP LOSS SETTINGS IN THE INDIKATOR SETTINGS - //



float factor = input.float(3)
int pd = input.int(7, minval=1, maxval=100)
float up = hl2 - factor * ta.atr(pd)
dn = hl2 + factor * ta.atr(pd)
float trendup = 0.0
trendup := close[1] > trendup[1] ? math.max(up, trendup[1]) : up
float trenddown = 0.0
trenddown := close[1] < trenddown[1] ? math.min(dn, trenddown[1]) : dn
float trend = 0.0
trend := close > trenddown[1] ? 1 : close < trendup[1] ? -1 : nz(trend[1], 1)
float tsl = trend == 1 ? trendup : trenddown
color linecolor = trend == 1 ? color.green : color.red


plot(tsl, color=linecolor, style=plot.style_line, linewidth=2, title='supertrend')
plotshape(ta.cross(close, tsl) and close > tsl, 'up arrow', shape.triangleup, location.belowbar, color.new(color.green, 0), 0)
plotshape(ta.cross(tsl, close) and close < tsl, 'down arrow', shape.triangledown, location.abovebar, color.new(color.red, 0), 0)
plotarrow(trend == 1 and trend[1] == -1 ? trend : na, title='up entry arrow', colorup=color.new(color.lime, 0), maxheight=60, minheight=50)
plotarrow(trend == -1 and trend[1] == 1 ? trend : na, title='down entry arrow', colordown=color.new(color.red, 0), maxheight=60, minheight=50)


alertcondition(ta.cross(close, tsl) and close > tsl, title='supertrend long', message='supertrend: long ')
alertcondition(ta.cross(tsl, close) and close < tsl, title='supertrend short', message='supertrend: short ')

LONG = trend == 1 and trend[1] == -1
SHORT = trend == -1 and trend[1] == 1


plotshape(LONG, style=shape.labelup, location=location.belowbar, color=color.blue, size=size.tiny, title="Al/Buy/Long", text="BUY", textcolor=color.white)
plotshape(SHORT, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, title="Sat/Sell/Short", text="SELL", textcolor=color.white)


// - CODES FOR AUTOMATIC BUYING AND SELLING IN WHEN THE ALARM RUN - //
alertcondition(LONG, title='BUY', message='webhookbot=cancelorder symbol={{ticker}} | webhookbot=buy symbol={{ticker}} amount={{plot_0}}% amount_price={{plot_1}} | webhookbot=stoploss type=MARKET symbol={{ticker}} size=-{{plot_2}}%')
alertcondition(SHORT, title='SELL', message='webhookbot=cancelorder symbol={{ticker}} | webhookbot=sell symbol={{ticker}} amount=100%')
// - CODES FOR AUTOMATIC BUYING AND SELLING IN WHEN THE ALARM RUN - //