OPEN-SOURCE SCRIPT

EMA SHIFT & PARALLEL [n_dot]

ETHUSDT.P

This strategy was developed for CRYPTO FUTURES, (the settings for ETHUSDT.P) . I aimed for the strategy to function in a live environment, so I focused on making its operation realistic:

  • When determining the position, only 80% (adjustable) of the available cash is invested to reduce the risk of position liquidation.
  • I account for a 0.05% commission, typical on the futures market, for each entry and exit.


Concept:

I modified a simple, well-known method: the crossover of two exponential moving averages (FAST, SLOW) generates the entry and exit signals.

I enhanced the base idea as follows:

  • For the fast EMA, I incorporated a multiplier (offset) to filter out market noise and focus only on strong signals.
  • I use different EMAs for long and short entry points; both have their own FAST and SLOW EMAs and their own offset. For longs, the FAST EMA is adjusted downward (<1), while for shorts, it is adjusted upward (>1). Consequently, the signal is generated when the modified FAST EMA crosses the SLOW EMA.


Risk Management:
The position includes the following components:
  • Separate stop-losses for long and short positions.
  • Separate trailers for long and short positions.
  • The strategy operates so that the entry point is determined by the EMA crossover, while the exit is governed only by the Stop Loss or Trailer. Optionally, it can be set to close the position at the EMA recrossing ("Close at Signal").


Trailer Operation:
  • An entry percentage and offset are defined. The trailer activates when the price surpasses the entry price, calculated automatically by the system.
  • The trailer closes the position when the price drops by the offset percentage from the highest reached price.


Example for trailer:
  • Purchase Price = 100
  • Trailer Enter = 5% → Activation Price = 105 (triggers trailer if market price crosses it).
  • Trailer Offset = 2%
  • If the price rises to 110, the exit price becomes 107.8.
  • If the price goes to 120, the exit price becomes 117.6.
  • If the price falls below 117.6, the trailer closes the position.


Settings:

  • Source: Determines the market price reference.
  • End Close: Closes positions at the end of the simulation to avoid "shadow positions" and provide an objective result.
  • Lot proportional to free cash (%): Only a portion of free cash is invested to meet margin requirements.
  • Plot Short, Plot Long: Simplifies displayed information by toggling indicator lines on/off.
  • Long Position (toggleable):
  • EMA Fast ws: Window size for FAST EMA.
  • EMA Slow ws: Window size for SLOW EMA.
  • EMA Fast down shift: Adjustment factor for FAST EMA.
  • Stop Loss long (%): Percent drop to close the position.
  • Trailer enter (%): Percent above the purchase price to activate the trailer.
  • Trailer offset (%): Percent drop to close the position.
  • Short Position (toggleable):
  • EMA Fast ws: Window size for FAST EMA.
  • EMA Slow ws: Window size for SLOW EMA.
  • EMA Fast up shift: Adjustment factor for FAST EMA.
  • Stop Loss short (%): Percent rise to close the position.
  • Trailer enter (%): Percent below the purchase price to activate the trailer.
  • Trailer offset (%): Percent rise to close the position.


Operational Framework:

  • If in a long position and a short EMA crossover occurs, the strategy closes the long and opens a short (flip).
  • If in a short position and a long EMA crossover occurs, the strategy closes the short and opens a long (flip).


A position can close in three ways:
  • Stop Loss
  • Trailer
  • Signal Recrossing

If none are active, the position remains open until the end of the simulation.

Observations:

  • Shifts significantly deviating from 1 increase overfitting risk. Recommended ranges: 0.96–0.99 (long) and 1.01–1.05 (short).
  • The strategy's advantage lies in risk management, crucial in leveraged futures markets. It operates with relatively low DrawDown.


Recommendations:

  • Bullish Market: Higher entry threshold (e.g., 6%) and larger offset (e.g., 3%).
  • Volatile/Sideways Market: Tighter parameters (e.g., 3%, 1%).
  • The method is stable, and minor parameter adjustments do not significantly impact results, helping assess overfitting: if small changes lead to drastic differences, the strategy is over-optimized.
  • EMA Settings: Adjust FAST and SLOW EMAs based on the asset's volatility and cyclicality.
  • On the crypto market, especially in the Futures market, short time periods (1–15 minutes) often show significant noise, making patterns/repetitions hard to identify. I recommend setting the interval to at least 1 hour.


I hope this contributes to your success!
CyclesExponential Moving Average (EMA)Trend Analysis

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항