- ago
I was discussing trading strategies with Claude AI, and it introduced me to a topic I wasn't familiar with: Confluence Zones

I would love to experiment with this in some backtests, if it's something that the team might consider adding as a Trading Indicator in WL8. Claude provided some sample code in case it's helpful:

CODE:
using WealthLab; using System; public class ConfluentLevels : IndicatorBase { // Parameters that can be adjusted in WealthLab [Parameter("Entry Threshold", DefaultValue = 2)] public int EntryThreshold { get; set; } [Parameter("Exit Threshold", DefaultValue = 1)] public int ExitThreshold { get; set; } [Parameter("Lookback Period", DefaultValue = 3)] public int LookbackPeriod { get; set; } [Parameter("Confluence Tolerance %", DefaultValue = 0.1)] public double TolerancePercent { get; set; } public ConfluentLevels(BarHistory bars) : base(bars) { Name = "Confluent Levels (Fib + Pivot)"; } public override void Calculate() { // Create series for results var confluenceStrength = new TimeSeries(Bars, "ConfluenceStrength"); var entrySignal = new TimeSeries(Bars, "EntrySignal"); var exitSignal = new TimeSeries(Bars, "ExitSignal"); var trendDirection = new TimeSeries(Bars, "TrendDirection"); var high = Bars.High; var low = Bars.Low; var close = Bars.Close; for(int bar = LookbackPeriod; bar < Bars.Count; bar++) { // Calculate HLC double hlc = (high[bar] + low[bar] + close[bar]) / 3; // Calculate Pivot Points double pivotHigh = 2.0 * hlc - high[bar]; double pivotLow = 2.0 * hlc - low[bar]; // Calculate Fibonacci levels double range = high[bar] - low[bar]; double tolerance = range * (TolerancePercent / 100.0); double[] fibLevels = { high[bar] - (0.236 * range), // 23.6% high[bar] - (0.382 * range), // 38.2% high[bar] - (0.500 * range), // 50.0% high[bar] - (0.618 * range), // 61.8% high[bar] - (0.786 * range) // 78.6% }; // Count confluences int confluences = 0; // Check each Fib level against Pivot Points foreach(double fibLevel in fibLevels) { if (Math.Abs(fibLevel - pivotHigh) <= tolerance) confluences++; if (Math.Abs(fibLevel - pivotLow) <= tolerance) confluences++; } // Store base confluence strength confluenceStrength[bar] = confluences; // Determine trend direction (simple 3-bar momentum) trendDirection[bar] = close[bar] > close[bar - LookbackPeriod] ? 1 : -1; // Generate entry signals if (confluences >= EntryThreshold) { // Long entry when price is above pivot and trend is up if (close[bar] > hlc && trendDirection[bar] > 0) entrySignal[bar] = 1; // Short entry when price is below pivot and trend is down else if (close[bar] < hlc && trendDirection[bar] < 0) entrySignal[bar] = -1; } // Generate exit signals if (confluences <= ExitThreshold) { // Look at previous bars to determine if we're in a long or short double avgClose = 0; for(int i = 1; i <= LookbackPeriod; i++) avgClose += close[bar - i]; avgClose /= LookbackPeriod; // Exit long positions if (close[bar] < avgClose) exitSignal[bar] = 1; // Exit short positions else if (close[bar] > avgClose) exitSignal[bar] = -1; } } } public override string Name { get { return "Confluent Levels"; } } }
0
96
0 Replies

Reply

Bookmark

Sort
Currently there are no replies yet. Please check back later.