
The Adaptive Inverse Hyperbolic Tangent CCI Momentum Trading Strategy is a quantitative trading system based on technical indicators, centered around the IFTCCI indicator developed by Kıvanc Özbilgiç. This strategy generates buy and sell signals by setting precise threshold levels as the indicator oscillates between -1 and +1. Buy signals are triggered when the indicator crosses upward from below -0.95 to above a specific threshold; sell signals are triggered when the indicator crosses downward from above 0.95 to below a specific threshold. Additionally, the strategy incorporates a dynamic stop-loss mechanism and re-entry conditions: if the price moves in the opposite direction by a certain magnitude (0.1 units) after a signal is generated, the system will trigger a stop-loss or execute a re-entry operation. This strategy performs more effectively on Heikin Ashi charts, providing traders with a systematic approach to momentum trading.
The core of this strategy is the IFTCCI indicator, which is calculated through the following steps:
The specific calculation formula is:
v1 = 0.1 * (CCI(close, period) / 4)
v2 = WMA(v1, wma_period)
IFTCCI = (e^(2*v2) - 1) / (e^(2*v2) + 1)
The execution logic of the strategy is divided into the following key components:
Buy Conditions:
Sell Conditions:
State Tracking:
The entire strategy employs percentage-based fund management, using 100% of available funds for each trade, and prohibits pyramiding (pyramiding=0). The strategy calculates signals in real-time as each candle forms (calc_on_every_tick=true), ensuring timely capture of market dynamics.
Clear Entry and Exit Rules: The strategy provides explicit trading signals based on precise numerical thresholds, avoiding subjective judgment and making trading decisions more objective and disciplined.
Dynamic Risk Management Mechanism: The built-in stop-loss mechanism effectively limits losses on individual trades, automatically exiting when the market moves against the position beyond a preset magnitude, protecting capital safety.
Strong Market Adaptability: The IFTCCI indicator, through hyperbolic tangent transformation, oscillates between -1 and +1, possessing inherent normalization characteristics suitable for market environments with different volatility levels.
Smoothed Signals, Reduced False Breakouts: Using weighted moving averages to smooth the original CCI effectively reduces noise and false signals, improving the reliability of trading signals.
Intelligent Re-entry Mechanism: When the market resumes its original trend after an exit, the re-entry mechanism allows the system to recapture opportunities, enhancing the strategy’s profitability.
Good Visualization: The strategy displays clear background color changes on the chart, helping traders intuitively understand market conditions and trading signals.
Parameter Adjustability: All key parameters can be adjusted through the input interface, allowing the strategy to adapt to different market conditions and personal risk preferences.
Frequent Trading in Oscillating Markets: In range-bound markets, the indicator may frequently fluctuate around the thresholds, generating multiple buy and sell signals, leading to overtrading and commission erosion. Solution: Additional filtering conditions can be added, such as time filters or trend filters, to reduce trading frequency in oscillating markets.
Fixed Stop-Loss Magnitude Issue: The current strategy uses a fixed value (0.1 units) as the stop-loss magnitude, which may be too large or too small in market environments with different volatility levels. Solution: Design an adaptive stop-loss magnitude that dynamically adjusts the stop-loss distance based on recent market volatility.
Lack of Long-term Trend Confirmation: This strategy is primarily based on short-term momentum and does not incorporate long-term trend analysis, potentially generating unnecessary trades when the main trend reverses. Solution: Introduce long-period trend indicators as filters, only trading in the direction of the trend.
Timing Risk of Re-entry Mechanism: The current re-entry mechanism is based on a fixed rebound magnitude and may re-enter too early during market false breakouts. Solution: Add additional confirmation conditions, such as volume confirmation or complementary signals from other technical indicators.
Single Indicator Dependency: The strategy relies solely on the IFTCCI indicator for decision-making, lacking multi-dimensional market analysis. Solution: Introduce complementary indicator combinations, such as RSI, MACD, or volatility indicators, to provide multi-angle market confirmation.
Multiple Timeframe Analysis Integration: The current strategy operates on a single timeframe. It could integrate multiple timeframe analysis, for example, using the IFTCCI indicator from a higher timeframe as a trading direction filter, only trading in the direction of the larger trend. This can reduce counter-trend trading and improve win rates.
Dynamic Threshold Adjustment: Change the fixed thresholds (-0.95⁄0.95) to thresholds that dynamically adjust based on market volatility. Use narrower thresholds in low-volatility environments and wider thresholds in high-volatility environments to adapt to signal generation needs under different market conditions.
Volume Confirmation Mechanism: Add a volume analysis component, requiring significant volume support when signals are generated. This can filter out low-quality breakout signals and reduce losses from false breakouts.
Fund Management Optimization: The current strategy uses a fixed percentage for position management. This could be improved to an adaptive fund management system based on market volatility and win rates, increasing positions on high-confidence signals and reducing positions on low-confidence signals.
Machine Learning Enhancement: Use machine learning algorithms to adaptively optimize the parameters of the IFTCCI indicator (CCI period and WMA period), automatically adjusting the best parameter combinations according to different market environments to improve the strategy’s adaptability.
Trading Time Filter: Add a trading time filter to avoid high-volatility periods at market open and close, or avoid periods when important economic data is released, reducing unpredictable volatility caused by sudden events.
Correlation Analysis: Introduce correlation analysis with other markets or assets, enhancing the credibility of trading signals when multiple related markets simultaneously show similar signals, improving the robustness of the strategy.
The Adaptive Inverse Hyperbolic Tangent CCI Momentum Trading Strategy is a well-structured, logically clear quantitative trading system that generates trading signals through threshold breakouts of the IFTCCI indicator and is equipped with stop-loss and re-entry mechanisms to manage risk and capture opportunities. The main advantages of the strategy lie in its clear signals, dynamic risk control, and strong parameter adjustability.
However, the strategy also faces risks such as frequent trading in oscillating markets, inflexible fixed stop-loss magnitudes, and lack of long-term trend confirmation. By integrating multiple timeframe analysis, dynamically adjusting thresholds, adding volume confirmation, optimizing fund management, introducing machine learning enhancements, and adding trading time filters, the robustness and profitability of the strategy can be significantly improved.
For traders wishing to apply this strategy, it is recommended to first test different parameter combinations in a simulated environment to find the optimal settings for their trading instruments and risk preferences, and gradually integrate the optimization directions proposed in this article to build a more comprehensive and robust trading system.
/*backtest
start: 2024-05-27 00:00:00
end: 2025-01-20 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDT"}]
*/
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © erkankuskonmaz
//@version=5
strategy("IFTCCI Buy Sell Signal Strategy",
overlay=false,
pyramiding=0,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
calc_on_every_tick=true) // NEW LINE: Enables real-time signal generation.
// --- Indicator Settings and Calculations (IFTCCIv2) ---
group_indicator_params = "Indicator Parameters (IFTCCIv2)"
ccilength_param = input.int(5, "CCI Period", group=group_indicator_params)
wmalength_param = input.int(9, title="Smoothing Period (WMA)", group=group_indicator_params)
// IFTCCIv2 Calculation
v1_calc = 0.1 * (ta.cci(close, ccilength_param) / 4)
v2_calc = ta.wma(v1_calc, wmalength_param)
indicator_value_ift = (math.exp(2 * v2_calc) - 1) / (math.exp(2 * v2_calc) + 1)
// --- Strategy Rule Inputs ---
group_entry_rules = "Buy Signal Conditions"
entry_low_prev_max = input.float(-0.95, title="Primary Buy: Previous Bar Max Value", group=group_entry_rules)
entry_low_curr_min = input.float(-0.94, title="Primary Buy: Current Bar Min Value", group=group_entry_rules)
reentry_trigger_units = input.float(0.10, title="Re-entry: Rise from Lowest Value", group=group_entry_rules)
group_exit_rules = "Sell Signal Conditions (Exit Position)"
exit_high_prev_min = input.float(0.95, title="Target Sell: Previous Bar Min Value", group=group_exit_rules)
exit_high_curr_max = input.float(0.94, title="Target Sell: Current Bar Max Value", group=group_exit_rules)
stop_loss_units = input.float(0.10, title="Stop Loss: Drop from Peak Value", group=group_exit_rules)
// --- Indicator Values for Strategy ---
float ind_val = indicator_value_ift
float ind_val_prev = indicator_value_ift[1]
// --- State Tracking Variables ---
var float highest_indicator_since_long_entry = na
var bool track_for_reentry_after_close = false
var float lowest_indicator_since_reentry_tracking_started = na
// --- Update State Logic ---
// 1. Update the highest indicator value since entering long position
if strategy.position_size > 0
if strategy.position_size[1] <= 0
highest_indicator_since_long_entry := ind_val
else
highest_indicator_since_long_entry := math.max(highest_indicator_since_long_entry, ind_val)
else
if strategy.position_size[1] > 0
highest_indicator_since_long_entry := na
// 2. Update re-entry tracking mechanism
if strategy.position_size[1] > 0 and strategy.position_size == 0
track_for_reentry_after_close := true
lowest_indicator_since_reentry_tracking_started := ind_val
else if strategy.position_size > 0
track_for_reentry_after_close := false
lowest_indicator_since_reentry_tracking_started := na
else if track_for_reentry_after_close and strategy.position_size == 0
if not na(lowest_indicator_since_reentry_tracking_started)
lowest_indicator_since_reentry_tracking_started := math.min(lowest_indicator_since_reentry_tracking_started, ind_val)
else
lowest_indicator_since_reentry_tracking_started := ind_val
// --- Buy Conditions (Long Entry) ---
bool can_enter_new_position = strategy.opentrades == 0
// Condition 1: Main Buy Condition
bool condition_main_buy_cross = ind_val_prev <= entry_low_prev_max and ind_val >= entry_low_curr_min
bool main_long_entry_trigger = condition_main_buy_cross and can_enter_new_position
// Condition 2: Re-entry Buy Condition
bool condition_re_entry_trigger = false
if track_for_reentry_after_close and not na(lowest_indicator_since_reentry_tracking_started) and can_enter_new_position
if ind_val >= lowest_indicator_since_reentry_tracking_started + reentry_trigger_units
condition_re_entry_trigger := true
// Combined Buy Condition
bool final_long_entry_condition = main_long_entry_trigger or condition_re_entry_trigger
// --- Sell Conditions (Long Exit) ---
bool currently_in_long_position = strategy.position_size > 0
// Sell Condition 1: Target Sell
bool condition_sell_target = ind_val_prev >= exit_high_prev_min and ind_val <= exit_high_curr_max
// Sell Condition 2: Stop Loss
bool condition_sell_stop_loss = false
if currently_in_long_position and not na(highest_indicator_since_long_entry)
if ind_val <= highest_indicator_since_long_entry - stop_loss_units
condition_sell_stop_loss := true
// Combined Sell Condition
bool final_long_exit_condition = currently_in_long_position and (condition_sell_target or condition_sell_stop_loss)
// --- Strategy Orders ---
if (final_long_entry_condition)
entry_comment = main_long_entry_trigger ? "Buy (Primary)" : "Buy (Re-entry)"
strategy.entry("Buy ID", strategy.long, comment=entry_comment)
if (final_long_exit_condition)
exit_comment = condition_sell_target ? "Sell (Target)" : "Sell (Stop)"
strategy.close("Buy ID", comment=exit_comment)
// --- Plot Indicator and Strategy Markers ---
plot(indicator_value_ift, title="IFTCCI Value", color=color.rgb(0, 0, 0), linewidth=2)
hline(0, "Mid Level", color=color.new(#787b86, 50), linestyle=hline.style_dotted)
hline(0.95, "Upper Reference (+0.95)", color=color.new(#002fff, 10), linestyle=hline.style_dashed)
hline(-0.95, "Lower Reference (-0.95)", color=color.new(#002fff, 10), linestyle=hline.style_dashed)
// Background Coloring on Entry and Exit Signals
color background_color = final_long_entry_condition ? color.new(color.green, 81) : final_long_exit_condition ? color.new(color.red, 81) : na
bgcolor(background_color, title="Signal Background")