The Catchnet Indicator
The Catchnet Strategy: by cerlc
The Catchnet Strategy is a sophisticated trading system designed for experienced traders who want to maximize their profits by leveraging technical indicators and advanced techniques. This strategy is built using the Pine Script programming language and can be implemented on various trading platforms, such as TradingView. The code is written in version 5 and includes features such as dynamic exits, trade statistics, and customizable settings to cater to individual preferences.
Key Components and Functions of the Catcher Strategy:
1. Entry Conditions: The strategy uses two primary entry conditions to signal long and short trades. These conditions are based on the crossover of the close price and the 50-period Simple Moving Average (SMA) for long trades and the 50-period SMA for short trades.
2. Dynamic Exits: The strategy incorporates dynamic exit conditions to optimize trade exits. These conditions are based on the crossover of the close price and the 20-period SMA for long trades and the 20-period SMA for short trades. The dynamic exit conditions are designed to adapt to changing market conditions and can be enabled or disabled using the "Use Dynamic Exits" input.
3. Fixed Exit Conditions: In addition to dynamic exit conditions, the strategy also includes fixed exit conditions based on the crossover of the close price and the 10-period SMA for long trades and the 10-period SMA for short trades. These fixed exit conditions can serve as a backup in case the dynamic exit conditions do not trigger.
4. Trade Statistics: The strategy can display trade statistics, including total wins, total losses, total trades, win-loss ratio, and win rate. These statistics can be useful for evaluating the performance of the strategy over time.
5. Alerts: The strategy can generate alerts for various events, such as opening and closing long and short trades. These alerts can be used to notify traders of potential trading opportunities and help them stay up-to-date with the latest market developments.
6. Display Trade Statistics Table: The strategy can display a trade statistics table that includes the total number of trades, total wins, total losses, win-loss ratio, and win rate. This table can be used to visualize the performance of the strategy and make informed decisions about its effectiveness.
7. Custom Fractal Function: The strategy includes a custom fractal function that can be used to identify potential trend reversals and generate alerts for bullish and bearish changes.
Backtesting and Real-time Stats: The strategy supports backtesting to evaluate its performance over historical data and real-time stats to monitor its performance in real-time trading.
//@version=5 indicator("Catchnet", overlay=true) // Strategy Settings settings = input(true, title="Settings") useDynamicExits = input(true, title="Use Dynamic Exits") useAtrOffset = input(true, title="Use ATR Offset") showExits = input(true, title="Show Exits on Chart") showTradeStats = input(true, title="Show Trade Statistics") // Entry Conditions startLongTrade = ta.crossover(close, ta.sma(close, 50)) startShortTrade = ta.crossunder(close, ta.sma(close, 50)) // Dynamic Exit Conditions endLongTradeDynamic = ta.crossover(close, ta.sma(close, 20)) endShortTradeDynamic = ta.crossunder(close, ta.sma(close, 20)) isValidLongExit = ta.barssince(endLongTradeDynamic) > ta.barssince(startLongTrade) isValidShortExit = ta.barssince(endShortTradeDynamic) > ta.barssince(startShortTrade) // Fixed Exit Conditions endLongTradeStrict = ta.crossover(close, ta.sma(close, 10)) endShortTradeStrict = ta.crossunder(close, ta.sma(close, 10)) // Combine Exit Conditions endLongTrade = useDynamicExits ? endLongTradeDynamic and isValidLongExit[1] : endLongTradeStrict endShortTrade = useDynamicExits ? endShortTradeDynamic and isValidShortExit[1] : endShortTradeStrict // Plotting Signals and Exits plotshape(startLongTrade, color=color.green, style=shape.labelup, title="Buy Signal", text="Buy") plotshape(startShortTrade, color=color.red, style=shape.labeldown, title="Sell Signal", text="Sell") plotshape(endLongTrade and showExits, color=color.blue, style=shape.xcross, title="Exit Long", text="Exit Long") plotshape(endShortTrade and showExits, color=color.orange, style=shape.xcross, title="Exit Short", text="Exit Short") // Alerts alertcondition(startLongTrade, title="Open Long ▲", message="Open Long") alertcondition(endLongTrade, title="Close Long ▼", message="Close Long") alertcondition(startShortTrade, title="Open Short ▼", message="Open Short") alertcondition(endShortTrade, title="Close Short ▲", message="Close Short") // Display Trade Statistics if showTradeStats totalWins = 0 totalLosses = 0 totalTrades = 0 tradeStatsHeader = "Trade Statistics" winLossRatio = 0 winRate = 0 // Display Trade Stats Table if barstate.islast totalTrades := totalTrades + 1 if endLongTrade and startLongTrade[1] totalWins := totalWins + 1 else if endShortTrade and startShortTrade[1] totalLosses := totalLosses + 1 winLossRatio := totalWins / totalLosses winRate := totalWins / totalTrades // var tbl = ta.new_table(position.top_right, columns=2, rows=7) // if barstate.islast // ta.cell(tbl, 0, 0, tradeStatsHeader, text_halign=text.align_center, text_color=color.gray, text_size=size.normal) // ta.cell(tbl, 1, 1, str.tostring(totalWins / totalTrades, '#.#%'), text_halign=text.align_center, text_color=color.gray, text_size=size.normal) // ta.cell(tbl, 1, 2, str.tostring(totalTrades, '#') + ' (' + str.tostring(totalWins, '#') + '|' + str.tostring(totalLosses, '#') + ')', text_halign=text.align_center, text_color=color.gray, text_size=size.normal) // ta.cell(tbl, 1, 5, str.tostring(totalWins / totalLosses, '0.00'), text_halign=text.align_center, text_color=color.gray, text_size=size.normal) // ta.cell(tbl, 1, 6, str.tostring(totalEarlySignalFlips, '#'), text_halign=text.align_center, text_color=color.gray, text_size=size.normal) // Fractal Filters and Kernel Regression Filters isBullishChange = ta.change(close) > 0 isBearishChange = ta.change(close) < 0 // Custom Fractal Function fractalize(src, length) => highestHigh = ta.highest(src, length) lowestLow = ta.lowest(src, length) isFractalHigh = ta.crossover(src, highestHigh) isFractalLow = ta.crossunder(src, lowestLow) fractal = isFractalHigh ? 1 : isFractalLow ? -1 : 0 fractal alertBullish = ta.crossover(close, fractalize(close, 5)) alertBearish = ta.crossunder(close, fractalize(close, 5)) // Backtesting and Real-time Stats // [totalWins, totalLosses, totalEarlySignalFlips, totalTrades, tradeStatsHeader, winLossRatio, winRate] = ml.backtest(high, low, open, startLongTrade, endLongTrade, startShortTrade, endShortTrade, isEarlySignalFlip, maxBarsBackIndex, bar_index, settings.source, useWorstCase) // Display Trade Stats Table // if showTradeStats // var tbl = ml.init_table() // if barstate.islast // ml.update_table(tbl, tradeStatsHeader, totalTrades, totalWins, totalLosses, winLossRatio, winRate, totalEarlySignalFlips) // Plotting Labels showBarPredictions = input(true, "Show Bar Predictions") showBarColors = input(true, "Show Bar Colors") atrSpaced = useAtrOffset ? ta.atr(1) : na c_pred = close > ta.sma(close, 20) ? color.green : color.red c_label = showBarPredictions ? c_pred : na c_bars = showBarColors ? color.new(c_pred, 50) : na x_val = bar_index y_val = useAtrOffset ? close > ta.sma(close, 20) ? high + atrSpaced : low - atrSpaced : close > ta.sma(close, 20) ? high + close * 0.02 : low - close * 0.03 label.new(x_val, y_val, str.tostring(close), xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_up, c_label, size.normal, text.align_left) barcolor(showBarColors ? c_pred : na)
Feel free to be a contributor: https://tradingview.com/script/MPvIHKon-Catcher/