La estrategia utiliza dos indicadores de energía dinámica aleatoria (SMI y RSI) para el juicio sobre el espacio, complementado con un filtro de Martingale y un filtro físico para filtrar las señales de negociación, con el objetivo de capturar tendencias de línea corta y rastrear las fluctuaciones de los precios.
La estrategia utiliza dos indicadores aleatorios de energía dinámica, el SMI y el RSI, para juzgar el exceso de volatilidad. El SMI se calcula a través de la diferencia entre los precios reales de la línea K y el promedio móvil del precio de cierre, lo que permite identificar eficazmente los puntos de inflexión. El RSI determina el exceso de compra y venta mediante la comparación de la cantidad de volatilidad. La estrategia hace más cuando el SMI es inferior a 50 y el RSI es inferior a 20; y hace menos cuando el SMI es superior a 50 y el RSI es superior a 80.
La estrategia también utiliza 1⁄3 de la línea media corporal de 10 ciclos como condición de filtración de la ruptura. Cuando la entidad rompe 1⁄3 de la línea media, la ruptura se considera efectiva.
Además, la estrategia utiliza la estrategia opcional de Martingale, que consiste en aumentar proporcionalmente la posición en una operación perdedora con la esperanza de recuperar las pérdidas anteriores.
La función de backtest mide la efectividad de la estrategia mediante la introducción de la hora de inicio y finalización.
La estrategia utiliza un conjunto de indicadores y filtros binarios aleatorios para identificar puntos de inflexión, capturar tendencias de línea corta y rastrear fluctuaciones de precios.
Se puede optimizar el SMI y el RSI para reducir la probabilidad de seguimiento de alta y baja. El uso razonable de la estrategia de Martingale, el control de la proporción de la posición y la frecuencia.
La estrategia combina el uso de dos indicadores aleatorios para capturar el punto de inflexión, auxiliado por filtros y martingales para la selección y seguimiento de señales de negociación, para identificar de manera efectiva las tendencias de línea corta, rastrear las fluctuaciones de los precios, y es adecuado para los inversores que buscan altas ganancias.
/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
// strategy(title = "CS Basic Scripts - Stochastic Special (Strategy)", shorttitle = "Stochastic Special", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(false, defval = false, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usesmi = input(true, defval = true, title = "Use SMI Strategy")
usersi = input(true, defval = true, title = "Use RSI Strategy")
usebod = input(true, defval = true, title = "Use Body-Filter")
a = input(5, "SMI Percent K Length")
b = input(3, "SMI Percent D Length")
limit = input(50, defval = 50, minval = 1, maxval = 100, title = "SMI Limit")
//Backtesting Input Range
fromyear = input(2017, defval = 2017, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//Fast RSI
fastup = rma(max(change(close), 0), 7)
fastdown = rma(-min(change(close), 0), 7)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))
//Stochastic Momentum Index
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)
//Lines
plot(SMI, color = blue, linewidth = 3, title = "Stochastic Momentum Index")
plot(SMIsignal, color = red, linewidth = 3, title = "SMI Signal Line")
plot(limit, color = black, title = "Over Bought")
plot(-1 * limit, color = black, title = "Over Sold")
plot(0, color = blue, title = "Zero Line")
//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false
//Signals
up1 = SMI < -1 * limit and close < open and body and usesmi
dn1 = SMI > limit and close > open and body and usesmi
up2 = fastrsi < 20 and close < open and body and usersi
dn2 = fastrsi > 80 and close > open and body and usersi
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body
//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]
if up1 or up2
if strategy.position_size < 0
strategy.close_all()
strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if dn1 or dn2
if strategy.position_size > 0
strategy.close_all()
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
strategy.close_all()