Type/to search

Weighted Standard Deviation Trading Strategy

Cryptocurrency
Created: 2023-11-24 13:54:58
Last modified: 3 years ago
1
Follow
1779
Followers

img

Overview

This strategy uses the weighted standard deviation indicator combined with moving average to implement trend trading on cryptocurrencies. It calculates a price channel of weighted standard deviation based on closing prices and volumes over a certain period. When the price breaks through the upper or lower channel, long or short positions are taken. Stop loss and take profit conditions are also set to limit losses per trade.

Strategy Logic

The code defines two custom functions to calculate weighted standard deviation from time series and arrays. The key steps are:

  1. Calculate the weighted average price based on closing price and volume
  2. Calculate the squared error of each candle vs the average price
  3. Calculate variance based on sample size, weights and adjusted mean
  4. Take square root to derive standard deviation

This gives us a channel centered on the weighted average price, with upper and lower bounds at one standard deviation away. When price breaks through the channel bottom from below, go long. When it breaks through the top from above, go short.

Advantage Analysis

The biggest edge of this strategy is the combination of moving average and volatility analysis. The MA judges the market trend direction while the SD range defines a sensible band - both verify each other for higher reliability. Also, the volume weighting helps filter false breaks for higher success probability on actual breaks.

The stop loss and take profit points further help trade with the trend and avoid excessive losses on reversals. This is a subtlety that many novice traders fail to implement.

Risk Analysis

The main risk is from violent market swings. This can cause the SD channel to swing wildly too, making judgements difficult. Also, choosing too short periods risks getting misled by noise and errors.

The remedy is to smooth the parameters and period settings appropriately. Consider combining other indicators like RSI to improve breakout confirmation.

Optimization Directions

  1. Optimize period parameters - test 5min, 15min, 30mins etc for best combo
  2. Optimize stop loss/take profit ratios for maximum return
  3. Add filters eg volume to avoid false breaks
  4. Add candlestick filters on close price, wick etc to improve accuracy

Conclusion

This strategy successfully employs the weighted standard deviation indicator together with MA to track cryptocurrency trends. Reasonable stop loss/take profit setups also help trade market rhythm and avoid excessive reversal losses. Further optimizations via parameter tuning and multi-indicator confirmation can improve reliability for a solid algo trading strategy.

Source
Pine
/*backtest
start: 2023-11-16 00:00:00
end: 2023-11-23 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rumpypumpydumpy   © cache_that_pass

//@version=4
Strategy parameters
Strategy parameters
len
Stop Loss %
Take Profit %
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)