BenTen, Thanks for your very tight could using conditional logic rather than direct assignment like “trend = 0”! I’m not a TOS user yet, but your code will translate to an application I use that permits only assignment to another function or macro that is set to 0. Appreciated, Pat
I found that the only way to keep the trendline from showing as red is to have zero periods of expansion on the right edge. I actually like about 10 periods on the right side. Zero makes me feel claustrophobic being right up against the wall. But I guess I'll live with it unless someone can figure out why it wants to keep making the last period of the trendline red.
Has anyone tried this in real trade? Was looking for HT code for tos and found this one.
Is the original settings good for holding a trend trade or would it be better to change for other instruments like /NQ? I am looking for a 5m TF setups for /ES and /NQ.
Has anyone tried this in real trade? Was looking for HT code for tos and found this one.
Is the original settings good for holding a trend trade or would it be better to change for other instruments like /NQ? I am looking for a 5m TF setups for /ES and /NQ.
Recommend you put it on your chart. Nothing beats personal experience The only way you will know what works best for you is to play with the settings and see how the indicator line up w/ your strategy and with your other indicators. To determine if this indicator brings value, analyze it over different timeframes, across history and with multiple instruments.
Can someone help with a lower study to show signal/alert on condition when one or more higher timeframes are in sync (same trend -uptrend or downtrend) with trend in current chart. Eg: I am swing trading on 15 min and want to have signal/alert (as a lower study) when 15 min, 30 min and 1 hour are in the same trend (up or down ) as current 15 min. chart.
I have downloaded the Half Trend indicator and scanner and started paper trading the buy/sell signals. Would like to create a TOS alert when the indicator has an UP (Buy) or DOWN (Sell) arrow on the indicator.
# PRC_HalfTrend Scanner
# Original indicator study by Mobius Apr 2020
# Comment/uncomment desired plot at end of script
# 2020.08.20 -john5788
@Kallyone@Richard Lamkin
So.... It would seem from reading through this thread, alerts have been problematic.
It "could" be because the indicator has a lag.
Theoretically, if we set it to look back two bars, the alerts might fire.
BUT there may be other problems. I don't use this indicator. The following snippet is untested.
Add this to the bottom of your script:
Ruby:
Alert(UpSignal within 2 bars, "upSignal", Alert.Bar, Sound.Chimes);
Alert(DownSignal within 2 bars, "downSignal", Alert.Bar, Sound.Chimes);
Half Trend is a scalping indicator for ThinkorSwim converted by developer Mobius. This is my first time hearing about the script, but Half Trend seems to be quite popular among Forex traders. Also, it was only available for other platforms such as MT4. Now you can use it on ThinkorSwim
A quick search on Google will allow you to learn more about the Half Trend indicator, potential setups, and usage.
thinkScript Code
Code:
# PRC_HalfTrend | indicator
# 10.03.2017
# Ported by Mobius Apr 2020
# Arrows added by @shortyuk (https://usethinkscript.com/threads/half-trend-scalper-indicator-for-thinkorswim.3305/post-30413)
input Amplitude = 3;
def lowpricei;
def highpricei;
def lowma;
def highma;
def barindex = barNumber();
def nexttrend;
def maxlowprice;
def trend;
def minhighprice;
def up;
def down;
plot halftrend;
lowpricei = Lowest(low, Amplitude);
highpricei = Highest(high, Amplitude);
lowma = average(low, Amplitude);
highma = average(high, Amplitude);
if barindex > Amplitude and
nexttrend[1] == 1
{
maxlowprice = Max(lowpricei, maxlowprice[1]);
trend = if highma < maxlowprice[1] and close < low[1]
then 1
else trend[1];
nexttrend = if highma < maxlowprice[1] and close < low[1]
then 0
else nexttrend[1];
minhighprice = if highma < maxlowprice[1] and close < low[1]
then highpricei
else minhighprice[1];
}
else if nexttrend[1] == 0
{
minhighprice = Min(highpricei, minhighprice[1]);
trend = if lowma > minhighprice[1] and close > high[1]
then 0
else trend[1];
nexttrend = if lowma > minhighprice[1] and close > high[1]
then 1
else nexttrend[1];
maxlowprice = if lowma > minhighprice[1] and close > high[1]
then lowpricei
else maxlowprice[1];
}
else
{
maxlowprice = maxlowprice[1];
trend = trend[1];
nexttrend = nexttrend[1];
minhighprice = minhighprice[1];
}
if trend == 0
{
up = if trend[1] <> 0
then down[1]
else Max(maxlowprice[1], up[1]);
down = 0;
}
else if trend[1] <> 1
{
down = up[1];
up = 0;# up[1] este era el error
}
else if trend == 1
{
down = Min(minhighprice, down[1]);
up = up[1];
}
else
{
up =up[1];
down = down[1];
}
if up > 0
{
halftrend = up;
}
else
{
halftrend = down;
}
halftrend.SetStyle(Curve.Firm);
halftrend.AssignValueColor(if up > 0 then color.cyan else color.red);
halftrend.SetLineWeight(2);
plot UpSignal = if up[1]<1 and up>0 then low else Double.NaN;
plot DownSignal = if down[1]<1 and down>0 then high else Double.NaN;
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
UpSignal.SetDefaultColor(Color.Cyan);
DownSignal.SetDefaultColor(Color.Red);
UpSignal.SetLineWeight(3);
DownSignal.SetLineWeight(3);
# End Code
Backtesting Snippet
Add the following to your existing script, then add the entire indicator as a new strategy:
Might not work, given the problems with this indicator.
You can try adding this to the bottom of your script:
Ruby:
input paintcandles = yes ;
AssignBackgroundColor(if !paintcandles then color.current else
if upsignal then color.cyan else
if downsignal then color.magenta else color.current);
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.
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.