Convert PineScript to ThinkScript. Tradeview to TOS - futures io
futures io futures trading



Convert PineScript to ThinkScript. Tradeview to TOS


Discussion in Platforms and Indicators

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Convert PineScript to ThinkScript. Tradeview to TOS

(login for full post details)
  #1 (permalink)
Vineland, New Jersey
 
 
Posts: 3 since Jan 2021
Thanks: 0 given, 0 received

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

 
Best Threads (Most Thanked)
in the last 7 days on futures io
The war of the two worlds (options traders vs futures traders)
111 thanks
GME GameStop Corp
62 thanks
Spoo-nalysis ES e-mini futures S&P 500
60 thanks
How did you learn to trade?
38 thanks
The Small Exchange (www.smallexchange.com)
35 thanks
 
(login for full post details)
  #2 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 26 since Mar 2019
Thanks: 4 given, 16 received

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
 
(login for full post details)
  #3 (permalink)
Vineland, New Jersey
 
 
Posts: 3 since Jan 2021
Thanks: 0 given, 0 received



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
 
(login for full post details)
  #4 (permalink)
Vineland, New Jersey
 
 
Posts: 3 since Jan 2021
Thanks: 0 given, 0 received

Anybody else with an attempt? Thanks

Reply With Quote


futures io Trading Community Platforms and Indicators > Convert PineScript to ThinkScript. Tradeview to TOS


Last Updated on January 12, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Finding Trading Opportunities Using Profile Charts w/Tradovate

Jan 28
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts