Author states: ScalpingTrend Buy/Sell is a simple and effective buy/sell indicator that works directly on the price chart. It is based on the classic WaveTrend oscillator and focuses solely on buy/sell signals.
Been really busy lately, but finally had time to sit down and code a bit. I've been having fun converting indicators from TradingView to Thinkorswim, and it's been a great way to learn the fundamentals of coding along the way. Found this indicator and thought it looked pretty simple, so I took a shot at converting it and I think it came out pretty well. If you spot anything I could improve, feel free to let me know. Always learning!
Here’s the original script (some variable names were tough to translate since they weren’t in English
)
https://www.tradingview.com/script/CxjCOZub/
Here is my code:
Been really busy lately, but finally had time to sit down and code a bit. I've been having fun converting indicators from TradingView to Thinkorswim, and it's been a great way to learn the fundamentals of coding along the way. Found this indicator and thought it looked pretty simple, so I took a shot at converting it and I think it came out pretty well. If you spot anything I could improve, feel free to let me know. Always learning!
Here’s the original script (some variable names were tough to translate since they weren’t in English
https://www.tradingview.com/script/CxjCOZub/
Here is my code:
Ruby:
#indicator(title="WaveTrend Overlay Al/Sat", shorttitle="WT_Overlay", overlay=true)
input n1 = 10;
input n2 = 21;
input reaction_wt = 1;
input only_sells_when_overbought = yes;
input only_buys_when_oversold = yes;
input nsc = 53;
input nsv = -53;
# === WaveTrend ===
def ap = hlc3;
def esa = expaverage(ap, n1);
def d = expaverage(absvalue(ap - esa), n1);
def ci = (ap - esa) / (0.015 * d);
def tci = expaverage(ci, n2);
def wt1 = tci;
def wt2 = simplemovingavg(ci, n2);
# === Buy/Sell Signals ===
def sell = wt1 crosses below wt2 and wt1 >= nsc and only_sells_when_overbought;
def sell_1 = wt1 crosses below wt2 and !only_sells_when_overbought;
def buy = wt1 crosses above wt2 and wt1 <= nsv and only_buys_when_oversold;
def buy_1 = wt1 crosses above wt2 and wt1 <= nsv and !only_buys_when_oversold;
assignpriceColor(if buy or buy_1 then color.green else if sell or sell_1 then color.red else color.current);
plot buyPlot = if buy or buy_1 then low else double.nan;
plot sellPlot = if sell or sell_1 then high else double.nan;
buyplot.setpaintingStrategy(paintingStrategy.BOOLEAN_arrow_up);
sellplot.setpaintingStrategy(paintingStrategy.BOOLEAN_arrow_down);
buyplot.setdefaultcolor(createcolor(57, 255, 20));
sellplot.setdefaultcolor(createcolor(255, 30, 60));
buyplot.setlineWeight(2);
sellplot.setlineWeight(2);
Last edited by a moderator: