XaiJu
Dutch Algotrading
Dutch Algotrading

patreon


LuxAlgo Supertrend Oscillator Strategy

Introduction

Hello dear readers, this time another trading strategy that I tested, but did not have the superbest results. However this algo is something special since the author has tried to simulate a Tradingview Indicator called “LuxAlgo Supertrend Oscillator”.

The accompanying text in this indicator windows is as follows:

“This oscillator is made of three components, all derived from the SuperTrend indicator. This approach allows the user to easily determine overbought/sold zones, identify whether a retracement is present or if the price is ranging or trending. It also allows for the anticipation of the potential price cross with the SuperTrend.

We provide additional information including whether a signal returned by the SuperTrend was false, as well as the percentage of false signals.

Usage

The indicator is in a range of (-100,100) with values closer to 100/-100 indicating a stronger trend. The main oscillator value above 0 indicates that the price is above the SuperTrend.

It is possible to identify when a retracement is present in a trend. This is often indicated by an oscillator value moving within 50/-50.

Each overbought/oversold level can be used to determine potential exit points.

The indicator also includes two additional oscillators derived from the main oscillator. A smoothed version of the main oscillator (Signal), and a smoothed version of the difference between the Main and Signal oscillators (Histogram), thus making the oscillator part of the indicator more similar to MACD.


One can use the histogram to anticipate when the price might cross the SuperTrend by comparing the sign between the main and histogram. Potential false signals can also be filtered with this method.”

All other information about this Tradingview indicator is located on the following webpage: SuperTrend Oscillator [LuxAlgo] — Indicator by LuxAlgo — TradingView

The author of the Freqtrade Strategy Code is: “viksal1982  viktors.s@gmail.com” and you can contact him if you have any other questions or nice remarks. Compliments are also always nice to get 😊

Strategy code

Anyway, let us concentrate on the code itself. It is a very interesting code since it has to simulate the Tradingview Indicator. Here it is called the the LUX_SuperTrendOscillator function, which computes several components crucial for trend detection and trading decisions. Here's how it works:

Calculating ATR and Price Bands: The function starts by calculating the Average True Range (ATR), which is used to determine market volatility. It then calculates the median price and uses both values to compute the upper (up) and lower (dn) bands.

Dynamic Upper and Lower Bands: The upper and lower bands are adjusted dynamically based on previous values and the price action, helping to track the trend more closely.

Trend Determination: The trend is determined by comparing the closing price with the dynamic bands. If the close is above the upper band, the trend is up, and if below the lower band, the trend is down.

Oscillator and Signal Calculation: The oscillator value is calculated as a normalized difference between the close and a super trend plot (spt). An adaptive moving average (AMA) of the oscillator serves as the signal line.

Histogram for Momentum Visualization: Finally, a histogram is derived from the difference between the oscillator and its signal, indicating the momentum and potential trend reversals.

Buying and Selling Logic

Within the LuxOSC class, which inherits from Freqtrade's IStrategy, the trading signals are generated based on the conditions set by the oscillator and other parameters:

Buy Signal: A buy signal is triggered when the oscillator crosses above a certain threshold and the price is below the super trend line, suggesting a potential bullish reversal.

Sell Signal: Conversely, a sell signal occurs when the oscillator crosses below a designated threshold, indicating a potential bearish turn.

Strategy Parameters and Customization

The strategy parameters such as length, mult, and smooth are adjustable, allowing traders to fine-tune the sensitivity and behavior of the oscillator based on different market conditions. These parameters are used dynamically within the strategy to adapt to the current market volatility and price action.

Good code of this strategy and creating the indicator is not the goal of this exercise ofcourse. The profitability of the complete algorithm under real live market circumstances is the goal here, and backtesting it is the first step in this process.

Backtest results

Let me get straight to the point here, the code looks very interesting, but the potential to make money isn’t there as you can see in the results table.

In the accompanying chart, we have a visual representation of the LuxOSC strategy applied on a 15-minute timeframe, where the performance is measured by win/draw/lose counts and cumulative profit over time. The yellow line denotes cumulative wins, which pleasingly trends upwards over time, while the red line indicates cumulative losses that also rise but at a slower rate. The green line represents cumulative profit and shows a general upward trajectory, suggesting that the strategy, while profitable, does experience fluctuations in performance. Notably, the spikes and troughs in win and loss counts, particularly around the dashed line marking the 2021 bull market top, suggest a strategy sensitive to market volatility. After this point, we observe a pronounced volatility in win counts and a notable dip in cumulative profits, implying the strategy might be over-optimized for the conditions preceding the market peak or that it struggles to adapt to the changing market dynamics post-bull run. The decline in performance after the market's peak raises questions about the strategy's robustness and adaptability to different market phases, emphasizing the importance of continuous optimization and risk management to maintain steady returns.

The drawdown chart before us paints a stark picture of the risks involved in the LuxOSC strategy when applied to a 15-minute trading window. Drawdown, represented by the red line, measures the peak-to-trough decline during a specific recorded period of investment. We observe periods where drawdown spikes dramatically, notably around the 2021 bull market top indicated by the dashed yellow line. This suggests that the strategy may have been significantly impacted by the volatile conditions surrounding the market's peak. While the drawdown does show a general improvement over time, the green line, indicating the average drawdown, remains at a relatively high 42.95%, signaling that potential for large losses has been a consistent trait of this strategy. Such metrics underscore the importance of a comprehensive risk management strategy to mitigate the significant downturns and protect capital.

Here we have a two-panel chart illustrating the performance metrics of the LuxOSC strategy on a weekly period. On the left, the win rate distribution is depicted using a box plot, where the strategy shows a median win rate around 60%. The interquartile range (the height of the box) indicates a relatively consistent win rate performance, with the majority of the data points falling within the 60-80% range, showing a stable probability of individual trade success.

On the right panel, we observe the profit distribution. The spread of the profit data points suggests variability in the outcome of trades, with several outliers indicating substantial losses that could signal the presence of tail risk. Despite a cluster of profitable trades around the median, the tails extending towards significant losses highlight the need for caution. Such an asymmetric distribution with fat tails towards the losses accentuates the potential for infrequent but severe negative outcomes, underscoring the necessity for stringent risk management strategies in trading.

As you can see, the LuxOSC also has an overall 'total_score' that is quite low. 

It is one of the better performing algos in the 'win_perc' category. But a high winrate is no guarantee for high profits.

LuxOSC's 'drawdown' is moderately high, suggesting that while the strategy may win often, it is not immune to significant drops in value, which could be concerning for risk-averse traders. The 'profit_perc' and 'profit_factor' also place LuxOSC in a favorable light, showcasing its ability to generate profits and maintain a good ratio of gross profits to gross losses, but nevertheless the overall profit stays low here.

The 'calmar_ratio', 'sortino', and 'sharpe' ratios are crucial for evaluating performance in relation to risk, and here LuxOSC's performance is extremely low. Notably, in the 'ES_CVaR' (Expected Shortfall and Conditional Value at Risk) metric, LuxOSC demonstrates a potential concern, indicating a significant expected loss in the worst-case scenario, which traders should not overlook.

So as you can already guess, the results of this (on and by itself) interesting algo code, is quite disappointing. I’m not entirely sure if this is caused by faulty code or that the strategy is just not favorable to crypto pairs in general. 

The idea is interesting and I will certainly take this code into my bamboo_ta module at a certain point in time. But the strategy and the results itself will be archived and I have no plans to use these further.

Anyway, these are the results for this algo. As usual you can use the code at your own risk and learn from it by tweaking it furtner.

But I will leave it at this.

Thanks for reading the post and I will see you in the next one,

Goodbye!


More Creators