0% found this document useful (0 votes)
145 views2 pages

GBS

This Pine Script™ code implements a trading indicator called 'Gain Buy Sell' that utilizes Bollinger Bands and Average True Range (ATR) for generating buy and sell signals. The script includes customizable settings for ATR period, Bollinger Bands period, and deviation, as well as options to enable or disable the ATR filter. It also features alerts for buy and sell conditions and displays a dashboard with a Telegram link for users to join a community.

Uploaded by

tiresdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views2 pages

GBS

This Pine Script™ code implements a trading indicator called 'Gain Buy Sell' that utilizes Bollinger Bands and Average True Range (ATR) for generating buy and sell signals. The script includes customizable settings for ATR period, Bollinger Bands period, and deviation, as well as options to enable or disable the ATR filter. It also features alerts for buy and sell conditions and displays a dashboard with a Telegram link for users to join a community.

Uploaded by

tiresdev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.

0
at https://mozilla.org/MPL/2.0/
// Join us https://t.me/simpleforextools

//@version=5
indicator(shorttitle='GBS', title='Gain Buy Sell', overlay=true)

// --- settings
ATRperiod = input.int(defval=5, title='ATR Period', minval=1)
BBperiod = input.int(defval=21, title='Bollinger Bands Period', minval=1)
BBdeviation = input.float(defval=1.00, title='Bollinger Bands Deviation',
minval=0.1, step=0.1)
UseATRfilter = input(defval=true, title='ATR Filter On/Off')
showsignals = input(title='Show Signals ', defval=true)
// --- end of settings

// Bollinger Bands calculation


BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation
BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation

// ATR calculation
atrValue = ta.atr(ATRperiod)

// Signal initialization
var float EliteSignal = na
var int BBSignal = 0

// Determine BB signal
if (close > BBUpper)
BBSignal := 1
else if (close < BBLower)
BBSignal := -1

// Buy signal logic


if (BBSignal == 1)
if (UseATRfilter)
EliteSignal := low - atrValue
else
EliteSignal := low
if (EliteSignal < nz(EliteSignal[1]))
EliteSignal := nz(EliteSignal[1])

// Sell signal logic


if (BBSignal == -1)
if (UseATRfilter)
EliteSignal := high + atrValue
else
EliteSignal := high
if (EliteSignal > nz(EliteSignal[1]))
EliteSignal := nz(EliteSignal[1])

// Trend direction determination


var int iTrend = 0
if (nz(EliteSignal) > nz(EliteSignal[1]))
iTrend := 1
else if (nz(EliteSignal) < nz(EliteSignal[1]))
iTrend := -1

// Trend line color based on trend direction


lineColor = iTrend > 0 ? #ebfc02 : #f70000

// Define three lines with reduced gap (0.5x ATR)


gapSize = atrValue * 0.5
EliteSignalUpper = EliteSignal + gapSize
EliteSignalLower = EliteSignal - gapSize

// Buy & sell conditions


buy = 0.0
sell = 0.0
buy := iTrend[1] == -1 and iTrend == 1 ? 1 : na
sell := iTrend[1] == 1 and iTrend == -1 ? 1 : na

// Alerts
alertcondition(sell == 1, title="Sell", message="Gain Buy Sell Sell")
alertcondition(buy == 1, title="Buy", message="Gain Buy Sell Buy")
alertcondition(buy == 1 or sell == 1, title="Signal", message="Gain Buy Sell
Signal")

// Plot the three trend lines with same width and reduced gap
plot(EliteSignal, color=lineColor, linewidth=3, title="Gain Buy Sell Main")
plot(EliteSignalUpper, color=lineColor, linewidth=3, title="Gain Buy Sell Upper")
plot(EliteSignalLower, color=lineColor, linewidth=3, title="Gain Buy Sell Lower")
plotshape(buy == 1 and showsignals ? EliteSignal - atrValue : na, text='BUY',
style=shape.labelup, location=location.absolute, color=#ebfc02, textcolor=#050202,
offset=0, transp=0, size=size.normal)
plotshape(sell == 1 and showsignals ? EliteSignal + atrValue : na, text='SELL',
style=shape.labeldown, location=location.absolute, color=#f70000,
textcolor=#050202, offset=0, transp=0, size=size.normal)

//
===================================================================================
=======

// === Dashboard with Telegram Link ===


var table myTable = table.new(position.top_center, 1, 1, border_width=1,
frame_color=color.black, bgcolor=color.white)

// Add Telegram Message to Dashboard


table.cell(myTable, 0, 0, "Join Telegram @simpleforextools", bgcolor=color.blue,
text_color=color.white, text_size=size.normal)

You might also like