0% found this document useful (0 votes)
120 views24 pages

Scripts Traiding

The document contains source code for a trading strategy using Pine Script indicators and functions. It defines moving averages, plots indicators like RSI and EMA, and includes signals to buy and sell based on crossovers of moving averages. Various periods and parameters can be customized. It also contains code snippets to plot prices of different assets on the same chart and test RSI calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views24 pages

Scripts Traiding

The document contains source code for a trading strategy using Pine Script indicators and functions. It defines moving averages, plots indicators like RSI and EMA, and includes signals to buy and sell based on crossovers of moving averages. Various periods and parameters can be customized. It also contains code snippets to plot prices of different assets on the same chart and test RSI calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 24

// This source code is subject to the terms of the Mozilla Public License 2.

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

plot(ta.highest(high, 20), color=color.green)


plot(ta.lowest(low, 20), color=color.red)

max = ta.highest(high, 20) maximo de velas cada 20 periodos


min = ta.lowest(low, 20) minimo de velas cada 20 periodos

plot((max), color=color.green) grafico


plot((min), color=color.red) grafico
media = (max + min) / 2 media de maximo y minimo
plot((media), color=color.yellow) grafico

Ema20 = ta.ema(high, 20) media movil de 20


plot((Ema20), color=color.aqua) grafico
-------------------------------------------------------------
periodoema = input(defval=21, title="Periodo ema")
Ema20 = ta.ema(high, periodoema)
plot((Ema20), color=color.aqua, linewidth=2)

periodosma = input(defval=200, title="Periodo sma")


cantidad = input(defval=100, title="Cantidad")
texto = input(defval="Hola Ale", title="Texto")

sma200 = ta.sma(close, periodosma)


plot((sma200), color=color.olive, linewidth=2)
-------------------------------------------------------------
precios_btc = request.security("BTCUSDT", timeframe.period, close)
precios_luna = request.security("LUNAUSDT", timeframe.period, close)
precios_shib = request.security("SHIBUSDT", timeframe.period, close)

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)

mirsi = ta.rsi(close, periodos)


media = ta.ema(mirsi, periodosema)

fill(l1, l2, color=color.new(color.green, 80))

plot(ta.rsi(close, periodos), color=color.purple, linewidth=1)


plot(media, color=color.green, linewidth=1)

comprar = ta.crossover(media, sobreventa)


vender = ta.crossunder(media, sobrecompra)

bgcolor(comprar ? color.green : na, transp=10)


bgcolor(vender ? color.red : na, transp=10)
---------------------------------------------
pruebas RSI
i//@version=5
indicator("ta.rsi", overlay=false)
plot(ta.rsi(close, 14))

linea1 = hline(70, "RSI Upper Band", color=#787B86)


linea2 = hline(30, "RSI Lower Band", color=#787B86)
fill(linea1,linea2, color=color.purple)

-------------------------------------------------
// 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)

mmrapida = ema(close, 10)


mmlenta = ema(close, 50)

plot(mmrapida, color=color.red)
plot(mmlenta, color=color.purple)

crucearriba = crossover(mmrapida, mmlenta)


cruceabajo= crossunder(mmrapida, mmlenta)

plotshape(crucearriba, style = shape.arrowup, location = location.bottom, color =


color.green, size = size.auto, text = "Compra")
plotshape(cruceabajo, style = shape.arrowdown, location = location.top, color =
color.red, size = size.auto, text = "Venta")

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)

alcista = (mm5 > mm10) and (mm10 > mm20)


bajista = (mm5 < mm10) and (mm10 < mm20)

bgcolor( alcista ? color.green : na)


bgcolor( bajista ? color.red : na)
-----------------------------------------------------------------------
//@version=4
study("Media Movil", overlay = false)

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)

Longitud_mm_v = input(5, title="Longitud MM verde")


Longitud_mm_a = input(10, title="Longitud MM amarilla")
Longitud_mm_r = input(20, title="Longitud MM roja")

Pintar_mm = input(false, title="Pintar MM")


// desde
desde_a = input( 2018, title= "Desde a�o")
desde_m= input( 9, 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

mm_v = ta.ema(close, Longitud_mm_v)


mm_a = ta.ema(close, Longitud_mm_a)
mm_r = ta.ema(close, Longitud_mm_r)

alcista = (mm_v > mm_a) and (mm_a > mm_r)


comprado =strategy.position_size > 0
if (not comprado and alcista and FechaValida())
//realizar compra
cantidad = round(strategy.equity / close)
strategy.entry("compra", strategy.long, cantidad)

if (comprado and not alcista)


//realizar venta
strategy.close("compra", comment="Venta")

if (comprado and not FechaValida())


//realizar venta x Finalizacion
strategy.close("compra", comment="Venta x Fin del periodo")

plot( Pintar_mm ? mm_v : na, color=color.green)


plot( Pintar_mm ? mm_a : na, color=color.yellow)
plot( Pintar_mm ? mm_r : na, color=color.red)

---------------------------------------------------------// This source code is


subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// � Alebr2811

---------------------------------------------------------------
//@version=4
study("Mi script1", overlay = true)

var acumulador_vpx = 0.0


var acumulador_vol = 0.0
var ultimo = 0

periodo = input(defval="Semana1", title="Periodo", type=input.string,


options=["Mensual", "Semanal", "Diario"])

if periodo == "Diario" dayofweek != ultimo


//reseteamos los acumuladores
acumulador_vpx = 0.0
acumulador_vol = 0.0
ultimo_dia = dayofweek

if periodo == "Semanal" weekofyear != ultimo


//reseteamos los acumuladores
acumulador_vpx = 0.0
acumulador_vol = 0.0
ultimo_dia = weekofyear

if periodo == "Mensual" month != ultimo


//reseteamos los acumuladores
acumulador_vpx = 0.0
acumulador_vol = 0.0
ultimo_dia = month

vpx = volume * hlc3

acumulador_vpx := acumulador_vpx + vpx


acumulador_vol := acumulador_vol + volume

vwap2 = acumulador_vpx / acumulador_vol

//Bands

plot( vwap2 * ( 1 + porcentaje/100), color=color.gray)


plot( vwap2 * ( 1 - porcentaje/100), color=color.gray)

//Vwap

plot(vwap2, color=color.yellow)
------------------------------------------------------------------
//@version=4 prueba el anterior no anda
study("Mi script1", overlay = true)

var acumulador_vpx = 0.0


var acumulador_vol = 0.0

vpx = volume * hlc3

acumulador_vpx := acumulador_vpx + vpx


acumulador_vol := acumulador_vol + volume

vwap2 = acumulador_vpx / acumulador_vol

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)

plotshape(Buy,"BUY", shape.labelup, location.belowbar, color.green,


text="BUY",textcolor=color.black)
plotshape(Sell,"SELL", shape.labeldown, location.abovebar, color.red,
text="SELL",textcolor=color.black)

colr = close>=tsl ? color.green : close<=tsl ? color.red : na


plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)

alertcondition(Buy, title="Buy Signal", message="Buy")


alertcondition(Sell, title="Sell Signal", message="Sell")
------------------------------------------------------------------------
//@version=4
study("SPY Indicators", shorttitle="SPY Ind", overlay=true)
// Version 1.0
// Author: Likwid

// Definitions: Price and Timeframes


src = input(close, title = "Source")
resolution = timeframe.period
price = security(syminfo.tickerid, resolution, src)

// Defintions: Moving Average periods and types


ma1Period = input(defval=8, title="Period", inline="1", group="Moving Averages:
Zone 1")
ma1Type = input(defval="EMA", title="Type", type=input.string,
options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="1",
group="Moving Averages: Zone 1")

ma2Period = input(defval=21, title="Period", inline="2", group="Moving Averages:


Zone 1")
ma2Type = input(defval="EMA", title="Type", type=input.string,
options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="2",
group="Moving Averages: Zone 1")

ma3Period = input(defval=34, title="Period", inline="3", group="Moving Averages:


Zone 2")
ma3Type = input(defval="EMA", title="Type", type=input.string,
options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="3",
group="Moving Averages: Zone 2")

ma4Period = input(defval=50, title="Period", inline="4", group="Moving Averages:


Zone 2")
ma4Type = input(defval="EMA", title="Type", type=input.string,
options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="4",
group="Moving Averages: Zone 2")

ma5Period = input(defval=200, title="Period", inline="5", group="Moving Averages:


Other")
ma5Type = input(defval="EMA", title="Type", type=input.string,
options=["EMA","SMA","WMA","HMA","LIN"], tooltip="MA Smoothing", inline="5",
group="Moving Averages: Other")
vwSwitch = input(title="VWAP", type=input.bool, defval=true, inline="6",
group="Moving Averages: Other")
vwPeriod = input(defval=9, title="Period", inline="6", group="Moving Averages:
Other")

// Moving Average Calculation


ma1 = ma1Type == "EMA" ? ema(price, ma1Period) :
ma1Type == "SMA" ? sma(price, ma1Period) :
ma1Type == "WMA" ? wma(price, ma1Period) :
ma1Type == "HMA" ? hma(price, ma1Period) :
ma1Type == "LIN" ? linreg(price, ma1Period, 0) : na

ma2 = ma2Type == "EMA" ? ema(price, ma2Period) :


ma2Type == "SMA" ? sma(price, ma2Period) :
ma2Type == "WMA" ? wma(price, ma2Period) :
ma2Type == "HMA" ? hma(price, ma2Period) :
ma2Type == "LIN" ? linreg(price, ma2Period, 0) : na

ma3 = ma3Type == "EMA" ? ema(price, ma3Period) :


ma3Type == "SMA" ? sma(price, ma3Period) :
ma3Type == "WMA" ? wma(price, ma3Period) :
ma3Type == "HMA" ? hma(price, ma3Period) :
ma3Type == "LIN" ? linreg(price, ma3Period, 0) : na

ma4 = ma4Type == "EMA" ? ema(price, ma4Period) :


ma4Type == "SMA" ? sma(price, ma4Period) :
ma4Type == "WMA" ? wma(price, ma4Period) :
ma4Type == "HMA" ? hma(price, ma4Period) :
ma4Type == "LIN" ? linreg(price, ma4Period, 0) : na

ma5 = ma5Type == "EMA" ? ema(price, ma5Period) :


ma5Type == "SMA" ? sma(price, ma5Period) :
ma5Type == "WMA" ? wma(price, ma5Period) :
ma5Type == "LIN" ? linreg(price, ma5Period, 0) : na

// Definitions: Trends
TrendUp1() => ma1 > ma2
TrendDown1() => ma1 < ma2
TrendUp2() => ma3 > ma4
TrendDown2() => ma3 < ma4

trendColor1 = TrendUp1() ? color.green : TrendDown1() ? color.red : color.blue


trendColor2 = TrendUp2() ? color.blue : TrendDown2() ? color.red : color.blue

// Moving Average plots


p_ma1 = plot(ma1)
p_ma2 = plot(ma2)
p_ma3 = plot(ma3)
p_ma4 = plot(ma4)
fill(p_ma1, p_ma2, color=trendColor1, transp=70)
fill(p_ma3, p_ma4, color=trendColor2, transp=70)

plot(ma5, color=color.red, linewidth=2, style=plot.style_line)


plot(vwSwitch ? vwap(hlc3) : na, color=color.white, linewidth=1,
style=plot.style_line)

-----------------------------------------------------------------------------------
-----
//@version=5

barIsUp() => // Function declaration (global scope)


close > open // Local block (local scope)

plotColor = if barIsUp() // Variable declaration (global scope)


color.green // Local block (local scope)
else
color.red // Local block (local scope)

bgcolor(color.new(plotColor, 70)) // Call to a built-in function (global scope)

strategy("My Strategy", overlay=true, margin_long=100, margin_short=100)


Longitud_mm_v = input(5, title="Longitud MM verde")
Longitud_mm_a = input(10, title="Longitud MM amarilla")
Longitud_mm_r = input(20, title="Longitud MM roja")

Pintar_mm = input(false, title="Pintar MM")

mm_v = ta.ema(close, Longitud_mm_v)


mm_a = ta.ema(close, Longitud_mm_a)
mm_r = ta.ema(close, Longitud_mm_r)

// 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

longCondition = ta.crossover((mm_v), (mm_a))


if (longCondition and FechaValida())
strategy.entry("Compra", strategy.long)

shortCondition = ta.crossunder((mm_v), (mm_a))


if (shortCondition and FechaValida())
strategy.entry("Venta", strategy.short)

plot( Pintar_mm ? mm_v : na, color=color.green)


plot( Pintar_mm ? mm_a : na, color=color.yellow)
plot( Pintar_mm ? mm_r : na, color=color.red)

-----------------------------------------------------------------------------------

//@version=5 // agregue la barra roja - cuenta las barras verdes


indicator("Green Bars Count")
var count = 0
isGreen = close >= open
if isGreen
count := count + 1
plot(count, color=color.green)

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"

string maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA",


"WMA"])
int maLength = input.int(10, "MA length", minval = 2)

float ma = switch maType


"EMA" => ta.ema(close, maLength)
"SMA" => ta.sma(close, maLength)
"RMA" => ta.rma(close, maLength)
"WMA" => ta.wma(close, maLength)
=>
runtime.error("No matching MA type found.")
float(na)

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]

[v,e] = getLow(lowest(Depth), lastlow, low, Deviation)


lastlow := e
zBB = v != 0.0
[v1,e1] = getHigh(highest(Depth), lasthigh, high, Deviation)
lasthigh := e1
zSS = v1 != 0.0

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]

f_draw_infopanel(_x, _y, _line, _text, _color)=>


_rep_text = ""
for _l = 0 to _line
_rep_text := _rep_text + "\n"
_rep_text := _rep_text + _text
var label _la = na
label.delete(_la)
_la := label.new(
x=_x, y=_y,
text=_rep_text, xloc=xloc.bar_time, yloc=yloc.price,
color=color.black, style=label.style_labelup, textcolor=_color,
size=size.normal)

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)

info_panel_x = timenow - round(change(time)*info_label_pos)


info_panel_y = src
BuyPoints=EnterPoints
SellPoints=EnterPoints-(EnterPoints*2)
info_title= "-- EasySys420 --" + "\n\ "
info_div1 = "\n\Sup Trend " + tostring(trend10)
info_div2 = "\n\SAR " + tostring(sar)
info_div3 = "\n\STT " + tostring(STT)
info_div4 = "\n\Zig " + tostring(Zig)
info_div5 = "\n\Roc " + tostring(Roc)
info_div6 = "\n\DMI " + tostring(DMI)
info_div7 = "\n\CCI " + tostring(CCI)
info_div8 = "\n\Weis " + tostring(Weis)
info_div9 = "\n\SMA " + tostring(smapoint)
info_div10 = "\n\AO " + tostring(aopoint)
info_div11 = "\n\MOM " + tostring(mompoint)
info_div12 = "\n\Hist " + tostring(histpoint)
info_div13 = "\n\BB " + tostring(bbpoint)
info_div14 = "\n\Ichi " + tostring(icpoint)
info_div15 = "\n\HMA " + tostring(hmapoint)
info_div16 = "\n\------------------"
info_current_close = "\n\Total points: " + tostring(totalpoints) + "\
n\------------------"
info_current_buy = "\n\Buying @: " + tostring(BuyPoints)
info_current_sell = "\n\Selling @: " + tostring(SellPoints)
info_text
=info_title+info_div1+info_div2+info_div3+info_div4+info_div5+info_div6+info_div7+i
nfo_div8+info_div9+info_div10+info_div11+info_div12+info_div13+info_div14+info_div1
5+info_div16+info_current_close+info_current_buy+info_current_sell
info_panel = disp_panels ? label.new(x=info_panel_x, y=info_panel_y,
text=info_text, xloc=xloc.bar_time, yloc=yloc.price, color=color.yellow,
style=label.style_labelup, textcolor=color.black, size=info_label_size) : na
label.delete(info_panel[1])

if (totalpoints>BuyPoints and trend10==1 or Zig==1 and trend10==1)


strategy.entry("OSTA",strategy.long, comment = "Long")
if (totalpoints<SellPoints and trend10==-1 or Zig==-1 and trend10==-1)
strategy.entry("M��",strategy.short, comment ="Short")
-------------------------------------------------------------------------------
//@version=5
indicator(title="Volume Weighted Moving Average", shorttitle="VWMA", overlay=true,
timeframe="", timeframe_gaps=true)
len = input.int(20, "Length", minval=1)
src = input(close, "Source")
ma = ta.vwma(src, len)
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(ma, title="VWMA", color=#2962FF, offset = offset)

-----------------------------------------------------------
//@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]

[v,e] = getLow(lowest(Depth), lastlow, low, Deviation)


lastlow := e
zBB = v != 0.0
[v1,e1] = getHigh(highest(Depth), lasthigh, high, Deviation)
lasthigh := e1
zSS = v1 != 0.0

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]

f_draw_infopanel(_x, _y, _line, _text, _color)=>


_rep_text = ""
for _l = 0 to _line
_rep_text := _rep_text + "\n"
_rep_text := _rep_text + _text
var label _la = na
label.delete(_la)
_la := label.new(
x=_x, y=_y,
text=_rep_text, xloc=xloc.bar_time, yloc=yloc.price,
color=color.black, style=label.style_labelup, textcolor=_color,
size=size.normal)

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)

info_panel_x = timenow - round(change(time)*info_label_pos)


info_panel_y = src
BuyPoints=EnterPoints
SellPoints=EnterPoints-(EnterPoints*2)
info_title= "-- EasySys420 --" + "\n\ "
info_div1 = "\n\Sup Trend " + tostring(trend10)
info_div2 = "\n\SAR " + tostring(sar)
info_div3 = "\n\STT " + tostring(STT)
info_div4 = "\n\Zig " + tostring(Zig)
info_div5 = "\n\Roc " + tostring(Roc)
info_div6 = "\n\DMI " + tostring(DMI)
info_div7 = "\n\CCI " + tostring(CCI)
info_div8 = "\n\Weis " + tostring(Weis)
info_div9 = "\n\SMA " + tostring(smapoint)
info_div10 = "\n\AO " + tostring(aopoint)
info_div11 = "\n\MOM " + tostring(mompoint)
info_div12 = "\n\Hist " + tostring(histpoint)
info_div13 = "\n\BB " + tostring(bbpoint)
info_div14 = "\n\Ichi " + tostring(icpoint)
info_div15 = "\n\HMA " + tostring(hmapoint)
info_div16 = "\n\------------------"
info_current_close = "\n\Total points: " + tostring(totalpoints) + "\
n\------------------"
info_current_buy = "\n\Buying @: " + tostring(BuyPoints)
info_current_sell = "\n\Selling @: " + tostring(SellPoints)
info_text
=info_title+info_div1+info_div2+info_div3+info_div4+info_div5+info_div6+info_div7+i
nfo_div8+info_div9+info_div10+info_div11+info_div12+info_div13+info_div14+info_div1
5+info_div16+info_current_close+info_current_buy+info_current_sell
info_panel = disp_panels ? label.new(x=info_panel_x, y=info_panel_y,
text=info_text, xloc=xloc.bar_time, yloc=yloc.price, color=color.yellow,
style=label.style_labelup, textcolor=color.black, size=info_label_size) : na
label.delete(info_panel[1])

if (FechaValida() and (totalpoints>BuyPoints and trend10==1 or Zig==1 and


trend10==1) )
strategy.order("Compra",strategy.long, comment = "Long")
if (FechaValida() and (totalpoints<SellPoints and trend10==-1 or Zig==-1 and
trend10==-1) )
strategy.order("Venta",strategy.short, comment ="Short")

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

// We calculate the max amt of shares we can buy.


amtShares = math.floor(strategy.equity / close)
// Strategy calls to enter long trades every 15 bars and exit long trades every 20
bars
if bar_index % 15 == 0 and FechaValida()
strategy.entry("Long", strategy.long, qty = amtShares)
if bar_index % 20 == 0 and FechaValida()
strategy.close("Long")

// Plot the number of contracts in the latest open trade.


//plot(strategy.opentrades.size(strategy.opentrades - 1), "Amount of contracts in
latest open trade")

//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)

rsi_v = ta.rsi(volume, 14)


bgcolor(rsi_v > 65 ? color.green : na)
plot(rsi_v, color=color.purple)

You might also like