Super Scalper Strategy v3.3 Update (3) Taitrading
Super Scalper Strategy v3.3 Update (3) Taitrading
//@version=5
strategy("Super Scalper Strategy v3.3", overlay=true, max_labels_count=500,
default_qty_type = strategy.percent_of_equity, default_qty_value = 100,
initial_capital = 100)
///////////////////////////////////////////////////////////////////////////////
//-----------------------------CRYPTO-SLAYA----------------------------------//
///////////////////////////////////////////////////////////////////////////////
// Get user settings
res = input.timeframe(title='TIMEFRAME', defval='15', group ="NON
REPAINT")
sensitivity = input.float(4, "SENSITIVITY (1-10)", 0.1, 10)
percentStop = input.float(0.8, "STOP LOSS %", 0)
percentTake = input.float(0.45, "TAKE PROFIT %", 0)
// Entry & Exit
enableE = input(true, "EXIT & ENTRY ON/OFF", group="EXIT & ENTRY")
Stop = input.color(color.new(#83868f, 5), "STOP LOSS")
Entry = input.color(color.new(#8d020e, 5), "ENTRY")
Tp1 = input.color(color.new(#038007, 5), "TAKE PROFIT")
// Create non-repainting security function
rp_security(_symbol, _res, _src) =>
request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])
// Main Indicator
// Functions
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100
securityNoRep(sym, res, src) => request.security(sym, res, src, barmerge.gaps_off,
barmerge.lookahead_on)
swingPoints(prd) =>
pivHi = ta.pivothigh(prd, prd)
pivLo = ta.pivotlow (prd, prd)
last_pivHi = ta.valuewhen(pivHi, pivHi, 1)
last_pivLo = ta.valuewhen(pivLo, pivLo, 1)
hh = pivHi and pivHi > last_pivHi ? pivHi : na
lh = pivHi and pivHi < last_pivHi ? pivHi : na
hl = pivLo and pivLo > last_pivLo ? pivLo : na
ll = pivLo and pivLo < last_pivLo ? pivLo : na
[hh, lh, hl, ll]
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
f_kc(src, len, sensitivity) =>
basis = ta.sma(src, len)
span = ta.atr(len)
[basis + span * sensitivity, basis - span * sensitivity]
// Get components
source = input(close, title = "Smoothring Source", group = "Smoothing")
smrng1_input= input.int(10, "Smring1", 1, 100 , 1 , group = "Smoothing")
smrng1_sens = input.float(defval = 2,title = "sens",minval = 0.1, maxval = 5 , step
= 0.01 , group = "Smoothing")
smrng2_input= input.int(80, "Smring2", 1, 100 , 1 , group = "Smoothing")
smrng1 = smoothrng(source, smrng1_input, smrng1_sens)
smrng2 = smoothrng(source, smrng2_input, sensitivity)
smrng = (smrng1 + smrng2) / 1.5
filt = rngfilt(source, smrng)
up = 0.0, up := filt > filt[1] ? nz(up[1]) + 1 : filt < filt[1] ? 0 :
nz(up[1])
dn = 0.0, dn := filt < filt[1] ? nz(dn[1]) + 1 : filt > filt[1] ? 0 :
nz(dn[1])
bullCond = bool(na), bullCond := source > filt and source > source[1] and up > 0
or source > filt and source < source[1] and up > 0
bearCond = bool(na), bearCond := source < filt and source < source[1] and dn > 0
or source < filt and source > source[1] and dn > 0
lastCond = 0, lastCond := bullCond ? 1 : bearCond ? -1 : lastCond[1]
bull = bullCond and lastCond[1] == -1
bear = bearCond and lastCond[1] == 1
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
rsi = ta.rsi(close, 28)
rsiOb = rsi > 78 and rsi > ta.ema(rsi, 10)
rsiOs = rsi < 27 and rsi < ta.ema(rsi, 10)
dHigh = securityNoRep(syminfo.tickerid, "D", high [1])
dLow = securityNoRep(syminfo.tickerid, "D", low [1])
dClose = securityNoRep(syminfo.tickerid, "D", close[1])
ema = ta.ema(close, 144)
emaBull = close > ema
equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes() and not
timeframe.isseconds
higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes() or timeframe.isseconds
too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and
str.tonumber(res) < 10)
securityNoRep1(sym, res, src) =>
bool bull_ = na
bull_ := equal_tf(res) ? src : bull_
bull_ := higher_tf(res) ? request.security(sym, res, src, barmerge.gaps_off,
barmerge.lookahead_on) : bull_
bull_array = request.security_lower_tf(syminfo.tickerid, higher_tf(res) ?
str.tostring(f_chartTfInMinutes()) + (timeframe.isseconds ? "S" : "") :
too_small_tf(res) ? (timeframe.isweekly ? "3" : "10") : res, src)
if array.size(bull_array) > 1 and not equal_tf(res) and not higher_tf(res)
bull_ := array.pop(bull_array)
array.clear(bull_array)
bull_
TF1Bull = securityNoRep1(syminfo.tickerid, "1" , emaBull)
TF3Bull = securityNoRep1(syminfo.tickerid, "3" , emaBull)
TF5Bull = securityNoRep1(syminfo.tickerid, "5" , emaBull)
TF15Bull = securityNoRep1(syminfo.tickerid, "15" , emaBull)
TF30Bull = securityNoRep1(syminfo.tickerid, "30" , emaBull)
TF60Bull = securityNoRep1(syminfo.tickerid, "60" , emaBull)
TF120Bull = securityNoRep1(syminfo.tickerid, "120" , emaBull)
TF240Bull = securityNoRep1(syminfo.tickerid, "240" , emaBull)
TF480Bull = securityNoRep1(syminfo.tickerid, "480" , emaBull)
TFDBull = securityNoRep1(syminfo.tickerid, "1440", emaBull)
srcStop = close
atrBand = srcStop * (percentStop / 100)
atrBand2 = srcStop * (percentTake / 100)
atrStop = trigger ? srcStop - atrBand : srcStop + atrBand
atrTake = trigger ? srcStop - atrBand2 : srcStop + atrBand2
lastTrade(src) => ta.valuewhen(bull or bear, src, 0)
entry_y = lastTrade(srcStop)
stop_y = lastTrade(atrStop)
tp1_y = (entry_y - lastTrade(atrTake)) + entry_y
// Labels
labelTpSl(y, txt, color) =>
label labelTpSl = percentStop and enableE != 0 ? label.new(bar_index + 1, y,
txt, xloc.bar_index, yloc.price, color, label.style_label_left, color.white,
size.normal) : na
label.delete(labelTpSl[1])
labelTpSl(entry_y, "Entry: " + str.tostring(math.round_to_mintick(entry_y)), color
= Entry)
labelTpSl(stop_y , "Stop Loss: " + str.tostring(math.round_to_mintick(stop_y)),
color = Stop)
labelTpSl(tp1_y, "Take Profit: " + str.tostring(math.round_to_mintick(tp1_y)),
color = Tp1)
lineTpSl(y, color) =>
line lineTpSl = percentStop and enableE != 0 ? line.new(bar_index - (trigger ?
countBull : countBear) + 4, y, bar_index + 1, y, xloc.bar_index, extend.none,
color, line.style_solid) : na
line.delete(lineTpSl[1])
lineTpSl(entry_y, color = Entry)
lineTpSl(stop_y, color = Stop)
lineTpSl(tp1_y, color = Tp1)
////////////////////////////////////////////////////////////////////////////////
//------------------------------BASELINE--------------------------------------//
////////////////////////////////////////////////////////////////////////////////
show_Baseline = input(title='Show Baseline', defval=true, group="BASELINE")
////BASELINE VALUES
maType = input.string(title='Baseline Type', defval='WMA', options=['SMA', 'EMA',
'WMA'])
len8 = input(title='Baseline Length', defval=50)
src8 = input(title='Source', defval=close)
//
tema(src8, len8) =>
ema1 = ta.ema(src8, len8)
ema2 = ta.ema(ema1, len8)
ema3 = ta.ema(ema2, len8)
3 * ema1 - 3 * ema2 + ema3
//----
ma(type, src8, len8) =>
float result = 0
if type == 'SMA' // Simple
result := ta.sma(src8, len8)
result
if type == 'EMA' // Exponential
result := ta.ema(src8, len8)
result
if type == 'WMA' // Weighted
result := ta.wma(src8, len8)
result
///Baseline Channel
BBMC = ma(maType, close, len8)
useTrueRange = input(true)
multy = input.float(0.2, step=0.05, title='Base Channel Multiplier')
Keltma = ma(maType, src8, len8)
range_1 = useTrueRange ? ta.tr : high - low
rangema = ta.ema(range_1, len8)
upperk = Keltma + rangema * multy
lowerk = Keltma - rangema * multy
//COLORS
color_bar = close > upperk ? #39ff14 : close < lowerk ? #ff1100 : color.yellow
//PLOTS
p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=6,
title='Baseline', transp=0)
////////////////////////////////////////////////////////////////////////////////
//--------------------------FILTER-OVER/UNDER-EMA-----------------------------//
////////////////////////////////////////////////////////////////////////////////
// inputs
emafilter = input.bool(true, title="Filter Over/Under EMA", group="EMA Filter")
emalength = input.int(200, title="EMA Length")
src7 = close
//Inputs
i_priceSrc = input.source ( close, 'Price Source', group='Properties')
i_basisType = input.string ( 'SMA', 'Basis Type', options=['SMA', 'EMA',
'WMA'], group='Properties')
///////////////////////////////////////////////////////////////////////////////
// function declarations
f_maType ( _price, _len, _type ) =>
_type == 'SMA' ? ta.sma ( _price, _len ) : _type == 'EMA' ? ta.ema ( _price,
_len ) : ta.wma ( _price, _len )
// OB
OBMitigationType = input.string("Close", title="Mitigation Type", options=["Close",
"Wick"], group="Order Blocks", tooltip="Choose how Order Blocks are mitigated")
OBBullMitigation = OBMitigationType=="Close" ? close[1] : low
OBBearMitigation = OBMitigationType=="Close" ? close[1] : high
//OB Colors
col_bullish = input.color(#5db49e, title="Bullish OB Border", inline="a",
group="Order Blocks")
col_bullish_ob = input.color(color.new(#64C4AC, 85), title="Background",
inline="a", group="Order Blocks")
// Delacring Variables
bool ob_created = false
bool ob_created_bull = false
var int cross_index = na
// If the ROC crossover our Sensitivty input - Then create an Order Block
// Sensitivty is negative as this is a Bearish OB
if ta.crossunder(pc, -sens)
ob_created := true
cross_index := bar_index
cross_index
// If the ROC crossover our Sensitivty input - Then create an Order Block
if ta.crossover(pc, sens)
ob_created_bull := true
cross_index := bar_index
cross_index
// -------------------------------
// Bearish OB Creation
// -------------------------------
// Check if we should create a OB, Also check if we haven't created an OB in the
last 5 candles.
if ob_created and cross_index - cross_index[1] > 5
float last_green = 0
float highest = 0
// Loop through the most recent candles and find the first GREEN (Bullish)
candle. We will place our OB here.
for i = 4 to 15 by 1
if close[i] > open[i]
last_green := i
break
// Draw our OB on that candle - then push the box into our box arrays.
drawShortBox := box.new(left=bar_index[last_green], top=high[last_green],
bottom=low[last_green], right=bar_index[last_green], bgcolor=col_bearish_ob,
border_color=col_bearish, extend=extend.right)
array.push(shortBoxes, drawShortBox)
// -------------------------------
// Bullish OB Creation
// -------------------------------
// Check if we should create a OB, Also check if we haven't created an OB in the
last 5 candles.
if ob_created_bull and cross_index - cross_index[1] > 5
float last_red = 0
float highest = 0
// Loop through the most recent candles and find the first RED (Bearish)
candle. We will place our OB here.
for i = 4 to 15 by 1
if close[i] < open[i]
last_red := i
break
// Draw our OB on that candle - then push the box into our box arrays.
drawlongBox := box.new(left=bar_index[last_red], top=high[last_red],
bottom=low[last_red], right=bar_index[last_red], bgcolor=col_bullish_ob,
border_color=col_bullish, extend=extend.right)
array.push(longBoxes, drawlongBox)
//////////////////////////////////////////////////////////////////////////////
//WATERMARK
Watermark = table.new(position.bottom_left, 1, 4, border_width=3)
table.cell(Watermark, 0, 0, text='Super Scalper Strategy v3.3',
text_color=color.new(color.white, 85), text_size=size.huge)