Estrategia de trading rápido con tres promedios móviles de baja latencia


Fecha de creación: 2023-12-25 14:24:38 Última modificación: 2023-12-25 14:24:38
Copiar: 0 Número de Visitas: 669
1
Seguir
1623
Seguidores

Estrategia de trading rápido con tres promedios móviles de baja latencia

Principio de estrategia

La estrategia utiliza tres medias móviles de retraso de tiempo bajo, que incluyen medias temáticas de retraso de tiempo bajo de 12 períodos, 26 períodos y 55 períodos. Estas tres medias representan: la media rápida, la media rápida y la media lenta, respectivamente.

El código define la función de la plantilla tema (tema) para calcular la línea media de tema de baja latencia. Su fórmula de cálculo es: TEMA = 2*EMA - EMA ((EMA), que utiliza el promedio móvil de índice secundario EWMA para calcular, es esencialmente un promedio móvil de doble índice, el principal beneficio es que reduce considerablemente el retraso. Así, se puede responder más rápidamente a los cambios en los precios y mejorar la actualidad de las señales de negociación.

Concretamente, la estrategia de entrada se juzga como: una señal de compra se produce cuando la línea media rápida cruza la línea media rápida y la línea media rápida está por encima de la línea media lenta; una señal de venta se produce cuando la línea media rápida cruza la línea media rápida y la línea media rápida está por debajo de la línea media lenta.

Análisis de las ventajas

La mayor ventaja de esta estrategia es la rápida y precisa decisión de salida y entrada. El diseño del retardo de la línea media triple baja reduce considerablemente el retraso y puede responder rápidamente a los cambios en los precios. Al mismo tiempo, el uso de la línea media triple para el juicio cruzado evita el error de juicio.

Además, la estrategia es adecuada para el comercio de alta frecuencia y puede capturar las fluctuaciones de precios en líneas cortas para obtener ganancias.

Análisis de riesgos

El mayor riesgo de esta estrategia es la posibilidad de arbitraje súper corto. El diseño del retraso de tres líneas medias bajas determina que sea extremadamente sensible a los cambios de precios, lo que provoca movimientos súper cortos en algunos mercados. En este caso, es fácil de encajar.

Además, las transacciones de alta frecuencia requieren el pago de más comisiones y puntos de deslizamiento. Si la capacidad de ganancia es insuficiente, es fácil ser arbitraje inverso de las tarifas de transacción.

Además, la estrategia requiere una mayor capacidad de monitoreo en tiempo real de los operadores, que requiere la actualización oportuna de los puntos de parada y de suspensión.

Dirección de optimización

La estrategia puede ser optimizada en los siguientes aspectos:

  1. Optimizar los parámetros periódicos de la línea de tres medias para adaptarlos mejor a las características de los diferentes mercados;

  2. Aumentar los indicadores de volatilidad o de volumen de transacción para confirmar las señales y evitar ser atrapados en situaciones de crisis.

  3. La combinación de más factores para establecer un mecanismo de detención de pérdidas y seguimiento dinámico;

  4. Optimizar la gestión de posiciones y controlar el riesgo individual a través de la gestión de fondos;

  5. Combinación de algoritmos de aprendizaje automático para optimizar dinámicamente los parámetros de la estrategia.

Resumir

Esta estrategia es una estrategia de comercio rápido de retardo en el tiempo de baja media de tres líneas. Está diseñada para capturar oportunidades de corto plazo a través de un retardo bajo, para lograr una salida rápida y rápida, adecuada para el comercio de alta frecuencia. La mayor ventaja de esta estrategia es que la señal es rápida y precisa, y la mayor desventaja es que es fácil de encajar en situaciones de crisis.

||

The strategy is named “Low Lag Triple Moving Average Fast Trading Strategy”. Its main idea is to determine entries and exits based on the golden cross and death cross of three moving averages with different parameters and low lag design.

Strategy Principle

The strategy uses three low-lag moving averages, including 12-, 26-, and 55-period low-lag TEMA. These three MAs represent fast, medium and slow MAs. When the fast MA crosses over the medium MA, a buy signal is generated. When the fast MA crosses below the medium MA, a sell signal is generated. By using the crossover of the three MAs to determine market entry and exit points, high frequency trading can be achieved.

The template function tema() is defined in the code to calculate the low-lag TEMA. Its calculation formula is: TEMA = 2*EMA - EMA(EMA). It uses the double exponential moving average EWMA for calculation. Essentially it is a double smoothed EMA with the main merit of largely reducing the lagging effect. Thus it can respond to price changes faster and improve the timeliness of trading signals.

Specifically, the entry rules of this strategy are: when the fast MA crosses over the medium MA and the fast MA is above the slow MA, a buy signal is generated. When the fast MA crosses below the medium MA and the fast MA is below the slow MA, a sell signal is generated.

Advantage Analysis

The biggest advantage of this strategy is that the entries and exits are determined quickly and accurately. The low-lag design of the three MAs greatly reduces the lagging effect so that they can respond to price changes rapidly. Also, using the crossover of three MAs to determine signals avoids false signals.

In addition, this strategy is suitable for high-frequency trading to capture profits from short-term price fluctuations. Through fast entries and exits it can profit from high volatility markets.

Risk Analysis

The biggest risk is that ultra short-term whipsaws may occur. Due to the high sensitivity to price changes from the low-lag design, some markets may experience high-frequency oscillations. Then whipsaws are very likely to happen.

Also, high-frequency trading requires paying relatively high commissions and slippage costs. If the profiting ability is insufficient, it is easy to suffer losses from the trading costs.

Moreover, this strategy requires the trader to have strong real-time monitoring abilities to update the stop loss and take profit timely.

Optimization Directions

The strategy can be optimized from the following aspects:

  1. Optimize the period parameters of the three MAs to better suit different market characteristics.

  2. Add volatility indicators or volume indicators to confirm signals and avoid whipsaws in ranging markets.

  3. Incorporate more factors to set up dynamic trailing stop mechanisms.

  4. Optimize position sizing to control single trade risks through money management techniques.

  5. Incorporate machine learning algorithms to dynamically optimize the strategy parameters.

Conclusion

This is a low-lag triple moving average fast trading strategy. Through its low-lag design, fast entries and exits can be achieved, which is suitable for high-frequency trading to capture short-term opportunities. The biggest advantage of this strategy is that its signal determination is fast and accurate. The biggest disadvantage is that it is prone to be whipsawed in ranging markets. This article comprehensively summarizes this trading strategy through detailed analysis of its rationale, advantages, risks and optimization directions.
[/trans]

Código Fuente de la Estrategia
/*backtest
start: 2023-11-24 00:00:00
end: 2023-12-24 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("scalping low lag tema etal", shorttitle="Scalping tema",initial_capital=10000, overlay=true)
mav = input(title="Moving Average Type", defval="temadelay", options=["nkclose", "ema", "emadelay", "fastema", "tema", "temadelay"])
lenb = 3
N = input(8)
K = input(1.2)
fracCap = input(1.0)
in = close + K*mom(close,N)
source = close
length = 8
sigma  = 12.0
offset = 0.9
p = 4
// length = 10
// sigma  = 6.0
// offset = 0.85
tema(src,len) => fastemaOut = 2*ema(src, len) - ema(ema(src, len), len)


a = 0.0
b = 0.0
c = 0.0
if mav == "nkclose"
    a := ema(in, 12)
    b := a[1]
    c := a[2]
if mav == "ema"
    a := ema(close, 12)
    b := ema(close, 26)
    c := ema(close, 55)
if mav == "emadelay"
    a := ema(close, 12)
    b := a[1]
    c := a[2]
if mav == "fastema"
    a := ema(in, 12)
    b := ema(in, 26)
    c := ema(in, 55)
if mav == "tema"
    a := tema(close, 12)
    b := tema(close, 26)
    c := tema(close, 55)
if mav == "temadelay"
    a := tema(close, 12)
    b := a[1]
    c := a[2]

TP = input(200)
SL = input(130)
TS = input(1)
// TP = input(50)
// SL = input(110)
// TS = input(1)

orderSize = floor((fracCap * strategy.equity) / close)
long = cross(a, c) and a > b
short = cross(a, c) and a < b
plot(a, title="12", color=color.red, linewidth=1)
plot(b, title="26", color=color.blue, linewidth=1)
plot(c, title="55", color=color.green, linewidth=1)

strategy.entry("Long", strategy.long, qty=orderSize,  when=long)
strategy.entry("Short", strategy.short, qty=orderSize,  when=short)
// strategy.entry("Long", strategy.long,  100.0, when=long)
// strategy.entry("Short", strategy.short,  100.0, when=short)
// strategy.entry("Long", strategy.long, 100.0, when=long)
// strategy.entry("Short", strategy.short, 100.0, when=short)
// strategy.entry("Long", strategy.long, 1.0, when=long)
// strategy.entry("Short", strategy.short, 1.0, when=short)

TPP = (TP > 0) ? TP : na
SLP = (SL > 0) ? SL : na
TSP = (TS > 0) ? TS : na
// strategy.exit("Close Short", "Short", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP, when=long)
// strategy.exit("Close Long", "Long", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP, when=short)
// strategy.exit("Close Long", "Long", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP, when=long[1])
// strategy.exit("Close Short", "Short", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP, when=short[1])
strategy.exit("Close Long", "Long", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP)
strategy.exit("Close Short", "Short", qty_percent=100, profit=TPP, loss=SLP, trail_points=TSP)