0% found this document useful (0 votes)
11 views1 page

Bollinger Bands & Stochastic Settings

The document outlines a trading script for a technical analysis tool that implements Bollinger Bands and a Stochastic Oscillator. It includes customizable settings for the Bollinger Bands and Stochastic Oscillator, as well as logic for generating buy and sell signals based on price movements relative to the bands and oscillator thresholds. The script tracks the number of buy and sell signals to limit them to three occurrences.

Uploaded by

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

Bollinger Bands & Stochastic Settings

The document outlines a trading script for a technical analysis tool that implements Bollinger Bands and a Stochastic Oscillator. It includes customizable settings for the Bollinger Bands and Stochastic Oscillator, as well as logic for generating buy and sell signals based on price movements relative to the bands and oscillator thresholds. The script tracks the number of buy and sell signals to limit them to three occurrences.

Uploaded by

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

instrument { name = "Turning point", overlay = true }

input_group {
"Bollinger Bands Settings",
period_bb = input (20, "Period", [Link], 1), -- Period: 20
dev_bb = input (2, "Deviation", [Link], 1), -- Deviation: 2
color_bb_upper = input {default = "#ff0000", type = [Link]}, -- Upper Band color
color_bb_lower = input {default = "#0000ff", type = [Link]} -- Lower Band color
}

input_group {
"Stochastic Oscillator Settings",
k_period = input (14, "Stochastic %K Period", [Link], 1), -- %K: 14
d_period = input (3, "Stochastic %D Period", [Link], 1), -- %D: 3
overbought = input (80, "Overbought Level", [Link], 1), -- Overbought: 80
oversold = input (20, "Oversold Level", [Link], 1) -- Oversold: 20
}

basis = sma(close, period_bb) -- Moving Average (Middle line)


upper_band = basis + dev_bb * stdev(close, period_bb) -- Upper Band
lower_band = basis - dev_bb * stdev(close, period_bb) -- Lower Band

stoch_k = sma(100 * ((close - lowest(low, k_period)) / (highest(high, k_period) - lowest(low,


k_period))), d_period)
stoch_d = sma(stoch_k, d_period)

plot(upper_band, "Upper Bollinger Band", color_bb_upper)


plot(lower_band, "Lower Bollinger Band", color_bb_lower)

buy_signal_count = 0 -- To track buy signals


sell_signal_count = 0 -- To track sell signals

if (close < lower_band and stoch_k < oversold and buy_signal_count < 3) then
plot_shape(1, "Buy Signal", shape_style.triangleup, shape_size.huge, "#00ff00",
shape_location.belowbar, 0)
buy_signal_count = buy_signal_count + 1 -- Increment buy signal count ( = )
elseif (close > lower_band) then
buy_signal_count = 0 -- Reset buy signal count if price moves above lower band ( = )
end

if (close > upper_band and stoch_k > overbought and sell_signal_count < 3) then
plot_shape(1, "Sell Signal", shape_style.triangledown, shape_size.huge, "#ff0000",
shape_location.abovebar, 0)
sell_signal_count = sell_signal_count + 1 -- Increment sell signal count ( = )
elseif (close < upper_band) then
sell_signal_count = 0 -- Reset sell signal count if price moves below upper band ( = )
end

You might also like