NexusFi: Find Your Edge


Home Menu

 





Convert PineScript to ThinkScript. Tradeview to TOS


Discussion in Platforms and Indicators

Updated
    1. trending_up 6,569 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
SHASHA
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 )


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
CFTC Workforce Shrinks 24% to 15-Year Low While Predicti …
Traders Hideout
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 JayC 
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);


Reply With Quote
  #3 (permalink)
SHASHA
Vineland, New Jersey
 
Posts: 3 since Jan 2021
Thanks Given: 0
Thanks Received: 0



JayC View Post
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.


Reply With Quote
  #4 (permalink)
SHASHA
Vineland, New Jersey
 
Posts: 3 since Jan 2021
Thanks Given: 0
Thanks Received: 0

Anybody else with an attempt? Thanks


Reply With Quote




Last Updated on January 12, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts