Created
July 4, 2023 06:41
-
-
Save Akihiro2030/486c1dde5f2710d77b400629ea015862 to your computer and use it in GitHub Desktop.
Pine Script for Binary Options Strategy with MACD, RCI, RCI3Lines and Bollinger Bands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@version=5 | |
indicator(shorttitle="BO Strategy", title="Binary Options Strategy with MACD, RCI, RCI3Lines and Bollinger Bands", overlay=true) | |
// Inputs | |
src = close | |
length = 20 | |
mult = 2.0 | |
// Bollinger Bands | |
basis = ta.sma(src, length) | |
dev = mult * ta.stdev(src, length) | |
upperBB2 = basis + dev * 2 | |
lowerBB2 = basis - dev * 2 | |
upperBB3 = basis + dev * 3 | |
lowerBB3 = basis - dev * 3 | |
// MACD | |
fast_length = input(title="Fast Length", defval=12) | |
slow_length = input(title="Slow Length", defval=26) | |
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) | |
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) | |
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) | |
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) | |
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) | |
macdLine = fast_ma - slow_ma | |
signalLine = sma_signal == "SMA" ? ta.sma(macdLine, signal_length) : ta.ema(macdLine, signal_length) | |
// RCI | |
rci = ta.rci(src, 9) | |
// Buy (Call) condition | |
buyCondition = ta.crossover(macdLine, signalLine) and rci > -80 and (close > lowerBB2 or close > lowerBB3) | |
// Sell (Put) condition | |
sellCondition = ta.crossunder(macdLine, signalLine) and rci < 80 and (close < upperBB2 or close < upperBB3) | |
// Plotting | |
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy") | |
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell") | |
// Alerts | |
alertcondition(buyCondition, title='Buy Signal', message='Buy Signal detected!') | |
alertcondition(sellCondition, title='Sell Signal', message='Sell Signal detected!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment