Scripts Traiding
Scripts Traiding
0 at
https://mozilla.org/MPL/2.0/
// � Alebr2811
//@version=5
indicator("Mi script", overlay=true) // true ..lo integra en el grafico principal
plot(close, color=color.orange) // Esto muestra precio de cierre
plot(open, color=color.yellow) //Esto muestra precio de apertura
plot(high, color=color.green) //Esto muestra precio alto
plot(low, color=color.red) //Esto muestra precio bajo
//plot(open + (close[3] - close[0] )/2 ) //Esto muestra cualquier cuenta
// bgcolor(color.black)
cantidad = 29000
precio = 28800
subtotal = cantidad * precio
texto="hola"
total = subtotal + 10
Total = total + 10
plot(cantidad, color=color.purple)
plot(precio, color=color.gray
BTC = precios_btc / 1
luna = precios_luna * 1000000000
shib = precios_shib * 1000000000
plot((BTC), color=color.green)
//plot((luna), color=color.red)
//plot((shib), color=color.yellow)
media = ta.sma(BTC,20)
plot(media)
------------------------------------------------------------------
//@version=5
//entrada de datos rsi con indicador de compra o venta en media de rsi -
estrategia varios periodos
indicator("RSI", overlay=false)
sobrecompra = input.float(70, title="sobrecompra", minval=50, maxval=100, step=1)
sobreventa = input.float(30, title="Sobreventa", minval=10, maxval=50, step=1)
periodos = input(defval=14, title="Periodo")
periodosema = input(defval=14, title="PeriodoEma")
l1 = hline(sobrecompra)
l2 = hline(sobreventa)
-------------------------------------------------
// same on pine, but less efficient - RSI
pine_rsi(x, y) =>
u = math.max(x - x[1], 0) // upward ta.change
d = math.max(x[1] - x, 0) // downward ta.change
rs = ta.rma(u, y) / ta.rma(d, y)
res = 100 - 100 / (1 + rs)
res
plot(pine_rsi(close, 7))
l1 = hline(70, "RSI Upper Band", color=#787B86)
l2 = hline(30, "RSI Lower Band", color=#787B86)
fill(l1, l2, color=color.new(color.green, 80))
---------------------------------------------------
//@version=4 media movil con se�ales de compra y venta con flechas y sombreado
ecenario alcista y bajista
study("Media Movil", overlay=true)
mm = sma(close, 9)
me = ema(close, 9)
mp = wma(close, 9)
plot(mp, color=color.yellow)
plot(me, color=color.gray)
plot(mm, color=color.orange)
plot(mmrapida, color=color.red)
plot(mmlenta, color=color.purple)
mm5 = ema(close, 5)
mm10 = ema(close, 10)
mm20 = ema(close, 20)
plot(mm5, color=color.green)
plot(mm10, color=color.yellow)
plot(mm20, color=color.red)
mm = ema(close, 21)
angulorad = atan( (mm[0] - mm[1]) )
angulogra = angulorad * 180 / acos(-1)
plot(angulogra)
hline(0, color=color.yellow)
hline(100, color=color.green)
hline(-100, color=color.red)
-----------------------------------------------------------------------
//@version=4
strategy("Mi semaforol", overlay = false)
FechaValida()=>
desde = time >= timestamp(syminfo.timezone, desde_a, desde_m, desde_d, 0, 0)
hasta = time <= timestamp(syminfo.timezone, hasta_a, hasta_m, hasta_d, 0, 0)
desde and hasta
---------------------------------------------------------------
//@version=4
study("Mi script1", overlay = true)
//Bands
//Vwap
plot(vwap2, color=color.yellow)
------------------------------------------------------------------
//@version=4 prueba el anterior no anda
study("Mi script1", overlay = true)
plot(vwap2, color=color.yellow)
------------------------------------------------------------------
//@version=4
study("Accurate Swing Trading System",overlay=true)
no=input(3,title="Swing")
Barcolor=input(true,title="Barcolor")
Bgcolor=input(false,title="Bgcolor")
res=highest(high,no)
sup=lowest(low,no)
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
avn=valuewhen(avd!=0,avd,0)
tsl=iff(avn==1,sup,res)
Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)
// Definitions: Trends
TrendUp1() => ma1 > ma2
TrendDown1() => ma1 < ma2
TrendUp2() => ma3 > ma4
TrendDown2() => ma3 < ma4
-----------------------------------------------------------------------------------
-----
//@version=5
// desde
desde_a = input.int( 2018, title= "Desde a�o")
desde_m= input.int( 9, title= "Desde mes", minval= 1, maxval=12)
desde_d = input.int(1, title= "Desde dia", minval= 1, maxval=31)
//hasta
hasta_a = input.int( 2030, title= "Desde a�o")
hasta_m= input.int( 1, title= "Desde mes", minval= 1, maxval=12)
hasta_d = input.int(1, title= "Desde dia", minval= 1, maxval=31)
FechaValida()=>
desde = time >= timestamp(syminfo.timezone, desde_a, desde_m, desde_d, 0, 0)
hasta = time <= timestamp(syminfo.timezone, hasta_a, hasta_m, hasta_d, 0, 0)
desde and hasta
-----------------------------------------------------------------------------------
var countr = 0
isRed = close <= open
if isRed
countr := countr + 1
plot(countr, color=color.red)
-----------------------------------------------------------------------------------
-
//@version=5
indicator("Switch using an expression", "", true)// cambio de "EMA", "SMA", "RMA",
"WMA"
plot(ma)
-----------------------------------------------------------------------------
//@version=5 // media movi que cambia de color
indicator("", "", true)
int periodInput = input.int(100, "Period", minval = 2)
float ma = ta.sma(close, periodInput)
bool xUp = ta.crossover(close, ma)
color maColor = close > ma ? color.lime : color.fuchsia
plot(ma, "MA", maColor)
plotchar(xUp, "Cross Up", "?", location.top, size = size.tiny)
----------------------------------------------------------------------------
//@version=5 // plot de vwma
indicator("Lows from new highs", "", true)
myVwma = ta.vwma(close, 20)
plot(myVwma)
----------------------------------------------------------------------------
//@version=4
strategy(title="EASYOLEGSYSTEM",
shorttitle="SYKAOLEG",overlay=true,default_qty_type=strategy.percent_of_equity,defa
ult_qty_value=10,commission_type=strategy.commission.percent,commission_value=0.01,
slippage=1)
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol1 = (volume / hilow)
spreadvol = (openclose * vol1)
VPT = spreadvol + cum(spreadvol)
window_len = 28
v_len = 14
price_spread = stdev(high-low, window_len)
vp = spreadvol + cum(spreadvol)
smooth = sma(vp, v_len)
v_spread = stdev(vp - smooth, window_len)
shadow = (vp - smooth) / v_spread * price_spread
out1 = shadow > 0 ? high + shadow : low + shadow
// INPUTS //
src = input(high,title="Source")
EnterPoints = input(14,minval=0,maxval=24,title="EnterPoints")
Period = input(3,minval=2,maxval=1000,title="Hull MA Period")
AF_initial = input(0.2,minval=0.00,maxval=1,step=0.01,title="AF_initial")
AF_increment= input(0.2,minval=0.00,maxval=1,step=0.01,title="AF_increment")
AF_maximum = input(0.1,minval=0.0,maxval=1,step=0.1,title="AF_maximum")
len = input(10,title="Length")
Depth = input(13,title="Depth")
Deviation = input(60,title="Deviation")
st_mult = input(0.2,minval=0,maxval=100,step=0.1, title="SuperTrend
Multiplier")
st_period = input(1,minval=1,title="SuperTrend Period")
multi = input(0.5,minval=0.0,maxval=3.0,step=0.1,title="Divergence Channel
Width Factor (Stddev)")
uDiv = input(true,title="Show Divergence Channel")
uHid = input(true,title="Show Hidden Divergence")
uReg = input(true,title="Show Regular Divergence")
disp_panels = input(true, title="Display info panels?")
info_label_pos=input(title="Info panel position",defval=-10,minval=-
1000,maxval=1000)
info_label_size=input(size.normal, options=[size.tiny, size.small, size.normal,
size.large, size.huge], title="Info panel label size")
vpt=ema(out1,len)
uDiv := uReg or uHid ? uDiv : false
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))
up_trend = 0.0
up_trend := src[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := src[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend10 = 0
trend10 := src > down_trend[1] ? 1: src < up_trend[1] ? -1 : nz(trend10[1], 1)
// Calculate SuperTrend Line
st_line = trend10 ==1 ? up_trend : down_trend
//
f_top_fractal(_src) =>
_src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and
_src[2] > _src[0]
f_bot_fractal(_src) =>
_src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and
_src[2] < _src[0]
f_fractalize(_src) =>
f_bot_fractal__1 = f_bot_fractal(_src)
f_top_fractal(_src) ? 1 : f_bot_fractal__1 ? -1 : 0
//
ST_high = st_line
ST_low = st_line
offset_ = multi * stdev(st_line, 20)
fractal_top_ST = f_fractalize(ST_high) > 0 ? ST_high[2] : na
fractal_bot_ST = f_fractalize(ST_low) < 0 ? ST_low[2] : na
ST_high_prev = valuewhen(fractal_top_ST, ST_high[2], 1)
ST_high_price = valuewhen(fractal_top_ST, high[2], 1)
ST_low_prev = valuewhen(fractal_bot_ST, ST_low[2], 1)
ST_low_price = valuewhen(fractal_bot_ST, low[2], 1)
regular_bearish_div = fractal_top_ST and high[2] > ST_high_price and ST_high[2] <
ST_high_prev and
ST_high > 0
hidden_bearish_div = fractal_top_ST and high[2] < ST_high_price and ST_high[2] >
ST_high_prev and
ST_high > 0
regular_bullish_div = fractal_bot_ST and low[2] < ST_low_price and ST_low[2] >
ST_low_prev and
ST_low < 0
hidden_bullish_div = fractal_bot_ST and low[2] > ST_low_price and ST_low[2] <
ST_low_prev and
ST_low < 0
color1=trend10 == 1 ? color.lime : color.orange
plot(title='ST High', series=uDiv ? ST_high : na, color=color1)
plot(title='ST Low', series=uDiv ? ST_low : na, color=color1)
plot(title='ST H F', series=uDiv ? fractal_top_ST + offset_ : na, color=color.red,
offset=-2)
plot(title='ST L F', series=uDiv ? fractal_bot_ST - offset_ : na,
color=color.green, offset=-2)
plot(title='ST H D', series=uDiv ? fractal_top_ST + offset_ : na,
style=plot.style_circles, color=regular_bearish_div and uReg or hidden_bearish_div
and uHid ? color.maroon : color.red, linewidth=5, offset=-2)
plot(title='ST L D', series=uDiv ? fractal_bot_ST - offset_ : na,
style=plot.style_circles, color=regular_bullish_div and uReg or hidden_bullish_div
and uHid ? color.green : color.blue, linewidth=5, offset=-2)
plotshape(title='+RBD', series=regular_bearish_div and uReg ? ST_high[2] +
offset_ : na, text='Regular', style=shape.labeldown, location=location.absolute,
color=color.maroon, textcolor=color.white, offset=-2)
plotshape(title='+HBD', series=hidden_bearish_div and uHid ? ST_high[2] + offset_ :
na, text='hidden', style=shape.labeldown, location=location.absolute,
color=color.maroon, textcolor=color.white, offset=-2)
plotshape(title='-RBD', series=regular_bullish_div and uReg ? ST_low[2] - offset_ :
na, text='Regular', style=shape.labelup, location=location.absolute,
color=color.green, textcolor=color.white, offset=-2)
plotshape(title='-HBD', series=hidden_bullish_div and uHid ? ST_low[2] - offset_ :
na, text='hidden', style=shape.labelup, location=location.absolute,
color=color.green, textcolor=color.white, offset=-2)
// ZigZag
lastlow = 0.0, lasthigh = 0.0
lastlow := nz(lastlow[1])
lasthigh := nz(lasthigh[1])
data(x) =>
d = security(syminfo.tickerid, timeframe.period, x, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
d
getLow(x, y, z, a) =>
lastlow = y
v = data(x)
m = v==lastlow or data(z) - v > a*syminfo.mintick
if v!=lastlow
lastlow := v
if m
v := 0.0
[v,lastlow]
getHigh(x, y, z, a) =>
lasthigh = y
v = data(x)
m = v==lasthigh or v - data(z) > a*syminfo.mintick
if v!=lasthigh
lasthigh := v
if m
v := 0.0
[v,lasthigh]
zigzagDirection = -1
zigzagHigh = 0
zigzagLow = 0
zigzagDirection := zBB ? 0 : zSS ? 1 : nz(zigzagDirection[1], -1)
virtualLow = zigzagLow[1] + 1
if not zBB or (zBB and zigzagDirection == zigzagDirection[1] and low >
low[virtualLow])
zigzagLow := nz(zigzagLow[1]) + 1
virtualHigh = zigzagHigh[1] + 1
if not zSS or (zSS and zigzagDirection == zigzagDirection[1] and high <
high[virtualHigh])
zigzagHigh := nz(zigzagHigh[1]) + 1
a=bar_index-zigzagLow
b=bar_index-zigzagHigh
var color c = na, c := fixnan(a < b[1] ? color.lime : a > b[1] ? color.red : na)
line zigzag = line.new(bar_index-zigzagLow, low[zigzagLow], bar_index-zigzagHigh,
high[zigzagHigh], color=c, style=line.style_solid, width=4)
if (zigzagDirection == zigzagDirection[1])
line.delete(zigzag[1])
zzPrevHigh = zigzagHigh[1]
zzPrevLow = zigzagLow[1]
if not na(zzPrevHigh[1])
zzPrevHigh := zzPrevHigh[1] + 1
if not na(zzPrevLow[1])
zzPrevLow := zzPrevLow[1] + 1
if zigzagDirection != zigzagDirection[1]
if zigzagDirection == 1
zzPrevHigh := zigzagHigh[1] + 1
if zigzagDirection == 0
zzPrevLow := zigzagLow[1] + 1
//sma
sma20 = sma(src, 20)
smapoint = 0
smapoint := src > sma20 ? smapoint + 1 : smapoint - 1
//AO
ao = sma(hl2,5) - sma(hl2,34)
aopoint = ao > 0 ? 1 : ao < 0 ? -1 : 0
//momentum
mom = src - src[14]
mompoint = mom > 0 ? 1 : mom < 0 ? -1 : 0
//MACD
fast_ma = ema(src, 12)
slow_ma = ema(src, 26)
macd = fast_ma - slow_ma
signal = ema(macd, 9)
hist = macd - signal
histpoint = hist > hist[1] ? 3 : -3
//Bull bear
Length = 30
r1=iff(close[1]<open,max(open-close[1],high-low),high-low)
r2=iff(close[1]>open,max(close[1]-open,high-low),high-low)
bull=iff(close==open,iff(high-close==close-low,iff(close[1]>open,max(high-
open,close-low),r1),iff(high-close>close-low,iff(close[1]<open, max(high-
close[1],close-low), high-open),r1)),iff(close<open,iff(close[1]<open,max(high-
close[1],close-low), max(high-open,close-low)),r1))
bear=iff(close==open,iff(high-close==close-low,iff(close[1]<open,max(open-low,high-
close),r2),iff(high-close>close-low,r2,iff(close[1]>open,max(close[1]-low,high-
close), open-low))),iff(close<open,r2,iff(close[1]>open,max(close[1]-low,high-
close),max(open-low,high-close))))
colors=iff(sma(bull-bear,Length)>0, color.green, color.red)
bbpoint = sma(bull-bear,Length)>0 ? 1 : -1
//UO
length7 = 7,
length14 = 14,
length28 = 28
average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)
high_ = max(high, src[1])
low_ = min(low, src[1])
bp = src - low_
tr_ = high_ - low_
avg7 = average(bp, tr_, length7)
avg14 = average(bp, tr_, length14)
avg28 = average(bp, tr_, length28)
uoout = 100 * (4*avg7 + 2*avg14 + avg28)/7
uopoint = uoout > 70 ? 1 : uoout < 30 ? -1 : 0
//IC
conversionPeriods = 9
basePeriods = 26
laggingSpan2Periods = 52
displacement = 26
donchian(len) => avg(lowest(len), highest(len))
baseLine = donchian(basePeriods)
icpoint = src > baseLine ? 2 : -2
//HMA
hullma = hma(src, Period)
hmapoint = src > hullma ? 1 : -1
//
trendDetectionLength =4
float trend = na
float wave = na
float vol = na
mov = src>src[1] ? 1 : src<src[1] ? -1 : 0
trend := (mov != 0) and (mov != mov[1]) ? mov : nz(trend[1])
isTrending = rising(src, trendDetectionLength) or falling(src,
trendDetectionLength)
wave := (trend != nz(wave[1])) and isTrending ? trend : nz(wave[1])
vol := wave == wave[1] ? (nz(vol[1])+volume) : volume
up1 = wave == 1 ? vol : 0
dn1 = wave == 1 ? 0 : vol
Weis= up1 > dn1 ? 2 : -2
//
stochlen = 14
roclen =20
ccilen =21
dilen = 5
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]
TD = 0
TS = 0
TD := src > src[4] ? nz(TD[1]) + 1 : 0
TS := src < src[4] ? nz(TS[1]) + 1 : 0
TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
stoch = stoch(src, high, low, stochlen)
roc = roc(src, roclen)
Roc=roc > 0 ? 1 : -1
cci = cci(src, ccilen)
CCI=cci > 0? 1 : -1
[plus, minus] = dirmov(dilen)
dmi = plus - minus
DMI= dmi >= 0? 2 : -2
//
Zig=a<b? 1 : -1
//
STT=trend10 == 1 ? 3 : -3
// start with uptrend
uptrend = true
newtrend = false
EP = high
SAR = low
AF = AF_initial
x=src-SAR
sar=x>0? 3 : -3
totalpoints
=sar+STT+Zig+Roc+DMI+CCI+Weis+smapoint+aopoint+mompoint+histpoint+bbpoint+icpoint+h
mapoint
color2=trend10 == 1 ? color.lime : color.red
Bgcolor=input(true,title="Bgcolor")
bgcolor(Bgcolor ? color2 :na)
-----------------------------------------------------------
//@version=4
strategy(title="EASYOLEGSYSTEM",
shorttitle="SYKAOLEG",overlay=true,default_qty_type=strategy.percent_of_equity,defa
ult_qty_value=10,commission_type=strategy.commission.percent,commission_value=0.01,
slippage=1)
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol1 = (volume / hilow)
spreadvol = (openclose * vol1)
VPT = spreadvol + cum(spreadvol)
window_len = 28
v_len = 14
price_spread = stdev(high-low, window_len)
vp = spreadvol + cum(spreadvol)
smooth = sma(vp, v_len)
v_spread = stdev(vp - smooth, window_len)
shadow = (vp - smooth) / v_spread * price_spread
out1 = shadow > 0 ? high + shadow : low + shadow
//Rango Fecha
// desde
desde_a = input( 2022, title= "Desde a�o")
desde_m = input( 6, title= "Desde mes", minval= 1, maxval=12)
desde_d = input( 1, title= "Desde dia", minval= 1, maxval=31)
//hasta
hasta_a = input( 2030, title= "Desde a�o")
hasta_m = input( 1, title= "Desde mes", minval= 1, maxval=12)
hasta_d = input( 1, title= "Desde dia", minval= 1, maxval=31)
FechaValida()=>
desde = time >= timestamp(syminfo.timezone, desde_a, desde_m, desde_d, 0, 0)
hasta = time <= timestamp(syminfo.timezone, hasta_a, hasta_m, hasta_d, 0, 0)
desde and hasta
// INPUTS //
src = input(high,title="Source")
EnterPoints = input(14,minval=0,maxval=24,title="EnterPoints")
Period = input(3,minval=2,maxval=1000,title="Hull MA Period")
AF_initial = input(0.2,minval=0.00,maxval=1,step=0.01,title="AF_initial")
AF_increment= input(0.2,minval=0.00,maxval=1,step=0.01,title="AF_increment")
AF_maximum = input(0.1,minval=0.0,maxval=1,step=0.1,title="AF_maximum")
len = input(10,title="Length")
Depth = input(13,title="Depth")
Deviation = input(60,title="Deviation")
st_mult = input(0.2,minval=0,maxval=100,step=0.1, title="SuperTrend
Multiplier")
st_period = input(1,minval=1,title="SuperTrend Period")
multi = input(0.5,minval=0.0,maxval=3.0,step=0.1,title="Divergence Channel
Width Factor (Stddev)")
uDiv = input(true,title="Show Divergence Channel")
uHid = input(true,title="Show Hidden Divergence")
uReg = input(true,title="Show Regular Divergence")
disp_panels = input(true, title="Display info panels?")
info_label_pos=input(title="Info panel position",defval=-10,minval=-
1000,maxval=1000)
info_label_size=input(size.normal, options=[size.tiny, size.small, size.normal,
size.large, size.huge], title="Info panel label size")
vpt=ema(out1,len)
uDiv := uReg or uHid ? uDiv : false
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))
up_trend = 0.0
up_trend := src[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := src[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend10 = 0
trend10 := src > down_trend[1] ? 1: src < up_trend[1] ? -1 : nz(trend10[1], 1)
// Calculate SuperTrend Line
st_line = trend10 ==1 ? up_trend : down_trend
//
f_top_fractal(_src) =>
_src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and
_src[2] > _src[0]
f_bot_fractal(_src) =>
_src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and
_src[2] < _src[0]
f_fractalize(_src) =>
f_bot_fractal__1 = f_bot_fractal(_src)
f_top_fractal(_src) ? 1 : f_bot_fractal__1 ? -1 : 0
//
ST_high = st_line
ST_low = st_line
offset_ = multi * stdev(st_line, 20)
fractal_top_ST = f_fractalize(ST_high) > 0 ? ST_high[2] : na
fractal_bot_ST = f_fractalize(ST_low) < 0 ? ST_low[2] : na
ST_high_prev = valuewhen(fractal_top_ST, ST_high[2], 1)
ST_high_price = valuewhen(fractal_top_ST, high[2], 1)
ST_low_prev = valuewhen(fractal_bot_ST, ST_low[2], 1)
ST_low_price = valuewhen(fractal_bot_ST, low[2], 1)
regular_bearish_div = fractal_top_ST and high[2] > ST_high_price and ST_high[2] <
ST_high_prev and
ST_high > 0
hidden_bearish_div = fractal_top_ST and high[2] < ST_high_price and ST_high[2] >
ST_high_prev and
ST_high > 0
regular_bullish_div = fractal_bot_ST and low[2] < ST_low_price and ST_low[2] >
ST_low_prev and
ST_low < 0
hidden_bullish_div = fractal_bot_ST and low[2] > ST_low_price and ST_low[2] <
ST_low_prev and
ST_low < 0
color1=trend10 == 1 ? color.lime : color.orange
plot(title='ST High', series=uDiv ? ST_high : na, color=color1)
plot(title='ST Low', series=uDiv ? ST_low : na, color=color1)
plot(title='ST H F', series=uDiv ? fractal_top_ST + offset_ : na, color=color.red,
offset=-2)
plot(title='ST L F', series=uDiv ? fractal_bot_ST - offset_ : na,
color=color.green, offset=-2)
plot(title='ST H D', series=uDiv ? fractal_top_ST + offset_ : na,
style=plot.style_circles, color=regular_bearish_div and uReg or hidden_bearish_div
and uHid ? color.maroon : color.red, linewidth=5, offset=-2)
plot(title='ST L D', series=uDiv ? fractal_bot_ST - offset_ : na,
style=plot.style_circles, color=regular_bullish_div and uReg or hidden_bullish_div
and uHid ? color.green : color.blue, linewidth=5, offset=-2)
plotshape(title='+RBD', series=regular_bearish_div and uReg ? ST_high[2] +
offset_ : na, text='Regular', style=shape.labeldown, location=location.absolute,
color=color.maroon, textcolor=color.white, offset=-2)
plotshape(title='+HBD', series=hidden_bearish_div and uHid ? ST_high[2] + offset_ :
na, text='hidden', style=shape.labeldown, location=location.absolute,
color=color.maroon, textcolor=color.white, offset=-2)
plotshape(title='-RBD', series=regular_bullish_div and uReg ? ST_low[2] - offset_ :
na, text='Regular', style=shape.labelup, location=location.absolute,
color=color.green, textcolor=color.white, offset=-2)
plotshape(title='-HBD', series=hidden_bullish_div and uHid ? ST_low[2] - offset_ :
na, text='hidden', style=shape.labelup, location=location.absolute,
color=color.green, textcolor=color.white, offset=-2)
// ZigZag
lastlow = 0.0, lasthigh = 0.0
lastlow := nz(lastlow[1])
lasthigh := nz(lasthigh[1])
data(x) =>
d = security(syminfo.tickerid, timeframe.period, x, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
d
getLow(x, y, z, a) =>
lastlow = y
v = data(x)
m = v==lastlow or data(z) - v > a*syminfo.mintick
if v!=lastlow
lastlow := v
if m
v := 0.0
[v,lastlow]
getHigh(x, y, z, a) =>
lasthigh = y
v = data(x)
m = v==lasthigh or v - data(z) > a*syminfo.mintick
if v!=lasthigh
lasthigh := v
if m
v := 0.0
[v,lasthigh]
zigzagDirection = -1
zigzagHigh = 0
zigzagLow = 0
zigzagDirection := zBB ? 0 : zSS ? 1 : nz(zigzagDirection[1], -1)
virtualLow = zigzagLow[1] + 1
if not zBB or (zBB and zigzagDirection == zigzagDirection[1] and low >
low[virtualLow])
zigzagLow := nz(zigzagLow[1]) + 1
virtualHigh = zigzagHigh[1] + 1
if not zSS or (zSS and zigzagDirection == zigzagDirection[1] and high <
high[virtualHigh])
zigzagHigh := nz(zigzagHigh[1]) + 1
a=bar_index-zigzagLow
b=bar_index-zigzagHigh
var color c = na, c := fixnan(a < b[1] ? color.lime : a > b[1] ? color.red : na)
line zigzag = line.new(bar_index-zigzagLow, low[zigzagLow], bar_index-zigzagHigh,
high[zigzagHigh], color=c, style=line.style_solid, width=4)
if (zigzagDirection == zigzagDirection[1])
line.delete(zigzag[1])
zzPrevHigh = zigzagHigh[1]
zzPrevLow = zigzagLow[1]
if not na(zzPrevHigh[1])
zzPrevHigh := zzPrevHigh[1] + 1
if not na(zzPrevLow[1])
zzPrevLow := zzPrevLow[1] + 1
if zigzagDirection != zigzagDirection[1]
if zigzagDirection == 1
zzPrevHigh := zigzagHigh[1] + 1
if zigzagDirection == 0
zzPrevLow := zigzagLow[1] + 1
//sma
sma20 = sma(src, 20)
smapoint = 0
smapoint := src > sma20 ? smapoint + 1 : smapoint - 1
//AO
ao = sma(hl2,5) - sma(hl2,34)
aopoint = ao > 0 ? 1 : ao < 0 ? -1 : 0
//momentum
mom = src - src[14]
mompoint = mom > 0 ? 1 : mom < 0 ? -1 : 0
//MACD
fast_ma = ema(src, 12)
slow_ma = ema(src, 26)
macd = fast_ma - slow_ma
signal = ema(macd, 9)
hist = macd - signal
histpoint = hist > hist[1] ? 3 : -3
//Bull bear
Length = 30
r1=iff(close[1]<open,max(open-close[1],high-low),high-low)
r2=iff(close[1]>open,max(close[1]-open,high-low),high-low)
bull=iff(close==open,iff(high-close==close-low,iff(close[1]>open,max(high-
open,close-low),r1),iff(high-close>close-low,iff(close[1]<open, max(high-
close[1],close-low), high-open),r1)),iff(close<open,iff(close[1]<open,max(high-
close[1],close-low), max(high-open,close-low)),r1))
bear=iff(close==open,iff(high-close==close-low,iff(close[1]<open,max(open-low,high-
close),r2),iff(high-close>close-low,r2,iff(close[1]>open,max(close[1]-low,high-
close), open-low))),iff(close<open,r2,iff(close[1]>open,max(close[1]-low,high-
close),max(open-low,high-close))))
colors=iff(sma(bull-bear,Length)>0, color.green, color.red)
bbpoint = sma(bull-bear,Length)>0 ? 1 : -1
//UO
length7 = 7,
length14 = 14,
length28 = 28
average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)
high_ = max(high, src[1])
low_ = min(low, src[1])
bp = src - low_
tr_ = high_ - low_
avg7 = average(bp, tr_, length7)
avg14 = average(bp, tr_, length14)
avg28 = average(bp, tr_, length28)
uoout = 100 * (4*avg7 + 2*avg14 + avg28)/7
uopoint = uoout > 70 ? 1 : uoout < 30 ? -1 : 0
//IC
conversionPeriods = 9
basePeriods = 26
laggingSpan2Periods = 52
displacement = 26
donchian(len) => avg(lowest(len), highest(len))
baseLine = donchian(basePeriods)
icpoint = src > baseLine ? 2 : -2
//HMA
hullma = hma(src, Period)
hmapoint = src > hullma ? 1 : -1
//
trendDetectionLength =4
float trend = na
float wave = na
float vol = na
mov = src>src[1] ? 1 : src<src[1] ? -1 : 0
trend := (mov != 0) and (mov != mov[1]) ? mov : nz(trend[1])
isTrending = rising(src, trendDetectionLength) or falling(src,
trendDetectionLength)
wave := (trend != nz(wave[1])) and isTrending ? trend : nz(wave[1])
vol := wave == wave[1] ? (nz(vol[1])+volume) : volume
up1 = wave == 1 ? vol : 0
dn1 = wave == 1 ? 0 : vol
Weis= up1 > dn1 ? 2 : -2
//
stochlen = 14
roclen =20
ccilen =21
dilen = 5
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]
TD = 0
TS = 0
TD := src > src[4] ? nz(TD[1]) + 1 : 0
TS := src < src[4] ? nz(TS[1]) + 1 : 0
TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
stoch = stoch(src, high, low, stochlen)
roc = roc(src, roclen)
Roc=roc > 0 ? 1 : -1
cci = cci(src, ccilen)
CCI=cci > 0? 1 : -1
[plus, minus] = dirmov(dilen)
dmi = plus - minus
DMI= dmi >= 0? 2 : -2
//
Zig=a<b? 1 : -1
//
STT=trend10 == 1 ? 3 : -3
// start with uptrend
uptrend = true
newtrend = false
EP = high
SAR = low
AF = AF_initial
if not na(uptrend[1]) and not na(newtrend[1])
if uptrend[1]
EP := max(high, EP[1])
else
EP := min(low, EP[1])
if newtrend[1]
AF := AF_initial
else
if EP != EP[1]
AF := min(AF_maximum, AF[1] + AF_increment)
else
AF := AF[1]
SAR := SAR[1] + AF * (EP - SAR[1])
if uptrend[1]
if newtrend
SAR := max(high, EP[1])
EP := min(low, low[1])
else
SAR := min(SAR, low[1])
if not na(low[2])
SAR := min(SAR, low[2])
if SAR > low
uptrend := false
newtrend := true
SAR := max(high, EP[1])
EP := min(low, low[1])
else
uptrend := true
newtrend := false
else
if newtrend
SAR := min(low, EP[1])
EP := max(high, high[1])
else
SAR := max(SAR, high[1])
if not na(high[2])
SAR := max(SAR, high[2])
if SAR < high
uptrend := true
newtrend := true
SAR := min(low, EP[1])
EP := max(high, high[1])
else
uptrend := false
newtrend := false
x=src-SAR
sar=x>0? 3 : -3
totalpoints
=sar+STT+Zig+Roc+DMI+CCI+Weis+smapoint+aopoint+mompoint+histpoint+bbpoint+icpoint+h
mapoint
color2=trend10 == 1 ? color.lime : color.red
Bgcolor=input(true,title="Bgcolor")
bgcolor(Bgcolor ? color2 :na)
strategy.entry
-----------------------------------------------------------------------------------
-----------
//@version=5
strategy("`strategy.opentrades.size` Example
1",overlay=false,default_qty_type=strategy.percent_of_equity, initial_capital=
1000,default_qty_value=10,commission_type=strategy.commission.percent,commission_va
lue=0.01,slippage=1)
//Rango Fecha
// desde
desde_a = input.int( 2022, title= "Desde a�o")
desde_m = input.int( 6, title= "Desde mes", minval= 1, maxval=12)
desde_d = input.int( 1, title= "Desde dia", minval= 1, maxval=31)
//hasta
hasta_a = input.int( 2022, title= "Desde a�o")
hasta_m = input.int( 6, title= "Desde mes", minval= 1, maxval=12)
hasta_d = input.int( 2, title= "Desde dia", minval= 1, maxval=31)
FechaValida()=>
desde = time >= timestamp(syminfo.timezone, desde_a, desde_m, desde_d, 0, 0)
hasta = time <= timestamp(syminfo.timezone, hasta_a, hasta_m, hasta_d, 0, 0)
desde and hasta
//plot(ta.vwma(close, 15))
rsi_c = ta.rsi(close, 14)
h1 = hline(70)
hline(50)
h2 = hline(30)
fill(h1, h2, color=color.new(color.silver, 80))
plot(rsi_c, color=color.purple)