Compare commits

..
10 Commits
Author SHA1 Message Date
saherelm c9939dc38a add smoothed hiken ashi .... 2024-05-05 18:17:00 +03:30
saherelm 43acacdfad last ... 2024-04-22 19:14:49 +03:30
saherelm 7a89415f30 add supert trended ind and osc to pine ... 2024-04-22 08:19:01 +03:30
saherelm e0127053e3 last ... 2024-04-06 14:11:03 +03:30
saherelm cc85bc83d7 last ... 2024-04-05 18:16:58 +03:30
saherelm c8ccf89ddd last ... 2024-04-04 18:28:01 +03:30
saherelm d4fce3c021 add new works ... 2024-04-01 14:56:00 +03:30
saherelm 4aca5799d5 add some new indicators ... 2024-03-09 12:04:57 +03:30
saherelm ec3e30bddb add chandelier exit 1 sample indicator ... 2024-03-08 19:46:58 +03:30
saherelm 73af4b648e add some new indicator/oscillators ... 2024-03-04 02:32:04 +03:30
24 changed files with 3568 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center Chandelier Exit
// ---------------------------------------------
// saherelm implementation of above indicator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm Chandelier Exit Indicator", shorttitle = "XS_CE_IND", overlay = true)
//
// START Inputs ....
//
//
var string XCECalcGroup = 'Calculation'
XCELength = input.int(title='ATR Period', defval=22, group=XCECalcGroup)
XCEMult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=XCECalcGroup)
XCEUseClose = input.bool(title='Use Close Price for Extremums', defval=true, group=XCECalcGroup)
//
var string XCEVisualGroup = 'Visuals'
XCEShowLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=XCEVisualGroup)
XCEHighlightState = input.bool(title='Highlight State', defval=true, group=XCEVisualGroup)
//
// END Inputs ....
//
//
// START Functions ....
//
//
//
// END Functions ....
//
//
// START Calculations ....
//
//
// Calculate ATR Value ...
XCEAtr = XCEMult * ta.atr(XCELength)
//
// Long Calculations ...
XCELongStop = (XCEUseClose ? ta.highest(close, XCELength) : ta.highest(XCELength)) - XCEAtr
XCELongStopPrev = nz(XCELongStop[1], XCELongStop)
XCELongStop := close[1] > XCELongStopPrev ? math.max(XCELongStop, XCELongStopPrev) : XCELongStop
//
// Short Calculations ...
XCEShortStop = (XCEUseClose ? ta.lowest(close, XCELength) : ta.lowest(XCELength)) + XCEAtr
XCEShortStopPrev = nz(XCEShortStop[1], XCEShortStop)
XCEShortStop := close[1] < XCEShortStopPrev ? math.min(XCEShortStop, XCEShortStopPrev) : XCEShortStop
//
// Calculate Current Direction ...
var int XCEDir = 1
XCEDir := close > XCEShortStopPrev ? 1 : close < XCELongStopPrev ? -1 : XCEDir
//
// Calculate Signals ...
XCEBuySignal = XCEDir == 1 and XCEDir[1] == -1
XCESellSignal = XCEDir == -1 and XCEDir[1] == 1
//
// Calculate Colors ...
var color XCELongColor = color.green
var color XCEShortColor = color.red
var color XCELongFillColor = color.new(color.green, 90)
var color XCEShortFillColor = color.new(color.red, 90)
var color XCETextColor = color.new(color.white, 0)
XCELongStateFillColor = XCEHighlightState ? XCEDir == 1 ? XCELongFillColor : na : na
XCEShortStateFillColor = XCEHighlightState ? XCEDir == -1 ? XCEShortFillColor : na : na
//
// END Calculations ....
//
//
// START Plots ....
//
//
// Long Plots ...
XCELongStopPlot = plot(XCEDir == 1 ? XCELongStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(XCELongColor, 0))
plotshape(XCEBuySignal ? XCELongStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(XCELongColor, 0))
plotshape(XCEBuySignal and XCEShowLabels ? XCELongStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(XCELongColor, 0), textcolor=XCETextColor)
//
// Short Plots ...
XCEShortStopPlot = plot(XCEDir == 1 ? na : XCEShortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(XCEShortColor, 0))
plotshape(XCESellSignal ? XCEShortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(XCEShortColor, 0))
plotshape(XCESellSignal and XCEShowLabels ? XCEShortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(XCEShortColor, 0), textcolor=XCETextColor)
//
// Filling Long and Short ...
XCEMidPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false)
fill(XCEMidPricePlot, XCELongStopPlot, title='Long State Filling', color=XCELongStateFillColor)
fill(XCEMidPricePlot, XCEShortStopPlot, title='Short State Filling', color=XCEShortStateFillColor)
//
// END Plots ....
//
//
// START Alerts ...
//
// END Alerts ...
//
+179
View File
@@ -0,0 +1,179 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center Chandelier Exit / Hull Trend ...
// ---------------------------------------------------
// saherelm implementation of above indicator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm Chandelier Exit/ Hull Trend Indicator", shorttitle = "XS_CEHULL_IND", overlay = true)
//
// START Inputs ....
//
//
var string XCECalcGroup = 'Calculation'
//
// CE ...
XCELength = input.int(title='ATR Period', defval=22, group=XCECalcGroup)
XCEMult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=XCECalcGroup)
XCEUseClose = input.bool(title='Use Close Price for Extremums', defval=true, group=XCECalcGroup)
//
// Hull ...
HUTRSrc = input.source(defval = hl2, title = "Source", group=XCECalcGroup)
HUTRLength = input.int(defval = 23, title = "Length", group=XCECalcGroup)
//
var string XCEVisualGroup = 'Visuals'
//
XShowXCE = input.bool(title='Show XCE', defval=true, group=XCEVisualGroup)
XShowXHull = input.bool(title='Show XHull', defval=true, group=XCEVisualGroup)
//
// CE ...
XCEShowLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=XCEVisualGroup)
XCEHighlightState = input.bool(title='Highlight State', defval=true, group=XCEVisualGroup)
//
// Hull ...
HUTRShowCross = input.bool(defval = true, title = "Show cross over/under", group=XCEVisualGroup)
//
// END Inputs ....
//
//
// START Functions ....
//
//
HUTRHma(src, length)=>
ta.wma((2 * ta.wma(src, length / 2)) - ta.wma(src, length), math.round(math.sqrt(length)))
//
HUTRHma3(src, length)=>
p = length / 2
ta.wma(ta.wma(close, p / 3) * 3 - ta.wma(close, p / 2) - ta.wma(close, p) ,p)
//
// END Functions ....
//
//
// START Calculations ....
//
//
// CE ...
//
// Calculate ATR Value ...
XCEAtr = XCEMult * ta.atr(XCELength)
//
// Long Calculations ...
XCELongStop = (XCEUseClose ? ta.highest(close, XCELength) : ta.highest(XCELength)) - XCEAtr
XCELongStopPrev = nz(XCELongStop[1], XCELongStop)
XCELongStop := close[1] > XCELongStopPrev ? math.max(XCELongStop, XCELongStopPrev) : XCELongStop
//
// Short Calculations ...
XCEShortStop = (XCEUseClose ? ta.lowest(close, XCELength) : ta.lowest(XCELength)) + XCEAtr
XCEShortStopPrev = nz(XCEShortStop[1], XCEShortStop)
XCEShortStop := close[1] < XCEShortStopPrev ? math.min(XCEShortStop, XCEShortStopPrev) : XCEShortStop
//
// Calculate Current Direction ...
var int XCEDir = 1
XCEDir := close > XCEShortStopPrev ? 1 : close < XCELongStopPrev ? -1 : XCEDir
//
// Calculate Signals ...
XCEBuySignal = XCEDir == 1 and XCEDir[1] == -1
XCESellSignal = XCEDir == -1 and XCEDir[1] == 1
//
// Calculate Colors ...
var color XCELongColor = color.green
var color XCEShortColor = color.red
var color XCELongFillColor = color.new(color.green, 90)
var color XCEShortFillColor = color.new(color.red, 90)
var color XCETextColor = color.new(color.white, 0)
XCELongStateFillColor = XCEHighlightState ? XCEDir == 1 ? XCELongFillColor : na : na
XCEShortStateFillColor = XCEHighlightState ? XCEDir == -1 ? XCEShortFillColor : na : na
//
// Hull ...
//
HUTRA = HUTRHma(HUTRSrc, HUTRLength)
HUTRB = HUTRHma3(HUTRSrc, HUTRLength)
HUTRColor = HUTRB > HUTRA ? color.lime : color.red
//
HUTRCrossDown = HUTRA > HUTRB and HUTRA[1] < HUTRB[1]
HUTRCrossUp = HUTRB > HUTRA and HUTRB[1] < HUTRA[1]
//
// END Calculations ....
//
//
// START Plots ....
//
//
// CE ...
//
// Long Plots ...
XCELongStopPlot = plot((XCEDir == 1 and XShowXCE) ? XCELongStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(XCELongColor, 0))
plotshape((XShowXCE and XCEBuySignal) ? XCELongStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(XCELongColor, 0))
plotshape((XShowXCE and XCEBuySignal and XCEShowLabels) ? XCELongStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(XCELongColor, 0), textcolor=XCETextColor)
//
// Short Plots ...
XCEShortStopPlot = plot((XCEDir == 1 or (not XShowXCE)) ? na : XCEShortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(XCEShortColor, 0))
plotshape((XShowXCE and XCESellSignal) ? XCEShortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(XCEShortColor, 0))
plotshape((XShowXCE and XCESellSignal and XCEShowLabels) ? XCEShortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(XCEShortColor, 0), textcolor=XCETextColor)
//
// Filling Long and Short ...
XCEMidPricePlot = plot(XShowXCE ? ohlc4 : na, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false)
fill(XCEMidPricePlot, XCELongStopPlot, title='Long State Filling', color=XShowXCE ? XCELongStateFillColor : na)
fill(XCEMidPricePlot, XCEShortStopPlot, title='Short State Filling', color=XShowXCE ? XCEShortStateFillColor : na)
//
// Hull ...
//
HUTRP1 = plot(series = XShowXHull ? HUTRA : na, color = color.new(HUTRColor, 75), linewidth = 1, title = "Upper Line")
HUTRP2 = plot(series = XShowXHull ? HUTRB : na, color = color.new(HUTRColor, 75), linewidth = 1, title = "Downer Line")
//
fill(HUTRP1, HUTRP2, color = XShowXHull ? color.new(HUTRColor, 55) : na, title = "Cloud Fill")
//
plotshape((XShowXHull and HUTRShowCross and HUTRCrossDown) ? HUTRA : na, location = location.absolute, style = shape.labeldown, color = color.red, size = size.tiny, text = "Sell", textcolor = color.white, offset=-1)
plotshape((XShowXHull and HUTRShowCross and HUTRCrossUp) ? HUTRA : na, location = location.absolute, style = shape.labelup, color = color.green, size = size.tiny, text = "Buy", textcolor = color.white, offset=-1)
//
// END Plots ....
//
//
// START Alerts ...
//
// END Alerts ...
//
+113
View File
@@ -0,0 +1,113 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center XUT Indicator
// ---------------------------------------------
// saherelm implementation of above indicator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm XUT Indicator", shorttitle = "XUT_IND", overlay = true)
//
// START Inputs ....
//
sensitivity = input(2, title = "Key Vaule. 'This changes the sensitivity'")
atrPeriod = input(10, title = "ATR Period")
maPeriod = input.int(50, minval=1, title="MA Period")
//
// END Inputs ....
//
//
// START Functions ....
//
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
//
// END Functions ....
//
//
// START Calculations ....
//
//
src = close
maMethod = "SMA"
maSmoothingLength = 5
//
// Ma Calculations ...
out = ta.sma(src, maPeriod)
maSmoothingLine = ma(out, maSmoothingLength, maMethod)
//
xATR = ta.atr(atrPeriod)
nLoss = sensitivity * xATR
//
xATRTrailingStop = 0.0
xATRTrailingStop := (src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0)) ? math.max(nz(xATRTrailingStop[1]) , src - nLoss) : (src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0)) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : (src > nz(xATRTrailingStop[1], 0)) ? src - nLoss : src + nLoss
//
pos = 0
pos := (src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0)) ? 1 : (src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0)) ? -1 : nz(pos[1], 0)
//
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
//
ema = ta.ema(src,1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
//
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
//
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
//
// END Calculations ....
//
//
// START Plots ....
//
//
// MA Plots ...
plot(out, color=color.blue, title="MA", offset=0)
plot(maSmoothingLine, title="Smoothing Line", color=#f37f20, offset=0, display=display.none)
//
// UT Plots ...
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny)
//
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
//
alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")
//
// END Plots ....
//
//
// START Alerts ...
//
// END Alerts ...
//
+93
View File
@@ -0,0 +1,93 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center STC Histogram
// ---------------------------------------------
// saherelm implementation of above oscillator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm STC Histogram", shorttitle = "XSTC_OSC", overlay = false)
//
// START Inputs ....
//
length = input(12, 'Length')
fastPeriod = input(26, 'FastLength')
slowPeriod = input(50, 'SlowLength')
//
// END Inputs ....
//
//
// START Functions ....
//
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
//
// END Functions ....
//
//
// START Calculations ....
//
maValue = AAAAA(length, fastPeriod, slowPeriod)
mColor = maValue > maValue[1] ? color.new(color.green, 20) : color.new(color.red, 20)
//
//
// END Calculations ....
//
//
// START Plots ....
//
//
plot(maValue, color = mColor, title = 'XSTC', linewidth = 2)
//
ul = plot(25, color=color.new(color.gray, 70))
ll = plot(75, color=color.new(color.gray, 70))
fill(ul, ll, color=color.new(color.gray, 96))
//
// END Plots ....
//
//
// START Alerts ...
//
//
if maValue[3] <= maValue[2] and maValue[2] > maValue[1] and maValue > 75
alert("Red", alert.freq_once_per_bar)
//
if maValue[3] >= maValue[2] and maValue[2] < maValue[1] and maValue < 25
alert("Green", alert.freq_once_per_bar)
//
// END Alerts ...
//
+182
View File
@@ -0,0 +1,182 @@
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("FVG Sessions [LuxAlgo]", overlay = true, max_lines_count = 500, max_boxes_count = 500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
bullCss = input.color(color.teal, 'FVG Level' , inline = 'bull')
bullAreaCss = input.color(color.new(color.teal, 50), 'Area' , inline = 'bull')
bullMitigatedCss = input.color(color.new(color.teal, 80), 'Mitigated', inline = 'bull')
bearCss = input.color(color.red, 'FVG Level' , inline = 'bear')
bearAreaCss = input.color(color.new(color.red, 50), 'Area' , inline = 'bear')
bearMitigatedCss = input.color(color.new(color.red, 80), 'Mitigated' , inline = 'bear')
//-----------------------------------------------------------------------------}
//UDT's
//-----------------------------------------------------------------------------{
type fvg
float top
float btm
bool mitigated
bool isnew
bool isbull
line lvl
box area
type session_range
line max
line min
//-----------------------------------------------------------------------------}
//Methods
//-----------------------------------------------------------------------------{
n = bar_index
//Method for setting fair value gaps
method set_fvg(fvg id, offset, bg_css, l_css)=>
avg = math.avg(id.top, id.btm)
area = box.new(n - offset, id.top, n, id.btm, na, bgcolor = bg_css)
avg_l = line.new(n - offset, avg, n, avg, color = l_css, style = line.style_dashed)
id.lvl := avg_l
id.area := area
//Method for setting session range maximum/minimum
method set_range(session_range id)=>
max = math.max(high, id.max.get_y2())
min = math.min(low, id.min.get_y2())
id.max.set_xy2(n, max)
id.max.set_y1(max)
id.min.set_xy2(n, min)
id.min.set_y1(min)
//-----------------------------------------------------------------------------}
//Variables
//-----------------------------------------------------------------------------{
var chartCss = color.new(chart.fg_color, 50)
var fvg sfvg = fvg.new(na, na, na, true, na)
var session_range sesr = na
var box area = na
var line avg = na
bull_fvg = low > high[2] and close[1] > high[2]
bear_fvg = high < low[2] and close[1] < low[2]
//Alert conditions
bull_isnew = false
bear_isnew = false
bull_mitigated = false
bear_mitigated = false
within_bull_fvg = false
within_bear_fvg = false
//-----------------------------------------------------------------------------}
//New session
//-----------------------------------------------------------------------------{
dtf = timeframe.change('D')
//On new session
if dtf
//Set delimiter
line.new(n, high + syminfo.mintick
, n, low - syminfo.mintick
, color = chartCss
, style = line.style_dashed
, extend = extend.both)
//Set new range
sesr := session_range.new(
line.new(n, high, n, high, color = chartCss)
, line.new(n, low, n, low, color = chartCss))
sfvg.isnew := true
//Set prior session fvg right coordinates
if not na(sfvg.lvl)
sfvg.lvl.set_x2(n-2)
sfvg.area.set_right(n-2)
//Set range
else if not na(sesr)
sesr.set_range()
//Set range lines color
sesr.max.set_color(sfvg.isbull ? bullCss : bearCss)
sesr.min.set_color(sfvg.isbull ? bullCss : bearCss)
//-----------------------------------------------------------------------------}
//Set FVG
//-----------------------------------------------------------------------------{
//New session bullish fvg
if bull_fvg and sfvg.isnew
sfvg := fvg.new(low, high[2], false, false, true)
sfvg.set_fvg(2, bullAreaCss, bullCss)
bull_isnew := true
//New session bearish fvg
else if bear_fvg and sfvg.isnew
sfvg := fvg.new(low[2], high, false, false, false)
sfvg.set_fvg(2, bearAreaCss, bearCss)
bear_isnew := true
//Change object transparencies if mitigated
if not sfvg.mitigated
//If session fvg is bullish
if sfvg.isbull and close < sfvg.btm
sfvg.set_fvg(1, bullMitigatedCss, bullCss)
sfvg.mitigated := true
bull_mitigated := true
//If session fvg is bearish
else if not sfvg.isbull and close > sfvg.top
sfvg.set_fvg(1, bearMitigatedCss, bearCss)
sfvg.mitigated := true
bear_mitigated := true
//Set fvg right coordinates to current bar
if not sfvg.isnew
sfvg.lvl.set_x2(n)
sfvg.area.set_right(n)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//On new session fvg
alertcondition(bull_isnew, 'Bullish FVG', 'New session bullish fvg')
alertcondition(bear_isnew, 'Bearish FVG', 'New session bearish fvg')
//On fvg mitigation
alertcondition(bull_mitigated, 'Mitigated Bullish FVG', 'Session bullish fvg has been mitigated')
alertcondition(bear_mitigated, 'Mitigated Bearish FVG', 'Session bearish fvg has been mitigated')
//If within fvg
alertcondition(close >= sfvg.btm and close <= sfvg.top and sfvg.isbull and not sfvg.isnew
, 'Price Within Bullish FVG'
, 'Price is within bullish fvg')
alertcondition(close >= sfvg.btm and close <= sfvg.top and not sfvg.isbull and not sfvg.isnew
, 'Price Within Bearish FVG'
, 'Price is within bearish fvg')
//On fvg average cross
alertcondition(ta.cross(close, math.avg(sfvg.top, sfvg.btm)) and sfvg.isbull and not sfvg.isnew
, 'Bullish FVG AVG Cross'
, 'Price crossed bullish fvg average')
alertcondition(ta.cross(close, math.avg(sfvg.top, sfvg.btm)) and not sfvg.isbull and not sfvg.isnew
, 'Bearish FVG AVG Cross'
, 'Price crossed bearish fvg average')
//-----------------------------------------------------------------------------}
+42
View File
@@ -0,0 +1,42 @@
//@version=4
study(title="UT Bot Alerts", overlay = true)
// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = atr(c)
nLoss = a * xATR
src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close
xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
pos = 0
pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
ema = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")
@@ -0,0 +1,47 @@
//@version=4
study(title="Average True Range Stop Loss Finder", shorttitle="ATR", overlay=true)
length = input(title="Length", defval=14, minval=1)
smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
m = input(1.5, "Multiplier")
src1 = input(high)
src2 = input(low)
pline = input(true, "Show Price Lines")
col1 = input(color.blue, "ATR Text Color")
col2 = input(color.teal, "Low Text Color",inline ="1")
col3 = input(color.red, "High Text Color",inline ="2")
collong = input(color.teal, "Low Line Color",inline ="1")
colshort = input(color.red, "High Line Color",inline ="2")
ma_function(source, length) =>
if smoothing == "RMA"
rma(source, length)
else
if smoothing == "SMA"
sma(source, length)
else
if smoothing == "EMA"
ema(source, length)
else
wma(source, length)
a = ma_function(tr(true), length) * m
x = ma_function(tr(true), length) * m + src1
x2 = src2 - ma_function(tr(true), length) * m
p1 = plot(x, title = "ATR Short Stop Loss", color= colshort, transp=20, trackprice = pline ? true : false)
p2 = plot(x2, title = "ATR Long Stop Loss", color= collong, transp=20, trackprice = pline ? true : false)
var table Table = table.new(position.bottom_center, 3, 1, border_width = 3)
f_fillCell(_table, _column, _row, _value, _timeframe) =>
_cellText = _timeframe+ tostring(_value, "#.#")
table.cell(_table, _column, _row, _cellText, text_color = col1)
table.cell_set_text_color(Table, 1, 0, color.new(col3, transp = 0))
table.cell_set_text_color(Table, 2, 0, color.new(col2, transp = 0))
if barstate.islast
f_fillCell(Table, 0, 0, a, "ATR: " )
f_fillCell(Table, 1, 0, x, "H: " )
f_fillCell(Table, 2, 0, x2, "L: " )
@@ -0,0 +1,57 @@
//@version=5
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Chandelier Exit script may be freely distributed under the terms of the GPL-3.0 license.
indicator('Chandelier Exit', shorttitle='CE', overlay=true)
var string calcGroup = 'Calculation'
length = input.int(title='ATR Period', defval=22, group=calcGroup)
mult = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=calcGroup)
useClose = input.bool(title='Use Close Price for Extremums', defval=true, group=calcGroup)
var string visualGroup = 'Visuals'
showLabels = input.bool(title='Show Buy/Sell Labels', defval=true, group=visualGroup)
highlightState = input.bool(title='Highlight State', defval=true, group=visualGroup)
var string alertGroup = 'Alerts'
awaitBarConfirmation = input.bool(title="Await Bar Confirmation", defval=true, group=alertGroup)
atr = mult * ta.atr(length)
longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr
longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
var int dir = 1
dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir
var color longColor = color.green
var color shortColor = color.red
var color longFillColor = color.new(color.green, 90)
var color shortFillColor = color.new(color.red, 90)
var color textColor = color.new(color.white, 0)
longStopPlot = plot(dir == 1 ? longStop : na, title='Long Stop', style=plot.style_linebr, linewidth=2, color=color.new(longColor, 0))
buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal ? longStop : na, title='Long Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(longColor, 0))
plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(longColor, 0), textcolor=textColor)
shortStopPlot = plot(dir == 1 ? na : shortStop, title='Short Stop', style=plot.style_linebr, linewidth=2, color=color.new(shortColor, 0))
sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal ? shortStop : na, title='Short Stop Start', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(shortColor, 0))
plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(shortColor, 0), textcolor=textColor)
midPricePlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0, display=display.none, editable=false)
longStateFillColor = highlightState ? dir == 1 ? longFillColor : na : na
shortStateFillColor = highlightState ? dir == -1 ? shortFillColor : na : na
fill(midPricePlot, longStopPlot, title='Long State Filling', color=longStateFillColor)
fill(midPricePlot, shortStopPlot, title='Short State Filling', color=shortStateFillColor)
await = awaitBarConfirmation ? barstate.isconfirmed : true
alertcondition(dir != dir[1] and await, title='Alert: CE Direction Change', message='Chandelier Exit has changed direction!')
alertcondition(buySignal and await, title='Alert: CE Buy', message='Chandelier Exit Buy!')
alertcondition(sellSignal and await, title='Alert: CE Sell', message='Chandelier Exit Sell!')
+8
View File
@@ -0,0 +1,8 @@
//@version=5
indicator(title="Double EMA", shorttitle="DEMA", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(9, minval=1)
src = input(close, title="Source")
e1 = ta.ema(src, length)
e2 = ta.ema(e1, length)
dema = 2 * e1 - e2
plot(dema, "DEMA", color=#43A047)
+31
View File
@@ -0,0 +1,31 @@
study(shorttitle="FBB", title="Fibonacci Bollinger Bands", overlay=true)
length = input(200, minval=1)
src = input(hlc3, title="Source")
mult = input(3.0, minval=0.001, maxval=50)
basis = vwma(src, length)
dev = mult * stdev(src, length)
upper_1= basis + (0.236*dev)
upper_2= basis + (0.382*dev)
upper_3= basis + (0.5*dev)
upper_4= basis + (0.618*dev)
upper_5= basis + (0.764*dev)
upper_6= basis + (1*dev)
lower_1= basis - (0.236*dev)
lower_2= basis - (0.382*dev)
lower_3= basis - (0.5*dev)
lower_4= basis - (0.618*dev)
lower_5= basis - (0.764*dev)
lower_6= basis - (1*dev)
plot(basis, color=fuchsia, linewidth=2)
p1 = plot(upper_1, color=white, linewidth=1, title="0.236")
p2 = plot(upper_2, color=white, linewidth=1, title="0.382")
p3 = plot(upper_3, color=white, linewidth=1, title="0.5")
p4 = plot(upper_4, color=white, linewidth=1, title="0.618")
p5 = plot(upper_5, color=white, linewidth=1, title="0.764")
p6 = plot(upper_6, color=red, linewidth=2, title="1")
p13 = plot(lower_1, color=white, linewidth=1, title="0.236")
p14 = plot(lower_2, color=white, linewidth=1, title="0.382")
p15 = plot(lower_3, color=white, linewidth=1, title="0.5")
p16 = plot(lower_4, color=white, linewidth=1, title="0.618")
p17 = plot(lower_5, color=white, linewidth=1, title="0.764")
p18 = plot(lower_6, color=green, linewidth=2, title="1")
@@ -0,0 +1,42 @@
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ozzy_livin
//@version=4
study(title="Ichimoku Buy & Sell Signals", shorttitle="Ichimoku", overlay=true)
// Periods
conversionPeriods = input(20, minval=1, title="Conversion Line Length")
basePeriods = input(60, minval=1, title="Base Line Length")
laggingSpan2Periods = input(120, minval=1, title="Lagging Span 2 Length")
displacement = input(30, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
// Build MA and Ichimoku
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
// Plot MA
plot(conversionLine, color=#00BCD4, transp=25, title="Tenkan")
plot(baseLine, color=#F44336, transp=25, title="Kijun")
// Plot Cloud
p1 = plot(leadLine1, offset = displacement - 1, color=#4CAF50, transp=25, title="Lead 1")
p2 = plot(leadLine2, offset = displacement - 1, color=#FF5252, transp=25, title="Lead 2")
// Color Fill Cloud
fill(p1, p2, color = leadLine1 > leadLine2 ? #4CAF50 : #FF5252, transp=75)
// Plot CROSS at MA Cross Over
plot(crossover(conversionLine, baseLine) ? conversionLine : na, style = plot.style_circles, color=#00FF00, transp=25, linewidth = 8, title="Cross Long")
// Plot CROSS at MA Cross Under
plot(crossover(baseLine, conversionLine) ? baseLine : na, style = plot.style_circles, color=#FF9800, transp=25, linewidth = 8, title="Cross Short")
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,667 @@
//FUNCTIONS
RoundUp(number, decimals) =>
factor = math.pow(10, decimals)
math.ceil(number * factor) / factor
calc_rr(float entry_price, float sl_price, float take_price) =>
entry_price > sl_price ? (take_price - entry_price) / (entry_price - sl_price) : (entry_price - take_price) / (sl_price - entry_price)
create_trend_line(float sensitivity, float fib) =>
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
high_line - channel_range * fib
//FUNCTIONS
// TYPES AND METHODS
type Strategy_settings
float sensitivity = 0
float risk_percent = 1
string break_even_target = "1"
float tp1_percent = 0
float tp1_percent_fix = 0
float tp2_percent = 0
float tp2_percent_fix = 0
float tp3_percent = 0
float tp3_percent_fix = 0
float tp4_percent = 0
float tp4_percent_fix = 0
bool fixed_stop = false
float sl_percent = 0
type Trade
int start_bar_index = 0
string side
float market_order_comission
float limit_order_comission
float entry_price
bool entry_hit = false
float sl_price
float tp1_price
float tp1_percent_fix
float tp2_price
float tp2_percent_fix
float tp3_price
float tp3_percent_fix
float tp4_price
float tp4_percent_fix
float break_even_price
bool sl_hit = false
bool tp1_hit = false
bool tp2_hit = false
bool tp3_hit = false
bool tp4_hit = false
float position_size_left = 100
float risk_percent
bool is_closed = false
float close_price = 0
bool can_break_even = false
bool force_closed = false
float profit = 0
float risk_reward
line entry_line
line stoploss_line
line target1_line
line target2_line
line target3_line
line target4_line
method calc_profit(Trade trade, bool show_labels) =>
label trade_info_label = na
label entry_hit_label = na
label tp1_hit_label = na
label tp2_hit_label = na
label tp3_hit_label = na
label tp4_hit_label = na
label sl_hit_label = na
label be_hit_label = na
float profit = 0.0
if trade.side == "LONG"
if low <= trade.entry_price and not trade.entry_hit
trade.start_bar_index := bar_index
trade.entry_hit := true
entry_hit_label := label.new(trade.start_bar_index, trade.entry_price, str.tostring("ENTRY HIT"), style = label.style_label_right)
trade_info_label := label.new(bar_index, high, "Trade info:" + "\nEntry: " + str.tostring(trade.entry_price) + "\nTp1: " + str.tostring(trade.tp1_price) + "\nTp2: " + str.tostring(trade.tp2_price) + "\nTp3:" + str.tostring(trade.tp3_price) + "\nTp4: " + str.tostring(trade.tp4_price) + "\nSl: " + str.tostring(trade.sl_price))
if high >= trade.tp1_price and not trade.tp1_hit and trade.entry_hit
trade.tp1_hit := true
trade.position_size_left -= trade.tp1_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp1_price) * trade.tp1_percent_fix / 100 * trade.risk_percent
tp1_hit_label := label.new(trade.start_bar_index, trade.tp1_price, str.tostring("TP1 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if high >= trade.tp2_price and not trade.tp2_hit and trade.entry_hit
trade.tp2_hit := true
trade.can_break_even := true
trade.position_size_left -= trade.tp2_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp2_price) * trade.tp2_percent_fix / 100 * trade.risk_percent
tp2_hit_label := label.new(trade.start_bar_index, trade.tp2_price, str.tostring("TP2 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if high >= trade.tp3_price and not trade.tp3_hit and trade.entry_hit
trade.tp3_hit := true
trade.position_size_left -= trade.tp3_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp3_price) * trade.tp3_percent_fix / 100 * trade.risk_percent
tp3_hit_label := label.new(trade.start_bar_index, trade.tp3_price, str.tostring("TP3 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if high >= trade.tp4_price and not trade.tp4_hit and trade.entry_hit
trade.tp4_hit := true
trade.is_closed := true
trade.position_size_left -= trade.tp4_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price) * trade.tp4_percent_fix / 100 * trade.risk_percent
tp4_hit_label := label.new(trade.start_bar_index, trade.tp4_price, str.tostring("TP4 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if high >= trade.break_even_price and not trade.can_break_even and trade.entry_hit
trade.can_break_even := true
//BE ENTRY HIT
if trade.can_break_even and trade.entry_hit
if low <= trade.entry_price and not (close >= open) and bar_index != trade.start_bar_index
trade.is_closed := true
be_hit_label := label.new(bar_index, trade.entry_price, str.tostring("BE HIT"), style = label.style_label_left)
// SL HIT
if low <= trade.sl_price and not trade.can_break_even and trade.entry_hit and bar_index != trade.start_bar_index
trade.sl_hit := true
trade.is_closed := true
profit += -trade.risk_percent * trade.position_size_left / 100
sl_hit_label := label.new(bar_index, trade.sl_price, str.tostring("SL HIT ") + str.tostring(profit, "#.##") + "%", color = color.red, style = label.style_label_left)
else
if high >= trade.entry_price and not trade.entry_hit
trade.start_bar_index := bar_index
trade.entry_hit := true
entry_hit_label := label.new(trade.start_bar_index, trade.entry_price, str.tostring("ENTRY HIT"), style = label.style_label_right)
trade_info_label := label.new(bar_index, high, "Trade info:" + "\nEntry: " + str.tostring(trade.entry_price) + "\nTp1: " + str.tostring(trade.tp1_price) + "\nTp2: " + str.tostring(trade.tp2_price) + "\nTp3:" + str.tostring(trade.tp3_price) + "\nTp4: " + str.tostring(trade.tp4_price) + "\nSl: " + str.tostring(trade.sl_price))
if low <= trade.tp1_price and not trade.tp1_hit and trade.entry_hit
trade.tp1_hit := true
trade.position_size_left -= trade.tp1_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp1_price) * trade.tp1_percent_fix / 100 * trade.risk_percent
tp1_hit_label := label.new(trade.start_bar_index, trade.tp1_price, str.tostring("TP1 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if low <= trade.tp2_price and not trade.tp2_hit and trade.entry_hit
trade.tp2_hit := true
trade.position_size_left -= trade.tp2_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp2_price) * trade.tp2_percent_fix / 100 * trade.risk_percent
tp2_hit_label := label.new(trade.start_bar_index, trade.tp2_price, str.tostring("TP2 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if low <= trade.tp3_price and not trade.tp3_hit and trade.entry_hit
trade.tp3_hit := true
trade.position_size_left -= trade.tp3_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp3_price) * trade.tp3_percent_fix / 100 * trade.risk_percent
tp3_hit_label := label.new(trade.start_bar_index, trade.tp3_price, str.tostring("TP3 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if low <= trade.tp4_price and not trade.tp4_hit and trade.entry_hit
trade.tp4_hit := true
trade.is_closed := true
trade.position_size_left -= trade.tp4_percent_fix
profit += calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price) * trade.tp4_percent_fix / 100 * trade.risk_percent
tp4_hit_label := label.new(trade.start_bar_index, trade.tp4_price, str.tostring("TP4 HIT +") + str.tostring(profit, "#.##") + "%" + "\nPosition size %: " + str.tostring(trade.position_size_left), style = label.style_label_right)
if low <= trade.break_even_price and not trade.can_break_even and trade.entry_hit
trade.can_break_even := true
//BE ENTRY HIT
if trade.can_break_even and trade.entry_hit
if high >= trade.entry_price and not (close <= open) and bar_index != trade.start_bar_index
trade.is_closed := true
be_hit_label := label.new(bar_index, trade.entry_price, str.tostring("BE HIT"), style = label.style_label_left)
// SL HIT
if high >= trade.sl_price and not trade.can_break_even and trade.entry_hit and bar_index != trade.start_bar_index
trade.sl_hit := true
trade.is_closed := true
profit += -trade.risk_percent * trade.position_size_left / 100
sl_hit_label := label.new(bar_index, trade.sl_price, str.tostring("SL HIT ") + str.tostring(profit, "#.##") + "%", color = color.red, style = label.style_label_left)
trade.profit += profit
if not show_labels
label.delete(entry_hit_label)
label.delete(tp1_hit_label)
label.delete(tp2_hit_label)
label.delete(tp3_hit_label)
label.delete(tp4_hit_label)
label.delete(sl_hit_label)
label.delete(be_hit_label)
label.delete(trade_info_label)
method close_trade(Trade trade, bool show_labels) =>
float profit = 0.0
label trade_closed_label = na
trade.force_closed := true
if not trade.sl_hit
if trade.side == "SHORT"
trade.is_closed := true
trade.close_price := close
if close <= trade.entry_price
percent_from_entry_to_close_price_at_trend_change = math.abs((close / trade.entry_price) * 100)
percent_from_entry_to_sl_price = math.abs((trade.entry_price / trade.sl_price) * 100)
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
else
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
string sign = profit >= 0 ? "+" : na
trade_closed_label := label.new(bar_index, high, str.tostring("TRADE CLOSED ") + sign + str.tostring(profit, "#.##") + "%")
else
trade.is_closed := true
trade.close_price := close
if close <= trade.entry_price
percent_from_entry_to_close_price_at_trend_change = math.abs((close / trade.entry_price - 1) * 100)
percent_from_entry_to_sl_price = math.abs((trade.entry_price / trade.sl_price - 1) * 100)
profit := -trade.risk_percent * (percent_from_entry_to_close_price_at_trend_change / percent_from_entry_to_sl_price) * trade.position_size_left / 100 + trade.profit
else
profit := calc_rr(trade.entry_price, trade.sl_price, close) * trade.position_size_left / 100 * trade.risk_percent
string sign = profit >= 0 ? "+" : na
trade_closed_label := label.new(bar_index, low, str.tostring("TRADE CLOSED ") + sign + str.tostring(profit, "#.##") + "%", style = label.style_label_up)
if not show_labels
label.delete(trade_closed_label)
trade.profit += profit
// TYPES AND METHODS
// STRATS
selector(string strategy_name) =>
strategy_settings = Strategy_settings.new()
switch strategy_name
"MANUAL" =>
strategy_settings.sensitivity := 18
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"UNIVERSAL 15m" =>
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"SOL 5m" =>
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
strategy_settings
// STRATS
string STRATEGIES = "STRATEGIES"
string POSITION = "POSITION"
string ENTRY = "ENTRY"
string TAKE_PROFITS = "TAKE PROFITS"
string STOP_LOSS = "STOPLOSS"
string rsi_group = "RSI"
string main_group = "MAIN"
string info_panel_group = "INFOPANELS"
string dev_settings = "DEVELOPER MODE"
int fibo_lines_transparend = 60
int fill_best_transparend = 95
int fill_worst_transparend = 98
color high_line_color = color.rgb(36, 255, 44, fibo_lines_transparend)
color fib_236_color = color.rgb(130, 228, 74, fibo_lines_transparend)
color fib_382_color = color.rgb(171, 224, 174, fibo_lines_transparend)
color fib_618_color = color.rgb(235, 255, 51, fibo_lines_transparend)
color fib_786_color = color.rgb(255, 131, 73, fibo_lines_transparend)
color low_line_color = color.rgb(255, 82, 82, fibo_lines_transparend)
color high_best_fill_color = color.rgb(48, 255, 55, fill_best_transparend)
color high_worst_fill_color = color.rgb(37, 255, 44, fill_worst_transparend)
color low_best_fill_color = color.rgb(255, 54, 54, fill_best_transparend)
color low_worst_fill_color = color.rgb(255, 43, 43, fill_worst_transparend)
tp_sl_entry_transparent = 30
color tp_color = color.new(color.green, tp_sl_entry_transparent)
color entry_color = color.rgb(120, 123, 134, tp_sl_entry_transparent)
color sl_color = color.new(color.red, tp_sl_entry_transparent)
line_style = line.style_dotted
//@version=5
indicator(title='[IMBA] ALGO', shorttitle='[IMBA] ALGO', overlay=true, max_lines_count = 500, max_labels_count = 500, max_bars_back = 1)
//---------------------------------------------------SETTINGS----------------------------------------------------------\\
// STRATS
var float sensitivity = 18
float risk_percent = 1
string break_even_target = "2"
float tp1_percent = 0
float tp1_percent_fix = 0
float tp2_percent = 0
float tp2_percent_fix = 0
float tp3_percent = 0
float tp3_percent_fix = 0
float tp4_percent = 0
float tp4_percent_fix = 0
bool fixed_stop = false
float sl_percent = 0
strategy_input = input.string(title = "STRATEGY", options = [
"MANUAL",
"UNIVERSAL 15m",
"===============",
"-------A-------",
"-------B-------",
"-------C-------",
"-------D-------",
"-------E-------",
"-------F-------",
"-------G-------",
"-------H-------",
"-------I-------",
"-------J-------",
"-------K-------",
"-------L-------",
"-------M-------",
"-------N-------",
"-------O-------",
"-------P-------",
"-------Q-------",
"-------R-------",
"-------S-------",
"SOL 5m",
"-------T-------",
"-------U-------",
"-------V-------",
"-------W-------",
"-------X-------",
"-------Y-------",
"-------Z-------"
], defval = "MANUAL", tooltip = "EN:\nTo manually configure the strategy, select MANUAL otherwise, changing the settings won't have any effect\nRU:\nЧтобы настроить стратегию вручную, выберите MANUAL в противном случае изменение настроек не будет иметь никакого эффекта")
// MAIN
sensitivity_input = input.float(title = 'Sensitive', step = 0.1, defval = 18)
start_date_input = input.time(defval = timestamp("1 June 2023"), title = "Start calculating date")
// POSITION
show_tp_enty_sl = input.bool(defval = true, title = "Show", group = POSITION, inline = "2.1")
fill_positions = input.bool(defval = true, title = "Fill", group = POSITION, inline = "2.1")
risk_percent_input = input.float(title = "Risk %", step = 1, defval = 1, group = POSITION, tooltip = "EN:\nMaximum allowable loss % of the deposit per 1 trade\nRU:\nМаксимально допустимая потеря % от депозита на 1 сделку")
break_even_target_input = input.string(title = "BE target", options = ["WITHOUT","1","2","3"], defval = "1", group = POSITION)
initial_deposit_input = input.float(title = "Initial deposit", defval = 1000, step = 100, group = POSITION)
// STOPLOSS
fixed_stop_input = input.bool(defval = false, title = "Fixed stoploss %", group = STOP_LOSS, tooltip = "EN:\nIf choosed: stoploss will be calculated manually \nIf NOT choosed: stoploss will be calculated automatic\nRU:\nЕсли выбрано: стоп будет рассчитываться вручную \nЕсли НЕ выбрано: стоп будет рассчитываться автоматически")
sl_percent_input = input.float(title="SL %", step = 0.1, defval=0.00, group = STOP_LOSS)
// TAKE PROFITS
tp1_percent_input = input.float(title="TP 1", step = 0.05, defval=1.00, minval = 0, group = TAKE_PROFITS, inline = "2.2")
tp1_percent_fix_input = input.float(title = "Fix %", step = 5, defval=40, group = TAKE_PROFITS, inline = "2.2")
tp2_percent_input = input.float(title="TP 2", step = 0.05, defval=2.00, minval = 0, group = TAKE_PROFITS, inline = "2.3")
tp2_percent_fix_input = input.float(title = "Fix %", step = 5, defval=30, group = TAKE_PROFITS, inline = "2.3")
tp3_percent_input = input.float(title="TP 3", step = 0.05, defval=3.00, minval = 0, group = TAKE_PROFITS, inline = "2.4")
tp3_percent_fix_input = input.float(title = "Fix %", step = 5, defval=20, group = TAKE_PROFITS, inline = "2.4")
tp4_percent_input = input.float(title="TP 4", step = 0.05, defval=4.00, minval = 0, group = TAKE_PROFITS, inline = "2.5")
tp4_percent_fix_input = input.float(title = "Fix %", step = 5, defval=10, group = TAKE_PROFITS, inline = "2.5")
// RSI
show_rsi = input.bool(defval = false, title = "Show", group = rsi_group, inline = "3.1")
len = input(title="Length", defval=14, group = rsi_group, inline = "3.2")
overbought = input(title="Overbought", defval=78, group = rsi_group, inline = "3.3")
oversold = input(title="Oversold", defval=22, group = rsi_group, inline = "3.3")
// INFO PANEL
show_profit_panel = input.bool(defval = true, title = "Show profit panel", group = info_panel_group)
show_strategy_panel = input.bool(defval = false, title = "Show strategy panel", group = info_panel_group)
show_old_panel = input.bool(defval = false, title = "Show old panel", group = info_panel_group)
// DEV
show_dev_labels = input.bool(defval = false, title = "Show", group = dev_settings, tooltip = "Shows all possible events")
//-----------------------------------------------GLOBAL VARIABLES------------------------------------------------------\\
var float total_profit = 0.0
var int trade_count = 0
var int profit_trades = 0
var int loss_trades = 0
var int loss_streak = 0
var int loss_in_a_row = 0
var int win_streak = 0
var int wins_in_a_row = 0
var int first_trade_date = na
var Trade trade = na
var bool is_long_trend_started = false
var bool is_short_trend_started = false
var bool is_trend_change = na
var bool is_long_trend = false
var bool is_short_trend = false
var bool can_long = false
var bool can_short = false
var int trend_started_bar_index = na
var line tp1_line = na
var label tp1_label = na
var line tp2_line = na
var label tp2_label = na
var line tp3_line = na
var label tp3_label = na
var line tp4_line = na
var label tp4_label = na
var line entry_line = na
var label entry_label = na
var line close_line = na
var line sl_line = na
var label sl_label = na
var label lable_at_signal = na
var int signal_closed_bar = na
var Strategy_settings strategy_s = na
var float dep = initial_deposit_input
//-----------------------------------------------------MAIN------------------------------------------------------------\\
// STRATEGY
strategy_s := strategy_input == "MANUAL" ? Strategy_settings.new(sensitivity_input, risk_percent_input, break_even_target_input, tp1_percent_input, tp1_percent_fix_input, tp2_percent_input, tp2_percent_fix_input, tp3_percent_input, tp3_percent_fix_input, tp4_percent_input, tp4_percent_fix_input, fixed_stop_input, sl_percent_input) : selector(strategy_input)
sensitivity := strategy_s.sensitivity
risk_percent := strategy_s.risk_percent
break_even_target := strategy_s.break_even_target
tp1_percent := strategy_s.tp1_percent
tp1_percent_fix := strategy_s.tp1_percent_fix
tp2_percent := strategy_s.tp2_percent
tp2_percent_fix := strategy_s.tp2_percent_fix
tp3_percent := strategy_s.tp3_percent
tp3_percent_fix := strategy_s.tp3_percent_fix
tp4_percent := strategy_s.tp4_percent
tp4_percent_fix := strategy_s.tp4_percent_fix
fixed_stop := strategy_s.fixed_stop
sl_percent := strategy_s.sl_percent
sensitivity *= 10
tp1_percent /= 100
tp2_percent /= 100
tp3_percent /= 100
tp4_percent /= 100
tp1_percent_fix /= 100
tp2_percent_fix /= 100
tp3_percent_fix /= 100
tp4_percent_fix /= 100
sl_percent /= 100
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
fib_236 = high_line - channel_range * (0.236)
fib_382 = high_line - channel_range * 0.382
fib_5 = high_line - channel_range * 0.5
fib_618 = high_line - channel_range * 0.618
fib_786 = high_line - channel_range * (0.786)
imba_trend_line = fib_5
// CAN LONG/SHORT
if time >= start_date_input
can_long := close >= imba_trend_line and close >= fib_236 and not is_long_trend
can_short := close <= imba_trend_line and close <= fib_786 and not is_short_trend
if can_long
is_long_trend := true
is_short_trend := false
is_long_trend_started := is_long_trend_started ? false : true
else if can_short
is_short_trend := true
is_long_trend := false
is_short_trend_started := is_short_trend_started ? false : true
else
is_trend_change := false
can_long := false
can_short := false
is_short_trend_started := false
is_long_trend_started := false
is_trend_change := is_short_trend_started or is_long_trend_started
plotshape(is_long_trend and is_long_trend_started ? imba_trend_line : na, title="Long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(is_short_trend and is_short_trend_started ? imba_trend_line : na, title="Short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plot(imba_trend_line, color = is_long_trend[1] ? color.green : color.red, linewidth = 3)
// LOGIC
if not na(trade)
calc_profit(trade, show_dev_labels)
if is_trend_change and not trade.is_closed
close_trade(trade, show_dev_labels)
if not trade.is_closed
label.set_x(entry_label, bar_index - 3)
label.set_text(entry_label, str.tostring(trade.side == "LONG" ? "🔰" : "🔰") + str.tostring(trade.entry_price))
label.set_x(sl_label, bar_index - 3)
label.set_text(sl_label, "⛔" + str.tostring(trade.sl_price))
label.set_x(tp1_label, bar_index - 3)
label.set_text(tp1_label, str.tostring(trade.tp1_hit ? "✅" : "1️⃣") + str.tostring(trade.tp1_price))
label.set_x(tp2_label, bar_index - 3)
label.set_text(tp2_label, str.tostring(trade.tp2_hit ? "✅" : "2️⃣") + str.tostring(trade.tp2_price))
label.set_x(tp3_label, bar_index - 3)
label.set_text(tp3_label, str.tostring(trade.tp3_hit ? "✅" : "3️⃣") + str.tostring(trade.tp3_price))
label.set_x(tp4_label, bar_index - 3)
label.set_text(tp4_label, str.tostring(trade.tp4_hit ? "✅" : "4️⃣") + str.tostring(trade.tp4_price))
line.set_xy1(tp1_line, trade.start_bar_index, trade.tp1_price)
line.set_xy2(tp1_line, bar_index + 1, trade.tp1_price)
line.set_xy1(tp2_line, trade.start_bar_index, trade.tp2_price)
line.set_xy2(tp2_line, bar_index + 1, trade.tp2_price)
line.set_xy1(tp3_line, trade.start_bar_index, trade.tp3_price)
line.set_xy2(tp3_line, bar_index + 1, trade.tp3_price)
line.set_xy1(tp4_line, trade.start_bar_index, trade.tp4_price)
line.set_xy2(tp4_line, bar_index + 1, trade.tp4_price)
line.set_xy1(entry_line, trade.start_bar_index, trade.entry_price)
line.set_xy2(entry_line, bar_index + 1, trade.entry_price)
line.set_xy1(sl_line, trade.start_bar_index, trade.sl_price)
line.set_xy2(sl_line, bar_index + 1, trade.sl_price)
lable_at_signal.set_x(int(math.avg(bar_index, trade.start_bar_index)))
sign = trade.profit >= 0 ? "+" : na
lable_at_signal.set_text(sign + str.tostring(trade.profit, "#.##") + "%")
lable_at_signal.set_color(trade.profit >= 0 ? color.green : color.red)
// FILLING
if fill_positions
if trade.tp1_hit
linefill.new(entry_line, tp1_line, color = color.new(color.green, 85))
if trade.tp2_hit
linefill.new(tp1_line, tp2_line, color = color.new(color.green, 85))
if trade.tp3_hit
linefill.new(tp2_line, tp3_line, color = color.new(color.green, 85))
if trade.tp4_hit
linefill.new(tp3_line, tp4_line, color = color.new(color.green, 85))
if trade.sl_hit
linefill.new(sl_line, entry_line, color = color.new(color.red, 85))
if trade.force_closed
close_line := line.new(x1=trade.start_bar_index, y1=trade.close_price, x2=bar_index, y2=trade.close_price, color=color.white, style = line_style, width = 2)
if trade.profit <= 0
linefill.new(close_line, entry_line, color = color.new(color.red, 85))
if trade.is_closed
dep := (trade.profit / 100 * dep) + dep
label.delete(entry_label)
label.delete(sl_label)
label.delete(tp1_label)
label.delete(tp2_label)
label.delete(tp3_label)
label.delete(tp4_label)
total_profit += trade.profit
trade_count += 1
if trade.profit >= 0
profit_trades += 1
wins_in_a_row += 1
loss_in_a_row := 0
win_streak := wins_in_a_row > win_streak ? wins_in_a_row : win_streak
else
loss_trades += 1
loss_in_a_row += 1
wins_in_a_row := 0
loss_streak := loss_in_a_row > loss_streak ? loss_in_a_row : loss_streak
trade := na
alertcondition(can_long and na(trade), "Long signal", "Long")
alertcondition(can_short and na(trade), "Short signal", "Short")
alertcondition(can_short or can_long and na(trade), "New signal", "Check chart to see signal direction")
if can_long or can_short and na(trade)
first_trade_date := trade_count == 0 ? timestamp(year, month, dayofmonth, hour, minute) : first_trade_date
trade := Trade.new()
trade.side := can_long ? "LONG" : "SHORT"
trade.entry_price := close
trade.entry_hit := true
trade.sl_price := math.round_to_mintick(can_long ? fixed_stop ? trade.entry_price * (1 - sl_percent) : fib_786 * (1 - sl_percent) : fixed_stop ? trade.entry_price * (1 + sl_percent) : fib_236 * (1 + sl_percent))
trade.tp1_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp1_percent) : trade.entry_price * (1 - tp1_percent))
trade.tp1_percent_fix := tp1_percent_fix * 100
trade.tp2_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp2_percent) : trade.entry_price * (1 - tp2_percent))
trade.tp2_percent_fix := tp2_percent_fix * 100
trade.tp3_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp3_percent) : trade.entry_price * (1 - tp3_percent))
trade.tp3_percent_fix := tp3_percent_fix * 100
trade.tp4_price := math.round_to_mintick(can_long ? trade.entry_price * (1 + tp4_percent) : trade.entry_price * (1 - tp4_percent))
trade.tp4_percent_fix := tp4_percent_fix * 100
trade.break_even_price := switch break_even_target
"1" => trade.tp1_price
"2" => trade.tp2_price
"3" => trade.tp3_price
"WITHOUT" => trade.tp4_price
trade.risk_percent := risk_percent
trade.risk_reward := calc_rr(trade.entry_price, trade.sl_price, trade.tp4_price)
trade.start_bar_index := bar_index
alert_message = "\n{\n" + " \"side\": \"" + str.tostring(trade.side) + "\",\n \"entry\": \"" + str.tostring(trade.entry_price) + "\",\n \"tp1\": \"" + str.tostring(trade.tp1_price) + "\",\n \"tp2\": \"" + str.tostring(trade.tp2_price) + "\",\n \"tp3\": \"" + str.tostring(trade.tp3_price) + "\",\n \"tp4\": \"" + str.tostring(trade.tp4_price) + "\",\n \"winrate\": \"" + str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%" + "\",\n \"strategy\": \"" + strategy_input + "\",\n \"beTargetTrigger\": \"" + break_even_target + "\",\n \"stop\": \"" + str.tostring(trade.sl_price) + "\"\n}\n"
alert(alert_message, alert.freq_once_per_bar_close)
if show_tp_enty_sl
entry_line := line.new(x1=trade.start_bar_index, y1=trade.entry_price, x2=bar_index, y2=trade.entry_price, color=entry_color, style = line.style_solid, width = 2)
entry_label := label.new(bar_index, trade.entry_price, str.tostring(trade.entry_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.gray)
sl_line := line.new(x1=trade.start_bar_index, y1=trade.sl_price, x2=bar_index, y2=trade.sl_price, color=sl_color, style = line_style, width = 2)
sl_label := label.new(bar_index, trade.sl_price, str.tostring(trade.sl_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.red)
tp1_line := line.new(x1=trade.start_bar_index, y1=trade.tp1_price, x2=bar_index, y2=trade.tp1_price, color=tp_color, style = line_style, width = 2)
tp1_label := label.new(bar_index, trade.tp1_price, str.tostring(trade.tp1_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.green)
tp2_line := line.new(x1=trade.start_bar_index, y1=trade.tp2_price, x2=bar_index, y2=trade.tp2_price, color=tp_color, style = line_style, width = 2)
tp2_label := label.new(bar_index, trade.tp2_price, str.tostring(trade.tp2_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.green)
tp3_line := line.new(x1=trade.start_bar_index, y1=trade.tp3_price, x2=bar_index, y2=trade.tp3_price, color=tp_color, style = line_style, width = 2)
tp3_label := label.new(bar_index, trade.tp3_price, str.tostring(trade.tp3_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.green)
tp4_line := line.new(x1=trade.start_bar_index, y1=trade.tp4_price, x2=bar_index, y2=trade.tp4_price, color=tp_color, style = line_style, width = 2)
tp4_label := label.new(bar_index, trade.tp4_price, str.tostring(trade.tp4_price), style = label.style_label_left, color = color.rgb(255, 255, 255, 100), textcolor = color.green)
lable_at_signal := label.new(bar_index, is_long_trend ? trade.tp4_price * 1.004 : trade.tp4_price * 0.996, "", style = label.style_label_center, textcolor = color.white)
//------------------------------------------------------RSI------------------------------------------------------------\\
rsi_value = ta.rsi(close, len)
is_overbought = rsi_value >= overbought
is_oversold = rsi_value <= oversold
plotshape(is_overbought and show_rsi ? high : na, color=color.red, style=shape.cross, size=size.tiny, location=location.abovebar)
plotshape(is_oversold and show_rsi ? low : na, color=color.green, style=shape.cross, size=size.tiny, location=location.belowbar)
//-----------------------------------------------------PANELS------------------------------------------------------------\\
lim = "-------------------------------------------------------"
high_idk = "╔════════════════════════════╗"
low_idk = "╚════════════════════════════╝"
panel_str1 = high_idk + "\n" + "[IMBA] ALGO" + "\n" + low_idk
panel_str13 = "First signal: " + str.format("{0,date,hh:mm} {0,date,long}", first_trade_date) + "\n" + lim
panel_str14 = "Signal closed: " + str.tostring(trade_count) + " " + "Winrate: " + str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%"
panel_str15 = "Profit signals: " + str.tostring(profit_trades) + " " + "Loss signals: " + str.tostring(trade_count - profit_trades)
panel_str16 = "Win streak: " + str.tostring(win_streak) + " " + "Loss streak: " + str.tostring(loss_streak) + "\n" + lim
panel_str17 = "💰 Profit: " + str.tostring(total_profit, "#.##") + "% 💰"
panel_last = "╚════════════════════════════╝"
panel_str_arr = array.from(panel_str1, panel_str13, panel_str14, panel_str15, panel_str16, panel_str17, panel_last)
if show_old_panel
label l = label.new(bar_index + 20, close, text=array.join(panel_str_arr, "\n"), color=color.rgb(0, 0, 0, 87), style=label.style_label_left, textcolor=color.rgb(76, 187, 72),textalign=text.align_center)
label.delete(l[1])
var table profit_table = na
if show_profit_panel
profit_table := table.new(position.top_right, 3, 10, border_color = color.green, border_width = 0)
table.cell(profit_table, 0, 0, "═════════════════════════════" + "\n" + "[IMBA] ALGO" + "\n" + "═════════════════════════════", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 5, text_size = size.normal)
table.cell(profit_table, 1, 0, "", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal)
table.merge_cells(profit_table, 0,0,1,0)
table.cell(profit_table, 0, 1, "First trade:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 8, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 1, str.format("{0,date,long}", first_trade_date), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 8, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 2, "Total trades:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 2, str.tostring(trade_count), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 3, "Profit trades:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 3, str.tostring(profit_trades), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 4, "Loss trades:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 4, str.tostring(loss_trades), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 5, "Winrate:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 5, str.tostring(RoundUp(profit_trades / trade_count * 100, 2)) + "%", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 6, "Win streak:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 6, str.tostring(win_streak), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 7, "Loss streak:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 7, str.tostring(loss_streak), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 8, "Deposit: ", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(profit_table, 1, 8, str.tostring(dep, "##.##"), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(profit_table, 0, 9, "═════════════════════════════" + "\n" + "💰 Profit: " + str.tostring(total_profit, "#.##") + "% 💰" + "\n" + "═════════════════════════════", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 10, text_size = size.normal, text_halign = text.align_center, text_valign = text.align_top)
table.cell(profit_table, 1, 9,"", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.merge_cells(profit_table, 0, 9, 1, 9)
var table strategy_table = na
if show_strategy_panel
strategy_table := table.new(position.bottom_right, 5, 6, border_color = color.green)
table.cell(strategy_table, 1, 0, "══════════════════════════════════════════" + "\n" + syminfo.ticker + " " + timeframe.period + " | WR: " + str.tostring(profit_trades / (profit_trades + (trade_count - profit_trades)) * 100, "##,##") + "%" + " | TT: " + str.tostring(trade_count) + " | P: " + str.tostring(total_profit, "#.##") + "%" + "\n" + "══════════════════════════════════════════", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 7, text_size = size.normal, text_valign = text.align_bottom)
table.cell(strategy_table, 2, 0, "", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 0, "", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 0, "", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal)
table.merge_cells(strategy_table, 1,0,4,0)
table.cell(strategy_table, 1, 1, "Strategy:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(strategy_table, 2, 1, strategy_input, bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 6, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 2, "Sensitivity:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(strategy_table, 2, 2, str.tostring(sensitivity / 10), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 3, "Risk:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(strategy_table, 2, 3, str.tostring(risk_percent) + "%", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 4, "BE target:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(strategy_table, 2, 4, str.tostring(break_even_target), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 1, 5, "Fixed stop:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal, text_halign = text.align_left)
table.cell(strategy_table, 2, 5, str.tostring(fixed_stop), bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 1, "TP1:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 1, str.tostring(tp1_percent * 100) + "%" + " (" + str.tostring(tp1_percent_fix * 100) + "%)", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 2, "TP2:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 2, str.tostring(tp2_percent * 100) + "%" + " (" + str.tostring(tp2_percent_fix * 100) + "%)", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 3, "TP3:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 3, str.tostring(tp3_percent * 100) + "%" + " (" + str.tostring(tp3_percent_fix * 100) + "%)", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 4, "TP4:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 4, str.tostring(tp4_percent * 100) + "%" + " (" + str.tostring(tp4_percent_fix * 100) + "%)", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 5, height = 3, text_size = size.normal)
table.cell(strategy_table, 3, 5, "Stop:", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 4, height = 3, text_size = size.normal)
table.cell(strategy_table, 4, 5, str.tostring(sl_percent * 100) + "%", bgcolor = color.rgb(0, 0, 0, 87), text_color = color.green, width = 8, height = 3, text_size = size.normal)
@@ -0,0 +1,39 @@
//@version=4
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Parabolic SAR script may be freely distributed under the terms of the GPL-3.0 license.
study("Parabolic SAR", shorttitle="PSAR", overlay=true)
start = input(title="Start", type=input.float, step=0.001, defval=0.02)
increment = input(title="Increment", type=input.float, step=0.001, defval=0.02)
maximum = input(title="Maximum", type=input.float, step=0.01, defval=0.2)
width = input(title="Point Width", type=input.integer, minval=1, defval=2)
highlightStartPoints = input(title="Highlight Start Points ?", type=input.bool, defval=true)
showLabels = input(title="Show Buy/Sell Labels ?", type=input.bool, defval=true)
highlightState = input(title="Highlight State ?", type=input.bool, defval=true)
psar = sar(start, increment, maximum)
dir = psar < close ? 1 : -1
psarColor = dir == 1 ? #3388bb : #fdcc02
psarPlot = plot(psar, title="PSAR", style=plot.style_circles, linewidth=width, color=psarColor, transp=0)
var color longColor = color.green
var color shortColor = color.red
buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal and highlightStartPoints ? psar : na, title="Long Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor, transp=0)
plotshape(buySignal and showLabels ? psar : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.white, transp=0)
sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal and highlightStartPoints ? psar : na, title="Short Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor, transp=0)
plotshape(sellSignal and showLabels ? psar : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.white, transp=0)
midPricePlot = plot(ohlc4, title="", display=display.none)
fillColor = highlightState ? (dir == 1 ? longColor : shortColor) : na
fill(midPricePlot, psarPlot, title="Trade State Filling", color=fillColor)
changeCond = dir != dir[1]
alertcondition(changeCond, title="Alert: PSAR Direction Change", message="PSAR has changed direction!")
alertcondition(buySignal, title="Alert: PSAR Long", message="PSAR Long")
alertcondition(sellSignal, title="Alert: PSAR Short", message="PSAR Sell")
@@ -0,0 +1,273 @@
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ChartPrime
//@version=5
indicator("Trendline Breakouts With Targets [ Chartprime ]",shorttitle = "TBT [ Chartprime ]",overlay = true,max_bars_back = 500,max_lines_count = 500)
bool ChartTime = time > chart.left_visible_bar_time and time < chart.right_visible_bar_time
string CORE = "➞ Core Settings 🔸"
var bool TradeisON = false
var bool LongTrade = false
var bool ShortTrade = false
var float TP = 0.0
var float SL = 0.0
int BarTIME = time - time[1]
var line tpLine = na
var label LAB = na
var int UpdatedX = 0
var float UpdatedY = 0.0
var float UpdatedSLP = 0.0
var int UpdatedXLow = 0
var float UpdatedYLow = 0.0
var float UpdatedSLPLow = 0.0
int Period = input.int(10, title='     Period     ➞',
group = CORE,
inline = "001")
bool Trendtype = input.string(title = "     Type        ➞",
defval='Wicks',
options=['Wicks', 'Body'],
group = CORE,
inline = "001")
== 'Wicks'
string Extensions = input.string(title='     Extend    ➞',
defval=' 25',
options=[' 25', ' 50', ' 75'],
group = CORE,
inline = "001")
color LineCol1 = input.color(color.rgb(109, 111, 111, 19),"",group = CORE,inline = "001")
bool ShowTargets = input.bool(true,"Show Targets",group = CORE,inline = "002")
ExtenSwitcher(ex) =>
switch ex
' 25' => 1 ,
' 50' => 2 ,
=> 3
WidthSwitcher(ex) =>
switch ex
'1' => 1 ,
'2' => 2 ,
=> 3
StyleSwitcher(style) =>
switch style
'Dashed' => line.style_dashed ,
'Dotted' => line.style_dotted ,
=> line.style_solid
method volAdj(int len)=>
math.min(ta.atr(len) * 0.3, close * (0.3/100)) [20] /2
Zband = volAdj(30)
method Trendlines(float src, int timeIndex,bool dir) =>
var int Start = 1 , var int End = 0 , var int TIME = 1
var float YEnd = 0, var float YStart = 0 , var float Slope = 0
var line Line1 = line.new(na,na,na,na)
var line Line2 = line.new(na,na,na,na)
var line Line3 = line.new(na,na,na,na)
SCR = fixnan(src)
if ta.change(SCR) != 0
TIME := time[timeIndex]
YStart := SCR[1]
Start := TIME[1]
Slope := (SCR - YStart) / (TIME - Start)
Slope
EXTime = ExtenSwitcher(Extensions) * BarTIME * 25
End := TIME + EXTime
YEnd := SCR + EXTime * Slope
if ta.change(SCR) != 0 and not TradeisON[1]
LineCond = Slope * time < 0 ? dir ? na : color.rgb(11, 139, 7, 53) : dir ? color.rgb(212, 46, 0, 54) : na
if not na(LineCond) //and ChartTime
Line1 := line.new(Start,
YStart,
End,
YEnd,
xloc.bar_time,
extend.none,
color=color.new(color.white,100)
)
Line2:=line.new(Start,
YStart - (Zband * 2),
End,
YEnd - (Zband * 2),
xloc.bar_time,
extend.none,
color=color.new(color.black,100)
)
Line3:=line.new(Start,
YStart - (Zband * 1),
End,
YEnd - (Zband * 1),
xloc.bar_time,
extend.none,
color=color.new(color.black,100)
)
linefill.new(Line3,Line2,color= LineCol1)
linefill.new(Line3,Line1,color= LineCond)
// linefill.new(Line,Line2,color= color.rgb(28, 15, 2, 76))
[Start, YStart, Slope]
PH = ta.pivothigh(Trendtype ? high : close > open ? close : open, Period, Period / 2)
PL = ta.pivotlow(Trendtype ? low : close > open ? open : close, Period, Period / 2)
method GetlinePrice(int TIME, float Price, float SLOP, int LookB) =>
var float Current = 0.0
EsTime = time - TIME
Current := Price + (EsTime - LookB * BarTIME) * SLOP
Current
method CheckCross(float Price, int StartTime, float StartPrice, float SLP) =>
var float Current = 0.0
var float Previous = 0.0
if StartPrice[Period] != StartPrice
Current := GetlinePrice(StartTime, StartPrice, SLP, 0)
Previous := GetlinePrice(StartTime, StartPrice, SLP, 1)
Crossover = Price[1] < Previous and Price > Current ? 1 : Price[1] > Previous - (Zband*0.1) and Price < Current - (Zband*0.1) ? -1 : 0
Crossover
[Xx, XZ, SLPXZ] = Trendlines(PH, Period / 2,false)
[XxL, XZL, SLPXZL] = Trendlines(PL, Period / 2, true)
if ta.change(fixnan(PH)) != 0
UpdatedX := Xx
UpdatedY := XZ
UpdatedSLP := SLPXZ
UpdatedSLP
if ta.change(fixnan(PL)) != 0
UpdatedXLow := XxL
UpdatedYLow := XZL
UpdatedSLPLow := SLPXZL
UpdatedSLPLow
Long = not (UpdatedSLP * time > 0)
and CheckCross(close, UpdatedX, UpdatedY, UpdatedSLP)== 1
and not TradeisON
Short = not (UpdatedSLPLow * time < 0)
and CheckCross(close, UpdatedXLow, UpdatedYLow, UpdatedSLPLow)==-1
and not TradeisON
TradeFire = Long or Short
if Long and not TradeisON
LongTrade:= true
ShortTrade:= false
if Short and not TradeisON
LongTrade:= false
ShortTrade:= true
if true
if TradeFire and not TradeisON
TP := switch
Long => high + (Zband *20)
Short => low - (Zband *20)
SL := switch
Long => low - (Zband *20)
Short => high + (Zband *20)
TradeisON:= true
if ShowTargets
line.new(bar_index,
Long ? high : low,
bar_index,
TP,
width=2,
color = color.rgb(154, 103, 20),
style= line.style_dashed)
tpLine:= line.new(bar_index,
TP,
bar_index+2,
TP,
style= line.style_dashed,
color = color.rgb(154, 103, 20)
)
LAB:=label.new(bar_index,
TP,
"Target",
color = color.rgb(154, 103, 20),
style= label.style_label_left,
size=size.small,
textcolor = color.white
)
if TradeisON
line.set_x2(tpLine,bar_index)
label.set_x(LAB,bar_index+1)
if LongTrade and TradeisON
if high >= TP
label.set_color(LAB,color.rgb(6, 128, 10, 37))
TradeisON:=false
if close <= SL
label.set_color(LAB,color.new(color.rgb(246, 7, 7),70))
TradeisON:=false
else if ShortTrade and TradeisON
if low <= TP
label.set_color(LAB,color.rgb(6, 128, 10, 37))
TradeisON:=false
if close >= SL
label.set_color(LAB,color.new(color.rgb(246, 7, 7),70))
TradeisON:=false
plotshape(Long and not TradeisON[1],
size = size.small,
color = color.rgb(46, 192, 6, 11),
location = location.belowbar,
style = shape.labelup ,
text = "",
textcolor = color.white)
plotshape(Short and not TradeisON[1],
size = size.small,
color = color.rgb(241, 2, 2, 11),
location = location.abovebar,
style = shape.labeldown ,
text = "",
textcolor = color.white)
// -- END -- .
+21
View File
@@ -0,0 +1,21 @@
//@version=5
indicator(title="Moving Average Simple", shorttitle="SMA", overlay=true, timeframe="", timeframe_gaps=true)
len = input.int(9, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500, display = display.data_window)
out = ta.sma(src, len)
plot(out, color=color.blue, title="MA", offset=offset)
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing", display = display.data_window)
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing", display = display.data_window)
smoothingLine = ma(out, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
@@ -0,0 +1,22 @@
//@version=2
study(title = "Smoothed Heiken Ashi Candles", shorttitle="Smoothed Ha Candles", overlay=true)
len=input(10)
o=ema(open,len)
c=ema(close,len)
h=ema(high,len)
l=ema(low,len)
haclose = (o+h+l+c)/4
haopen = na(haopen[1]) ? (o + c)/2 : (haopen[1] + haclose[1]) / 2
hahigh = max (h, max(haopen,haclose))
halow = min (l, min(haopen,haclose))
len2=input(10)
o2=ema(haopen, len2)
c2=ema(haclose, len2)
h2=ema(hahigh, len2)
l2=ema(halow, len2)
col=o2>c2 ? red : lime
plotcandle(o2, h2, l2, c2, title="heikin smoothed", color=col)
+37
View File
@@ -0,0 +1,37 @@
//@version=4
study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
+19
View File
@@ -0,0 +1,19 @@
//@version=5
indicator("Supertrend", overlay = true, timeframe = "", timeframe_gaps = true)
atrPeriod = input.int(10, "ATR Length", minval = 1)
factor = input.float(3.0, "Factor", minval = 0.01, step = 0.01)
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
supertrend := barstate.isfirst ? na : supertrend
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style = plot.style_linebr)
downTrend = plot(direction < 0 ? na : supertrend, "Down Trend", color = color.red, style = plot.style_linebr)
bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle",display = display.none)
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps = false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps = false)
alertcondition(direction[1] > direction, title='Downtrend to Uptrend', message='The Supertrend value switched from Downtrend to Uptrend ')
alertcondition(direction[1] < direction, title='Uptrend to Downtrend', message='The Supertrend value switched from Uptrend to Downtrend')
alertcondition(direction[1] != direction, title='Trend Change', message='The Supertrend value switched from Uptrend to Downtrend or vice versa')
@@ -0,0 +1,146 @@
//@version=5
indicator('SuperTrended Moving Averages', 'ST MA', overlay=true, format=format.price, precision=2, timeframe='', timeframe_gaps=false)
src = input(close, title='Source')
mav = input.string(title='Moving Average Type', defval='EMA', options=['SMA', 'EMA', 'WMA', 'DEMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF', 'HULL', 'TILL'])
length = input.int(100, 'Moving Average Length', minval=1)
Periods = input(title='ATR Period', defval=10)
Multiplier = input.float(title='ATR Multiplier', step=0.1, defval=0.5)
changeATR = input(title='Change ATR Calculation Method ?', defval=true)
showsignals = input(title='Show Buy/Sell Signals ?', defval=false)
highlighting = input(title='Highlighter On/Off ?', defval=true)
T3a1 = input.float(0.7, 'TILLSON T3 Volume Factor', step=0.1)
Var_Func(src, length) =>
valpha = 2 / (length + 1)
vud1 = src > src[1] ? src - src[1] : 0
vdd1 = src < src[1] ? src[1] - src : 0
vUD = math.sum(vud1, 9)
vDD = math.sum(vdd1, 9)
vCMO = nz((vUD - vDD) / (vUD + vDD))
VAR = 0.0
VAR := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) * nz(VAR[1])
VAR
VAR = Var_Func(src, length)
DEMA = 2 * ta.ema(src, length) - ta.ema(ta.ema(src, length), length)
Wwma_Func(src, length) =>
wwalpha = 1 / length
WWMA = 0.0
WWMA := wwalpha * src + (1 - wwalpha) * nz(WWMA[1])
WWMA
WWMA = Wwma_Func(src, length)
Zlema_Func(src, length) =>
zxLag = length / 2 == math.round(length / 2) ? length / 2 : (length - 1) / 2
zxEMAData = src + src - src[zxLag]
ZLEMA = ta.ema(zxEMAData, length)
ZLEMA
ZLEMA = Zlema_Func(src, length)
Tsf_Func(src, length) =>
lrc = ta.linreg(src, length, 0)
lrc1 = ta.linreg(src, length, 1)
lrs = lrc - lrc1
TSF = ta.linreg(src, length, 0) + lrs
TSF
TSF = Tsf_Func(src, length)
HMA = ta.wma(2 * ta.wma(src, length / 2) - ta.wma(src, length), math.round(math.sqrt(length)))
T3e1 = ta.ema(src, length)
T3e2 = ta.ema(T3e1, length)
T3e3 = ta.ema(T3e2, length)
T3e4 = ta.ema(T3e3, length)
T3e5 = ta.ema(T3e4, length)
T3e6 = ta.ema(T3e5, length)
T3c1 = -T3a1 * T3a1 * T3a1
T3c2 = 3 * T3a1 * T3a1 + 3 * T3a1 * T3a1 * T3a1
T3c3 = -6 * T3a1 * T3a1 - 3 * T3a1 - 3 * T3a1 * T3a1 * T3a1
T3c4 = 1 + 3 * T3a1 + T3a1 * T3a1 * T3a1 + 3 * T3a1 * T3a1
T3 = T3c1 * T3e6 + T3c2 * T3e5 + T3c3 * T3e4 + T3c4 * T3e3
getMA(src, length) =>
ma = 0.0
if mav == 'SMA'
ma := ta.sma(src, length)
ma
if mav == 'EMA'
ma := ta.ema(src, length)
ma
if mav == 'WMA'
ma := ta.wma(src, length)
ma
if mav == 'DEMA'
ma := DEMA
ma
if mav == 'TMA'
ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)
ma
if mav == 'VAR'
ma := VAR
ma
if mav == 'WWMA'
ma := WWMA
ma
if mav == 'ZLEMA'
ma := ZLEMA
ma
if mav == 'TSF'
ma := TSF
ma
if mav == 'HULL'
ma := HMA
ma
if mav == 'TILL'
ma := T3
ma
ma
MA = getMA(src, length)
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = MA - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = MA + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title='Up Trend', color=color.new(color.green, 100), linewidth=0, style=plot.style_linebr)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 100))
plotshape(buySignal and showsignals ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=0, color=color.new(color.red, 100))
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 100))
plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))
mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0)
colorup = input.color(defval = color.new(color.green, 60), title = "ColorU", inline = 'color')
colordown = input.color(defval = color.new(color.red, 60), title = "ColorD", inline = 'color')
longFillColor = highlighting ? trend == 1 ? colorup : color.white : color.new(color.white, 100)
shortFillColor = highlighting ? trend == -1 ? colordown : color.white : color.new(color.white, 100)
fill(mPlot, upPlot, title='UpTrend Highligter', color=longFillColor)
fill(mPlot, dnPlot, title='DownTrend Highligter', color=shortFillColor)
alertcondition(buySignal, title='SuperTrend Buy', message='SuperTrend Buy!')
alertcondition(sellSignal, title='SuperTrend Sell', message='SuperTrend Sell!')
changeCond = trend != trend[1]
alertcondition(changeCond, title='SuperTrend Direction Change', message='SuperTrend has changed direction!')
@@ -0,0 +1,96 @@
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("Trendlines with Breaks [LuxAlgo]", "LuxAlgo - Trendlines with Breaks", overlay = true)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
length = input.int(14, 'Swing Detection Lookback')
mult = input.float(1., 'Slope', minval = 0, step = .1)
calcMethod = input.string('Atr', 'Slope Calculation Method', options = ['Atr','Stdev','Linreg'])
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the past. Disable backpainting to see real time information returned by the indicator.')
//Style
upCss = input.color(color.teal, 'Up Trendline Color', group = 'Style')
dnCss = input.color(color.red, 'Down Trendline Color', group = 'Style')
showExt = input(true, 'Show Extended Lines')
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
var upper = 0.
var lower = 0.
var slope_ph = 0.
var slope_pl = 0.
var offset = backpaint ? length : 0
n = bar_index
src = close
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)
//Slope Calculation Method
slope = switch calcMethod
'Atr' => ta.atr(length) / length * mult
'Stdev' => ta.stdev(src,length) / length * mult
'Linreg' => math.abs(ta.sma(src * n, length) - ta.sma(src, length) * ta.sma(n, length)) / ta.variance(n, length) / 2 * mult
//Get slopes and calculate trendlines
slope_ph := ph ? slope : slope_ph
slope_pl := pl ? slope : slope_pl
upper := ph ? ph : upper - slope_ph
lower := pl ? pl : lower + slope_pl
var upos = 0
var dnos = 0
upos := ph ? 0 : close > upper - slope_ph * length ? 1 : upos
dnos := pl ? 0 : close < lower + slope_pl * length ? 1 : dnos
//-----------------------------------------------------------------------------}
//Extended Lines
//-----------------------------------------------------------------------------{
var uptl = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend = extend.right)
var dntl = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend = extend.right)
if ph and showExt
uptl.set_xy1(n-offset, backpaint ? ph : upper - slope_ph * length)
uptl.set_xy2(n-offset+1, backpaint ? ph - slope : upper - slope_ph * (length+1))
if pl and showExt
dntl.set_xy1(n-offset, backpaint ? pl : lower + slope_pl * length)
dntl.set_xy2(n-offset+1, backpaint ? pl + slope : lower + slope_pl * (length+1))
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plot(backpaint ? upper : upper - slope_ph * length, 'Upper', color = ph ? na : upCss, offset = -offset)
plot(backpaint ? lower : lower + slope_pl * length, 'Lower', color = pl ? na : dnCss, offset = -offset)
//Breakouts
plotshape(upos > upos[1] ? low : na, "Upper Break"
, shape.labelup
, location.absolute
, upCss
, text = "B"
, textcolor = color.white
, size = size.tiny)
plotshape(dnos > dnos[1] ? high : na, "Lower Break"
, shape.labeldown
, location.absolute
, dnCss
, text = "B"
, textcolor = color.white
, size = size.tiny)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
alertcondition(upos > upos[1], 'Upward Breakout', 'Price broke the down-trendline upward')
alertcondition(dnos > dnos[1], 'Downward Breakout', 'Price broke the up-trendline downward')
//-----------------------------------------------------------------------------}
@@ -0,0 +1,273 @@
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ChartPrime
//@version=5
indicator("Trendline Breakouts With Targets [ Chartprime ]",shorttitle = "TBT [ Chartprime ]",overlay = true,max_bars_back = 500,max_lines_count = 500)
bool ChartTime = time > chart.left_visible_bar_time and time < chart.right_visible_bar_time
string CORE = "➞ Core Settings 🔸"
var bool TradeisON = false
var bool LongTrade = false
var bool ShortTrade = false
var float TP = 0.0
var float SL = 0.0
int BarTIME = time - time[1]
var line tpLine = na
var label LAB = na
var int UpdatedX = 0
var float UpdatedY = 0.0
var float UpdatedSLP = 0.0
var int UpdatedXLow = 0
var float UpdatedYLow = 0.0
var float UpdatedSLPLow = 0.0
int Period = input.int(10, title='     Period     ➞',
group = CORE,
inline = "001")
bool Trendtype = input.string(title = "     Type        ➞",
defval='Wicks',
options=['Wicks', 'Body'],
group = CORE,
inline = "001")
== 'Wicks'
string Extensions = input.string(title='     Extend    ➞',
defval=' 25',
options=[' 25', ' 50', ' 75'],
group = CORE,
inline = "001")
color LineCol1 = input.color(color.rgb(109, 111, 111, 19),"",group = CORE,inline = "001")
bool ShowTargets = input.bool(true,"Show Targets",group = CORE,inline = "002")
ExtenSwitcher(ex) =>
switch ex
' 25' => 1 ,
' 50' => 2 ,
=> 3
WidthSwitcher(ex) =>
switch ex
'1' => 1 ,
'2' => 2 ,
=> 3
StyleSwitcher(style) =>
switch style
'Dashed' => line.style_dashed ,
'Dotted' => line.style_dotted ,
=> line.style_solid
method volAdj(int len)=>
math.min(ta.atr(len) * 0.3, close * (0.3/100)) [20] /2
Zband = volAdj(30)
method Trendlines(float src, int timeIndex,bool dir) =>
var int Start = 1 , var int End = 0 , var int TIME = 1
var float YEnd = 0, var float YStart = 0 , var float Slope = 0
var line Line1 = line.new(na,na,na,na)
var line Line2 = line.new(na,na,na,na)
var line Line3 = line.new(na,na,na,na)
SCR = fixnan(src)
if ta.change(SCR) != 0
TIME := time[timeIndex]
YStart := SCR[1]
Start := TIME[1]
Slope := (SCR - YStart) / (TIME - Start)
Slope
EXTime = ExtenSwitcher(Extensions) * BarTIME * 25
End := TIME + EXTime
YEnd := SCR + EXTime * Slope
if ta.change(SCR) != 0 and not TradeisON[1]
LineCond = Slope * time < 0 ? dir ? na : color.rgb(11, 139, 7, 53) : dir ? color.rgb(212, 46, 0, 54) : na
if not na(LineCond) //and ChartTime
Line1 := line.new(Start,
YStart,
End,
YEnd,
xloc.bar_time,
extend.none,
color=color.new(color.white,100)
)
Line2:=line.new(Start,
YStart - (Zband * 2),
End,
YEnd - (Zband * 2),
xloc.bar_time,
extend.none,
color=color.new(color.black,100)
)
Line3:=line.new(Start,
YStart - (Zband * 1),
End,
YEnd - (Zband * 1),
xloc.bar_time,
extend.none,
color=color.new(color.black,100)
)
linefill.new(Line3,Line2,color= LineCol1)
linefill.new(Line3,Line1,color= LineCond)
// linefill.new(Line,Line2,color= color.rgb(28, 15, 2, 76))
[Start, YStart, Slope]
PH = ta.pivothigh(Trendtype ? high : close > open ? close : open, Period, Period / 2)
PL = ta.pivotlow(Trendtype ? low : close > open ? open : close, Period, Period / 2)
method GetlinePrice(int TIME, float Price, float SLOP, int LookB) =>
var float Current = 0.0
EsTime = time - TIME
Current := Price + (EsTime - LookB * BarTIME) * SLOP
Current
method CheckCross(float Price, int StartTime, float StartPrice, float SLP) =>
var float Current = 0.0
var float Previous = 0.0
if StartPrice[Period] != StartPrice
Current := GetlinePrice(StartTime, StartPrice, SLP, 0)
Previous := GetlinePrice(StartTime, StartPrice, SLP, 1)
Crossover = Price[1] < Previous and Price > Current ? 1 : Price[1] > Previous - (Zband*0.1) and Price < Current - (Zband*0.1) ? -1 : 0
Crossover
[Xx, XZ, SLPXZ] = Trendlines(PH, Period / 2,false)
[XxL, XZL, SLPXZL] = Trendlines(PL, Period / 2, true)
if ta.change(fixnan(PH)) != 0
UpdatedX := Xx
UpdatedY := XZ
UpdatedSLP := SLPXZ
UpdatedSLP
if ta.change(fixnan(PL)) != 0
UpdatedXLow := XxL
UpdatedYLow := XZL
UpdatedSLPLow := SLPXZL
UpdatedSLPLow
Long = not (UpdatedSLP * time > 0)
and CheckCross(close, UpdatedX, UpdatedY, UpdatedSLP)== 1
and not TradeisON
Short = not (UpdatedSLPLow * time < 0)
and CheckCross(close, UpdatedXLow, UpdatedYLow, UpdatedSLPLow)==-1
and not TradeisON
TradeFire = Long or Short
if Long and not TradeisON
LongTrade:= true
ShortTrade:= false
if Short and not TradeisON
LongTrade:= false
ShortTrade:= true
if true
if TradeFire and not TradeisON
TP := switch
Long => high + (Zband *20)
Short => low - (Zband *20)
SL := switch
Long => low - (Zband *20)
Short => high + (Zband *20)
TradeisON:= true
if ShowTargets
line.new(bar_index,
Long ? high : low,
bar_index,
TP,
width=2,
color = color.rgb(154, 103, 20),
style= line.style_dashed)
tpLine:= line.new(bar_index,
TP,
bar_index+2,
TP,
style= line.style_dashed,
color = color.rgb(154, 103, 20)
)
LAB:=label.new(bar_index,
TP,
"Target",
color = color.rgb(154, 103, 20),
style= label.style_label_left,
size=size.small,
textcolor = color.white
)
if TradeisON
line.set_x2(tpLine,bar_index)
label.set_x(LAB,bar_index+1)
if LongTrade and TradeisON
if high >= TP
label.set_color(LAB,color.rgb(6, 128, 10, 37))
TradeisON:=false
if close <= SL
label.set_color(LAB,color.new(color.rgb(246, 7, 7),70))
TradeisON:=false
else if ShortTrade and TradeisON
if low <= TP
label.set_color(LAB,color.rgb(6, 128, 10, 37))
TradeisON:=false
if close >= SL
label.set_color(LAB,color.new(color.rgb(246, 7, 7),70))
TradeisON:=false
plotshape(Long and not TradeisON[1],
size = size.small,
color = color.rgb(46, 192, 6, 11),
location = location.belowbar,
style = shape.labelup ,
text = "",
textcolor = color.white)
plotshape(Short and not TradeisON[1],
size = size.small,
color = color.rgb(241, 2, 2, 11),
location = location.abovebar,
style = shape.labeldown ,
text = "",
textcolor = color.white)
// -- END -- .
+49
View File
@@ -0,0 +1,49 @@
//@version=5
//[SHK] STC colored indicator
//https://www.tradingview.com/u/shayankm/
indicator(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)
EEEEEE = input(12, 'Length')
BBBB = input(26, 'FastLength')
BBBBB = input(50, 'SlowLength')
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
if mAAAAA[3] <= mAAAAA[2] and mAAAAA[2] > mAAAAA[1] and mAAAAA > 75
alert("Red", alert.freq_once_per_bar)
if mAAAAA[3] >= mAAAAA[2] and mAAAAA[2] < mAAAAA[1] and mAAAAA < 25
alert("Green", alert.freq_once_per_bar)
plot(mAAAAA, color=mColor, title='STC', linewidth=2)
ul = plot(25, color=color.new(color.gray, 70))
ll = plot(75, color=color.new(color.gray, 70))
fill(ul, ll, color=color.new(color.gray, 96))