OPEN-SOURCE SCRIPT

Bitcoin Futures vs. Spot Tri-Frame - Strategy [presentTrading]

업데이트됨
Prove idea with a backtest is always true for trading.

I developed and open-sourced it as an educational material for crypto traders to understand that the futures and spot spread may be effective but not be as effective as they might think. It serves as an indicator of sentiment rather than a reliable predictor of market trends over certain periods. It is better suited for specific trading environments, which require further research.

█ Introduction and How it is Different

The "Bitcoin Futures vs. Spot Tri-Frame Strategy" utilizes three different timeframes to calculate the Z-Score of the spread between BTC futures and spot prices on Binance and OKX exchanges. The strategy executes long or short trades based on composite Z-Score conditions across the three timeframes.

The spread refers to the difference in price between BTC futures and BTC spot prices, calculated by taking a weighted average of futures prices from multiple exchanges (Binance and OKX) and subtracting a weighted average of spot prices from the same exchanges.

BTCUSD 1D L/S Performance
스냅샷


█ Strategy, How It Works: Detailed Explanation

🔶 Calculation of the Spread

The spread is the difference in price between BTC futures and BTC spot prices. The strategy calculates the spread by taking a weighted average of futures prices from multiple exchanges (Binance and OKX) and subtracting a weighted average of spot prices from the same exchanges. This spread serves as the primary metric for identifying trading opportunities.

Spread = Weighted Average Futures Price - Weighted Average Spot Price

🔶 Z-Score Calculation

The Z-Score measures how many standard deviations the current spread is from its historical mean. This is calculated for each timeframe as follows:

Spread Mean_tf = SMA(Spread_tf, longTermSMA)

Spread StdDev_tf = STDEV(Spread_tf, longTermSMA)

Z-Score_tf = (Spread_tf - Spread Mean_tf) / Spread StdDev_tf

Local performance
스냅샷

🔶 Composite Entry Conditions

The strategy triggers long and short entries based on composite Z-Score conditions across all three timeframes:

- Long Condition: All three Z-Scores must be greater than the long entry threshold.
Long Condition = (Z-Score_tf1 > zScoreLongEntryThreshold) and (Z-Score_tf2 > zScoreLongEntryThreshold) and (Z-Score_tf3 > zScoreLongEntryThreshold)

- Short Condition: All three Z-Scores must be less than the short entry threshold.
Short Condition = (Z-Score_tf1 < zScoreShortEntryThreshold) and (Z-Score_tf2 < zScoreShortEntryThreshold) and (Z-Score_tf3 < zScoreShortEntryThreshold)

█ Trade Direction

The strategy allows the user to specify the trading direction:

- Long: Only long trades are executed.
- Short: Only short trades are executed.
- Both: Both long and short trades are executed based on the Z-Score conditions.

█ Usage

The strategy can be applied to BTC or Crypto trading on major exchanges like Binance and OKX. By leveraging discrepancies between futures and spot prices, traders can exploit market inefficiencies. This strategy is suitable for traders who prefer a statistical approach and want to diversify their timeframes to validate signals.

█ Default Settings

- Input TF 1 (60 minutes): Sets the first timeframe for Z-Score calculation.
- Input TF 2 (120 minutes): Sets the second timeframe for Z-Score calculation.
- Input TF 3 (180 minutes): Sets the third timeframe for Z-Score calculation.
- Long Entry Z-Score Threshold (3): Defines the threshold above which a long trade is triggered.
- Short Entry Z-Score Threshold (-3): Defines the threshold below which a short trade is triggered.
- Long-Term SMA Period (100): The period used to calculate the simple moving average for the spread.
- Use Hold Days (true): Enables holding trades for a specified number of days.
- Hold Days (5): Number of days to hold the trade before exiting.
- TPSL Condition (None): Defines the conditions for taking profit and stop loss.
- Take Profit (%) (30.0): The percentage at which the trade will take profit.
- Stop Loss (%) (20.0): The percentage at which the trade will stop loss.

By fine-tuning these settings, traders can optimize the strategy to suit their risk tolerance and trading style, enhancing overall performance.
릴리즈 노트
updated the properties setting
Bitcoin (Cryptocurrency)BTCBTCUSDcryptomarketeducationalfutrestradingpresenttradingsentimentspreadstatisticsstrategy

오픈 소스 스크립트

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

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


Watch patiently/ then trade
또한 다음에서도:

면책사항