Hi all, so I just happened to be scanning TradingView and found the Lux Algo -- thought it looked interesting so I came on here, and saw this discussion. Here is my first attempt at coding this, using a combination of the Adaptive Zones study and the Wave Oscillator study. This is an upper study, but I included the Wave Oscillator in the lower area for reference. It allows options for signals from both studies, but the signals are based on having signals from BOTH studies fire off within 3 candles of each other.
This is my first longer indicator I've coded, so any feedback/criticism is more than welcome.
Code:
# Adaptive Zones with Wave Oscillator for Momentum
# Adaptive Price Zone by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/eoz8cGtU-Adaptive-Price-Zone-Indicator/
# Wave oscillator by LazyBear on TV... I think
input nPeriods = 200;
input nBandPct = 3;
input price = close;
input showAdaptive = no;
def xHL = high - low;
def nP = ceil(sqrt(nPeriods));
def xVal1 = expAverage(expAverage(close, nP), nP);
def xVal2 = expAverage(expAverage(xHL, nP), nP);
def UpBand = nBandPct * xVal2 + xVal1;
def DnBand = xVal1 - nBandPct * xVal2;
plot ub = UpBand;
plot db = DnBand;
ub.AssignValueColor(color.CYAN);
db.AssignValueColor(color.MAGENTA);
## Adaptive bands rejection/cross signals
def uppies = price > dnband and low[1] <= dnband;
def downies = price < upband and high[1] >= upband;
def downsig = downies and (downies[1] is false and downies[2] is false and downies[3] is false
and downies[4] is false and downies[5] is false);
def upsig = uppies and (uppies[1] is false and uppies[2] is false and uppies[3] is false
and uppies[4] is false and uppies[5] is false);
plot crossArrowsUp = upsig and showAdaptive;
crossArrowsUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
crossArrowsUp.SetDefaultColor(Color.green);
crossArrowsUp.SetLineWeight(1);
plot crossArrowsDn = downsig and showAdaptive;
crossArrowsDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
crossArrowsDn.SetDefaultColor(Color.red);
crossArrowsDn.SetLineWeight(1);
## Wavetrend Oscillator section
input Channel_Length = 10; #10
input Average_Length = 21; #10
def over_bought_1 = 60;
def over_bought_2 = 53;
def over_sold_1 = -60;
def over_sold_2 = -53;
input show_wave_alerts = no;
def ap = hlc3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);
## Wave Signal Logic
def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
def Signal = if signal1 then (signal1 * over_sold_2) else Double.NaN;
def signal2 = wt1 crosses below wt2 and wt1 > over_bought_2;
def Signal2_ = if signal2 then (signal2 * over_bought_2) else Double.NaN;
plot wave_up = if show_wave_alerts and signal1 then (signal1 * over_sold_2) else Double.NaN;
wave_up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
wave_up.SetDefaultColor(Color.light_green);
wave_up.SetLineWeight(1);
plot wave_down = if show_wave_alerts and signal2 then (signal2 * over_bought_2) else Double.NaN;
wave_down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
wave_down.SetDefaultColor(Color.red);
wave_down.SetLineWeight(1);
def full_sig_up = (signal is true and upsig) or (signal is true and upsig[1]) or (signal is true and upsig[2])
or (signal is true and upsig[3]) or (upsig and signal[1] is true) or (upsig and signal[2] is true)
or (upsig and signal[3] is true);
plot Long = full_sig_up;
Long.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Long.SetDefaultColor(Color.dark_green);
Long.SetLineWeight(5);
def full_sig_dn = (signal2_ is true and downsig) or (signal2_ is true and downsig[1]) or (signal2_ is true
and downsig[2]) or (signal2_ is true and downsig[3]) or (downsig and signal2_[1] is true)
or (downsig and signal2_[2] is true) or (downsig and signal2_[3] is true);
plot Short = full_sig_dn;
Short.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Short.SetDefaultColor(Color.dark_red);
Short.SetLineWeight(5);