Big Snapper Alerts rs2021
Big Snapper Alerts rs2021
//
//
// Author: JustUncleL
// Date: 19-Oct-2017
// Version: R3.0
//
// Description:
// This is a diversified Binary Option or Scalping Alert indicator originally
designed for
// lower Time Frame Trend or Swing trading. Although you will find it a useful
tool for
// higher time frames as well.
//
// The Alerts are generated by the changing direction of the ColouredMA (HullMA
by default,
// also SSMA works well) or optionally by fastMA crossing ColouredMA. Then you
have the choice of
// selecting the Directional filtering on these signals or a Bollinger Outside
IN swing
// reversal filter.
//
// The filters include:
//
// Type 1 - The three MAs (EMAs 21,55,89 by default) in various combinations
or by themselves.
// When only one directional MA selected then direction filter is
given by ColouredMA
// above(up)/below(down) selected MA.
// If more than one MA selected the direction is given by MAs being
in correct order
// for trend direction.
//
// Type 2 - The SuperTrend direction is used to filter ColouredMA signals.
//
// Type 3 - Bollinger Band Outside In is used to filter ColouredMA for swing
reversals.
//
// Type 4 - No directional filtering, all signals from the ColouredMA are
shown.
//
// Type 5 - Signals given by FastMA (eg length 7) crossing the ColouredMA (eg
length 14),
// suggested FastMA should same type as ColouredMA (eq HullMA or
SSMA) and
// no less than half the length.
//
// Notes: - Each Type can be combined with most other types to form more complex
filtration.
// - Alerts can also be disabled completely if you just want one
indicator with
// one colouredMA and/or 3xMAs and/or Bollinger Bands and/or SuperTrend
//
// === INPUTS ===
//
filterOption = input.string('SuperTrend', title='Signal Filter Option : ',
options=['3xMATrend', 'SuperTrend', 'SuperTrend+3xMA', 'ColouredMA', 'No Alerts',
'MACross', 'MACross+ST', 'MACross+3xMA', 'OutsideIn:MACross',
'OutsideIn:MACross+ST', 'OutsideIn:MACross+3xMA'])
//
hideMALines = input(false)
hideSuperTrend = input(true)
hideBollingerBands = input(true)
hideTrendDirection = input(true)
//
disableFastMAFilter = input(false)
disableMediumMAFilter = input(false)
disableSlowMAFilter = input(false)
//
uKC = false // input(false,title="Use Keltner Channel (KC) instead of Bollinger")
bbLength = input.int(20, minval=2, step=1, title='Bollinge Bands Length')
bbStddev = input.float(2.0, minval=0.5, step=0.1, title='Bollinger Bands StdDevs')
oiLength = input(8, title='Bollinger Outside In LookBack')
//
SFactor = input.float(3.618, minval=1.0, title='SuperTrend Factor')
SPd = input.int(5, minval=1, title='SuperTrend Length')
//
buyColour_ = input.string('Green', title='BUY Marker Colour: ', options=['Green',
'Lime', 'Aqua', 'DodgerBlue', 'Gray', 'Yellow'])
sellColour_ = input.string('Maroon', title='SELL Marker Colour: ',
options=['Maroon', 'Red', 'Fuchsia', 'Blue', 'Black', 'Orange'])
// --- Allocate Correct Filtering Choice
// Can only be one choice
uSuperTrendFilter = filterOption == 'SuperTrend' ? true : false
u3xMATrendFilter = filterOption == '3xMATrend' ? true : false
uBothTrendFilters = filterOption == 'SuperTrend+3xMA' ? true : false
//uOIFilter = filterOption == "OutsideIn:ClrMA" ? true : false
uOIMACrossFilter = filterOption == 'OutsideIn:MACross' ? true : false
uOI3xMAFilter = filterOption == 'OutsideIn:MACross+3xMA' ? true : false
uOISTFilter = filterOption == 'OutsideIn:MACross+ST' ? true : false
uMACrossFilter = filterOption == 'MACross' ? true : false
uMACrossSTFilter = filterOption == 'MACross+ST' ? true : false
uMACross3xMAFilter = filterOption == 'MACross+3xMA' ? true : false
// Supertrend Calculations
SUp = hl2 - SFactor * ta.atr(SPd)
SDn = hl2 + SFactor * ta.atr(SPd)
STrendUp = 0.0
STrendDown = 0.0
STrendUp := close[1] > STrendUp[1] ? math.max(SUp, STrendUp[1]) : SUp
STrendDown := close[1] < STrendDown[1] ? math.min(SDn, STrendDown[1]) : SDn
STrend = 0
STrend := close > STrendDown[1] ? 1 : close < STrendUp[1] ? -1 : nz(STrend[1], 1)
Tsl = STrend == 1 ? STrendUp : STrendDown
// ColouredMA OutsideIn
//oiupper = clrdirection<0 and noiupper>0 and highest(oiLength)>upper[noiupper]?
1 : 0
//oilower = clrdirection>0 and noilower>0 and lowest(oiLength)<lower[noilower]? 1 :
0
// MACross OutsideIN
oiMACrossupper = ta.crossunder(ma_fast, ma_coloured) and noiupper > 0 and
ta.highest(oiLength) > upper[noiupper] ? 1 : 0
oiMACrosslower = ta.crossover(ma_fast, ma_coloured) and noilower > 0 and
ta.lowest(oiLength) < lower[noilower] ? 1 : 0
// Bollinger Bands
p1 = plot(hideBollingerBands ? na : upper, title='BB upper',
color=color.new(dodgerblue, 20), linewidth=1)
p2 = plot(hideBollingerBands ? na : lower, title='BB lower',
color=color.new(dodgerblue, 20), linewidth=1)
fill(p1, p2, color=color.new(dodgerblue, 96), title='BB fill')
// 3xMA Filtering
_3xmabuy = 0
_3xmasell = 0
_3xmabuy := clrdirection == 1 and close > ma_fast and madirection == 1 ?
nz(_3xmabuy[1]) + 1 : clrdirection == 1 and madirection == 1 ? nz(_3xmabuy[1]) >
0 ? nz(_3xmabuy[1]) + 1 : 0 : 0
_3xmasell := clrdirection == -1 and close < ma_fast and madirection == -1 ?
nz(_3xmasell[1]) + 1 : clrdirection == -1 and madirection == -1 ? nz(_3xmasell[1])
> 0 ? nz(_3xmasell[1]) + 1 : 0 : 0
//
// SuperTrend Filtering
stbuy = 0
stsell = 0
stbuy := clrdirection == 1 and STrend == 1 ? nz(stbuy[1]) + 1 : 0
stsell := clrdirection == -1 and STrend == -1 ? nz(stsell[1]) + 1 : 0
//
//
// Check any Alerts set
long = u3xMATrendFilter and _3xmabuy == 1 or uSuperTrendFilter and stbuy == 1 or
uBothTrendFilters and st3xmabuy == 1 or uOI3xMAFilter and oi3xmabuy == 1 or
uOISTFilter and oistbuy == 1 or uOIMACrossFilter and oiMACrossbuy == 1 or
uMACrossSTFilter and macrossSTbuy == 1 or uMACross3xMAFilter and macross3xMAbuy ==
1
short = u3xMATrendFilter and _3xmasell == 1 or uSuperTrendFilter and stsell == 1 or
uBothTrendFilters and st3xmasell == 1 or uOI3xMAFilter and oi3xmasell == 1 or
uOISTFilter and oistsell == 1 or uOIMACrossFilter and oiMACrosssell == 1 or
uMACrossSTFilter and macrossSTsell == 1 or uMACross3xMAFilter and macross3xMAsell
== 1
//
// If Alert Detected, then Draw Big fat liner
plotshape(long ? long : na, title='Long Line Marker', location=location.belowbar,
style=shape.arrowup, color=buyclr, size=size.auto, text='████████████████',
textcolor=buyclr, transp=20)
plotshape(short ? short : na, title='Short Line Marker',
location=location.abovebar, style=shape.arrowdown, color=sellclr, size=size.auto,
text='████████████████', textcolor=sellclr, transp=20)
//
alertcondition(long or short, title='Signal Alert', message='SIGNAL')
alertcondition(long, title='Long Alert', message='LONG')
alertcondition(short, title='Short Alert', message='SHORT')