Jacky Trend Expert For ThinkOrSwim

Tomahawk6117

Member
Plus
This is for a trend indicator.
The author states: The Trend Expert is a calculation of SMA and MA for a special trend formula to estimate the momentum of the daily trend.

How it reads:
1. Red candle is a short-term uptrend.
2. Green candle is a short-term downtrend.
3. The height of the candle is momentum price bet stronger or weaker.

Description: 1. Study the momentum of price and justify the mid-short-term trend line.
#// 2. Trend line Purple= Bear and Blue= Bull.
#// 3. Price candle height is momentum power. Green is momentum up, red is momentum down.
#// 4. Buy Target = green candle to red candle and above Bull trend line.
#// 5. Sell = red candle to green candle as short term sell. Or. Midterm Sell below trend line.


a1mo3Xw.png

Here is the original Tradingview code:
https://www.tradingview.com/v/TQZaT6lI/


For the new ThinkOrSwim code, you must scroll down to the next post
 
Last edited by a moderator:
  • I'm watching this!
Reactions: sum

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hello everyone,

May you please help me in converting the following Pinescript code to thinkscript for thinkorswim? It is for a trend indicator. The code is below and the link to the indicator is: https://www.tradingview.com/v/TQZaT6lI/. Thank you very much for your time and your help.

Code:
/////////////////////////////////////////////////////////////////////////////////////
//      Author: Jacky
//      Rev Date : Dec 10 2021, rev 2
//      Description: 1. Study the momentum of price and justify the Mid-shortterm trend line.
//                   2. Trend line Purple =  Bull and Green =  Bear.
//                   3. Price candle height is momentum power. Green is momentum up, red is momentum down.
//                   4. Thick Mainlines is Mid-shorterm trend, if red is Bear, and partial red is risk of trend change.
//                   5. Buy Target = green candle to red candle and above Bull trend line.
//                   6. Sell = red candle to green candle as short term sell. Or. Midterm Sell below trend line.
//@version=5
indicator(title='Jacky TE', shorttitle='Jacky Trend Expert', precision=3)
//Function
WEIGHT(values, length) =>
    f_val = float(na)
    f_val := ta.wma(values, length) * 3 - ta.sma(values, length) * 2
    f_val

// Calculating Trend expert
priceTrend = (close * 3 + open * 2 + low + high) / 7
Trend_ma = ta.ema(priceTrend, 3)
Weight_ma = WEIGHT(Trend_ma, 6)

trendline = math.avg(ta.ema(priceTrend, 21), ta.ema(priceTrend, 34), ta.ema(priceTrend, 68))

paletteT = trendline <= trendline[1] ? color.new(color.lime, 10) : color.new(color.purple, 10)

plot(WEIGHT(trendline, 6), title='trendline', color=paletteT, linewidth=2)

palette = Weight_ma >= Weight_ma[1] ? color.new(color.red, 0) : color.new(color.lime, 0)

higher = 0.000
lower = 0.000

if Weight_ma >= Weight_ma[1]
    higher := Weight_ma
    lower := Weight_ma[1]
    lower
else
    higher := Weight_ma[1]
    lower := Weight_ma
    lower

plotcandle(higher, higher, lower, lower, color=palette, bordercolor=palette, wickcolor=palette)
check the below:

CSS:
# Indicator for TOS
#// Author: Jacky
#// Rev Date : Dec 10 2021, rev 2
#// Description: 1. Study the momentum of price and justify the Mid-shortterm trend line.
#//              2. Trend line Purple =  Bull and Green =  Bear.
#//              3. Price candle height is momentum power. Green is momentum up, red is momentum down.
#//              4. Thick Mainlines is Mid-shorterm trend, if red is Bear, and partial red is risk of trend change.
#//              5. Buy Target = green candle to red candle and above Bull trend line.
#//              6. Sell = red candle to green candle as short term sell. Or. Midterm Sell below trend line.
#indicator(title='Jacky TE', shorttitle='Jacky Trend Expert', precision=3)
# Converted by Sam4Cok@Samer800     - 03/2025

Declare lower;
input colorBars = yes;

def na = Double.NaN;
def last = isNaN(Close);

#//Function
Script WEIGHT {
input values = close;
input length = 6;
    def f_val = wma(values, length) * 3 - Average(values, length) * 2;
    plot out = f_val;
}
#// Calculating Trend expert
def priceTrend = (close * 3 + open * 2 + low + high) / 7;
def Trend_ma = ExpAverage(priceTrend, 3);
def Weight_ma = WEIGHT(Trend_ma, 6);
def ema1 = ExpAverage(priceTrend, 21);
def ema2 = ExpAverage(priceTrend, 34);
def ema3 = ExpAverage(priceTrend, 68);
def trendL = (ema1 + ema2 + ema3) / 3;
def weighTL = WEIGHT(trendL, 6);

def higher;
def lower;

if Weight_ma >= Weight_ma[1] {
    higher = Weight_ma;
    lower = Weight_ma[1];
} else {
    higher = Weight_ma[1];
    lower = Weight_ma;
}

#-- plots

plot trendLine = if !last and weighTL then weighTL else na;
trendLine.AssignValueColor(if trendline > trendline[1] then Color.CYAN else Color.MAGENTA);

# Plot the new Chart
def dn = Weight_ma < Weight_ma[1];

AddChart(open = if dn then na else higher, high = higher , low = lower , close = if dn then na else lower,
         type = ChartType.CANDLE, growcolor = Color.GREEN);

AddChart(open = if dn then higher else na, high = higher , low = lower , close = if dn then lower else na,
         type = ChartType.CANDLE, growcolor = Color.RED);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if trendline > trendline[1] then
                 if dn then Color.DARK_GREEN else Color.GREEN else
                 if dn then Color.RED else Color.DARK_RED);
#-- END of CODE
 
check the below:

CSS:
# Indicator for TOS
#// Author: Jacky
#// Rev Date : Dec 10 2021, rev 2
#// Description: 1. Study the momentum of price and justify the Mid-shortterm trend line.
#//              2. Trend line Purple =  Bull and Green =  Bear.
#//              3. Price candle height is momentum power. Green is momentum up, red is momentum down.
#//              4. Thick Mainlines is Mid-shorterm trend, if red is Bear, and partial red is risk of trend change.
#//              5. Buy Target = green candle to red candle and above Bull trend line.
#//              6. Sell = red candle to green candle as short term sell. Or. Midterm Sell below trend line.
#indicator(title='Jacky TE', shorttitle='Jacky Trend Expert', precision=3)
# Converted by Sam4Cok@Samer800     - 03/2025

Declare lower;
input colorBars = yes;

def na = Double.NaN;
def last = isNaN(Close);

#//Function
Script WEIGHT {
input values = close;
input length = 6;
    def f_val = wma(values, length) * 3 - Average(values, length) * 2;
    plot out = f_val;
}
#// Calculating Trend expert
def priceTrend = (close * 3 + open * 2 + low + high) / 7;
def Trend_ma = ExpAverage(priceTrend, 3);
def Weight_ma = WEIGHT(Trend_ma, 6);
def ema1 = ExpAverage(priceTrend, 21);
def ema2 = ExpAverage(priceTrend, 34);
def ema3 = ExpAverage(priceTrend, 68);
def trendL = (ema1 + ema2 + ema3) / 3;
def weighTL = WEIGHT(trendL, 6);

def higher;
def lower;

if Weight_ma >= Weight_ma[1] {
    higher = Weight_ma;
    lower = Weight_ma[1];
} else {
    higher = Weight_ma[1];
    lower = Weight_ma;
}

#-- plots

plot trendLine = if !last and weighTL then weighTL else na;
trendLine.AssignValueColor(if trendline > trendline[1] then Color.CYAN else Color.MAGENTA);

# Plot the new Chart
def dn = Weight_ma < Weight_ma[1];

AddChart(open = if dn then na else higher, high = higher , low = lower , close = if dn then na else lower,
         type = ChartType.CANDLE, growcolor = Color.GREEN);

AddChart(open = if dn then higher else na, high = higher , low = lower , close = if dn then lower else na,
         type = ChartType.CANDLE, growcolor = Color.RED);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if trendline > trendline[1] then
                 if dn then Color.DARK_GREEN else Color.GREEN else
                 if dn then Color.RED else Color.DARK_RED);
#-- END of CODE
This looks really good @samer800, thank you very much for your help, I really appreciate it. Thank you very much for responding so quickly as well.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
419 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top