Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Convert PineScript to ThinkScript. Tradeview to TOS
Updated January 12, 2021
trending_up
5,687 views
thumb_up
0 thanks given
group
2 followers
forum
3 posts
attach_file
0 attachments
Convert PineScript to ThinkScript. Tradeview to TOS
January 11th, 2021, 09:29 PM
Vineland, New Jersey
Posts: 3 since Jan 2021
Thanks Given: 0
Thanks Received: 0
Can anyone convert this TradingView PineScript to TOS ThinkScript?
Thank you very much in advance!!
//@version=4
study(title="Beep Boop", shorttitle="Beep Boop", resolution="")
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
EMATrend = input(title="EMA Trend", type=input.integer, defval=50)
src = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)
col_grow_above = #26A69A
col_grow_below = #FF0000
col_fall_above = #FFFFFF
col_fall_below = #FFFFFF
col_macd = #0094ff
col_signal = #ff6a00
fast_ma = sma_source ? sma (src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal
if (hist > 0)
hist := 0.1
if (hist < 0)
hist := 0.09
fastMA = ema(close, EMATrend)
//fastMA = 0
plot(hist, title="Histogram", style=plot.style_columns, color=(hist == 0.1 ? ((hist == 0.1) and (close > fastMA) and (open > fastMA) and (low > fastMA) ? col_grow_above : col_fall_above) : ((hist == 0.09) and (close < fastMA) and (open < fastMA) and (high < fastMA)? col_grow_below : col_fall_below) ), transp=0 )
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
January 12th, 2021, 02:11 AM
San Diego, CA
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43
Not really sure I have this right but here's an attempt.
Jay
Code
declare lower;
declare zerobase;
input fast_length = 12;
input slow_length = 26;
input EMATrend = 50;
input src = close;
input signal_length = 9;
input sma_source = {default "No", "Yes"};
input sma_signal = {default "No", "Yes"};
def fast_ma = if sma_source then SimpleMovingAvg(src, fast_length) else MovAvgExponential(src, fast_length);
def slow_ma = if sma_source then SimpleMovingAvg(src, slow_length) else MovAvgExponential(src, slow_length);
def macd = fast_ma - slow_ma;
def signal = if sma_signal then SimpleMovingAvg(macd, signal_length) else MovAvgExponential(macd, signal_length);
def hist = if macd - signal > 0 then 0.1 else if macd - signal < 0 then 0.09 else macd - signal;
def fastMA = MovAvgExponential(close, EMATrend);
plot histPlot = hist;
histPlot.DefineColor("grow_above", CreateColor(38, 166, 154));
histPlot.DefineColor("grow_below", CreateColor(255, 0, 0));
histPlot.DefineColor("fall_above", CreateColor(255, 255, 255));
histPlot.DefineColor("fall_below", CreateColor(255, 255, 255));
histPlot.DefineColor("macd", CreateColor(0, 148, 255));
histPlot.DefineColor("signal", CreateColor(255, 106, 0));
histPlot.AssignValueColor(
if hist == 0.1 and close > fastMA and open > fastMA and low > fastMA then
histPlot.color("grow_above")
else if hist == 0.1 then
histPlot.color("fall_above")
else if hist == 0.09 and close < fastMA and open < fastMA and high < fastMA then
histPlot.color("grow_below")
else histPlot.color("fall_below")
);
histPlot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
January 12th, 2021, 06:55 PM
Vineland, New Jersey
Posts: 3 since Jan 2021
Thanks Given: 0
Thanks Received: 0
JayC
Not really sure I have this right but here's an attempt.
Jay
Code
declare lower;
declare zerobase;
input fast_length = 12;
input slow_length = 26;
input EMATrend = 50;
input src = close;
input signal_length = 9;
input sma_source = {default "No", "Yes"};
input sma_signal = {default "No", "Yes"};
def fast_ma = if sma_source then SimpleMovingAvg(src, fast_length) else MovAvgExponential(src, fast_length);
def slow_ma = if sma_source then SimpleMovingAvg(src, slow_length) else MovAvgExponential(src, slow_length);
def macd = fast_ma - slow_ma;
def signal = if sma_signal then SimpleMovingAvg(macd, signal_length) else MovAvgExponential(macd, signal_length);
def hist = if macd - signal > 0 then 0.1 else if macd - signal < 0 then 0.09 else macd - signal;
def fastMA = MovAvgExponential(close, EMATrend);
plot histPlot = hist;
histPlot.DefineColor("grow_above", CreateColor(38, 166, 154));
histPlot.DefineColor("grow_below", CreateColor(255, 0, 0));
histPlot.DefineColor("fall_above", CreateColor(255, 255, 255));
histPlot.DefineColor("fall_below", CreateColor(255, 255, 255));
histPlot.DefineColor("macd", CreateColor(0, 148, 255));
histPlot.DefineColor("signal", CreateColor(255, 106, 0));
histPlot.AssignValueColor(
if hist == 0.1 and close > fastMA and open > fastMA and low > fastMA then
histPlot.color("grow_above")
else if hist == 0.1 then
histPlot.color("fall_above")
else if hist == 0.09 and close < fastMA and open < fastMA and high < fastMA then
histPlot.color("grow_below")
else histPlot.color("fall_below")
);
histPlot.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
Thanks for the attempt. Seems slightly off but very close. Much appreciated.
January 12th, 2021, 06:56 PM
Vineland, New Jersey
Posts: 3 since Jan 2021
Thanks Given: 0
Thanks Received: 0
Anybody else with an attempt? Thanks
Last Updated on January 12, 2021