I'm trying to write the Waddah Attar explosion in python, but I don't actually know pinescript and was wondering if I can get a little help. Writing up the math was easy, but the code to analyze the results was a little harder to understand. I put comments in the areas I don't understand and added an if statement at the end, since I want to use this in a screener I don't really need it to be plotted. Would really appreciate if someone could look this over and tell me how to complete the end. I'll provide the python code first and then the pinescript code. import yfinance as yf import talib as ta import numpy as np sensitivity = 150 fastLength = 20 slowLength = 40 channelLength = 20 mult = 2.0 deadZone = 20 data = yf.download("stock") def calc_macd(data,fastLength,slowLength): ema1 = ta.EMA(data, fastLength) ema2 = ta.EMA(data, slowLength) return ema1[len(ema1)-1]-ema2[len(ema2)-1] def calc_BBUpper(data,length,mult): basis = ta.SMA(data, length) #stdev stands for standard deviation, right? dev = mult * np.std(data) return basis[len(basis)-1] + dev def calc_BBLower(data,length,mult): basis = ta.SMA(data, length) dev = mult * np.std(data) return basis[len(basis)-1] - dev #what goes in for close[1] t1 = (calc_macd(data,fastLength,slowLength) - calc_macd(data1??,fastLength,slowLength)) * sensitivity #why is t2 even being calculated if it's not being used? t2 = (calc_macd(data2??,fastLength,slowLength) - calc_macd(data3??,fastLength,slowLength)) * sensitivity e1 = calc_BBUpper(data,channelLength,mult) - calc_BBLower(data,channelLength,mult) #this doesn't seem to actually calculate the color of the bar, and wouldn't it almost always return as an up trend this way? trendUp = t1 >= 0 #what is t1:0 trendDown = t1 < 0 #again what is -1*t1:0 if t1 > e1 and t1 > deadZone: print("is trade") https://www.tradingview.com/pine/?id=PUB;606 sensitivity = input(150, title="Sensitivity") fastLength=input(20, title="FastEMA Length") slowLength=input(40, title="SlowEMA Length") channelLength=input(20, title="BB Channel Length") mult=input(2.0, title="BB Stdev Multiplier") deadZone=input(20, title="No trade zone threshold") calc_macd(source, fastLength, slowLength) => fastMA = ema(source, fastLength) slowMA = ema(source, slowLength) fastMA - slowMA calc_BBUpper(source, length, mult) => basis = sma(source, length) dev = mult * stdev(source, length) basis + dev calc_BBLower(source, length, mult) => basis = sma(source, length) dev = mult * stdev(source, length) basis - dev t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength))*sensitivity t2 = (calc_macd(close[2], fastLength, slowLength) - calc_macd(close[3], fastLength, slowLength))*sensitivity e1 = (calc_BBUpper(close, channelLength, mult) - calc_BBLower(close, channelLength, mult)) //e2 = (calc_BBUpper(close[1], channelLength, mult) - calc_BBLower(close[1], channelLength, mult)) trendUp = (t1 >= 0) ? t1 : 0 trendDown = (t1 < 0) ? (-1*t1) : 0 plot(trendUp, style=columns, linewidth=1, color=(trendUp<trendUp[1])?lime:green, transp=45, title="UpTrend") plot(trendDown, style=columns, linewidth=1, color=(trendDown<trendDown[1])?orange:red, transp=45, title="DownTrend") plot(e1, style=line, linewidth=2, color=#A0522D, title="ExplosionLine") hline(deadZone, color=blue, linewidth=2, title="DeadZoneLine") Continue reading...