Half Trend Scalper Indicator for ThinkorSwim

L

LLSxCLC

New member
@BenTen Ohhh interesting. I never would have considered something like that lol. Any idea why the expansion area would mess with the indicator? Either way, thanks for your help. I really appreciate it!
 
  • Like
Reactions: ALF
D

Danzig

New member


Hello, I am having a similar issue with the HalfTrend. The indicator just continues all the way to the right. It still tracks the price candles but Like I said it continues across the screen. I already tried adjusting the expansion but did not change. Any ideas? Thank you.
 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Danzig Your expansion area is still way too far out. According to @LLSxCLC he was able to fix it after changing his expansion area.
 
J

john5788

New member
Modified the study to be imported as a scanner. Comment/uncomment the desired signal arrow to scan for at the bottom of the code.

Shareable link: https://tos.mx/H79KxEJ

Code:
# PRC_HalfTrend Scanner
# Original indicator study by Mobius Apr 2020
# Comment/uncomment desired plot at end of script
# 2020.08.20 -john5788

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;

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;
}
else if trend == 1
{
    down = Min(minhighprice, down[1]);
    up = up[1];
}
else
{
    up = up[1];
    down = down[1];
}

def UpSignal = up[1] < 1 and up > 0;
def DownSignal = down[1] < 1 and down > 0;

plot UpSignalArrow = UpSignal within 5 bars;
#plot DownSignalArrow = DownSignal within 5 bars;

# End Code
 
Last edited:
B

Bones

New member
Hello,

@BenTen Do you know if there is any Algo's or scalps for 5% to 15% percents, indicators?

thanks
 
B

Bobbydigital83

New member
VIP
Can anyone pass along a simple code that would show a arrow showing before the entry arrow is shown?

For example, if buy conditions are met,it would plot an arrow or a vertical line before the arrow entry?
 
T

theLEMband

New member
VIP
On a longer term basis, try adding the strategy with an amplitude of 1 for entry (delete or put "#" in front of the sell line) and add it again with an amplitude of 2 for exit (put "#" in front of the buy line). It is significantly better than buy and hold over the last 5 years on a daily chart.
 
S

sobiswas

New member
VIP
@BenTen Is there a way we can have this as a watchlist column? For like last 2 / 5 bars or configurable for that matter?
 
BenTen

BenTen

Administrative
Staff
VIP
@sobiswas Here is the watchlist column. If price is above the Halftrend = green. If below then red.

Code:
# PRC_HalfTrend | indicator
# 10.03.2017
# Ported by Mobius Apr 2020

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;
    }
AssignBackgroundcolor(if close > halftrend then color.green else color.red);
 
L

lmk99

Member
VIP
So... I re-wrote my re-written HalfTrend Indicator just using the TOS Accumulation Swing Index without any multi-time-frames.
And it is much more the scalping indicator that it is meant to be:


Here is http://tos.mx/ApTQPZa a copy of the code

This is great work, thank you for sharing. I want to make a small customization of adding another condition that has to be met in order for the buy and sell arrows to paint. For example, changing to something like this (the part I'm adding surrounded by asterisks):

Code:
def buy_criteria  =  ( bulltrend ****and MYVARIABLE>=1****) ;
def sell_criteria =  ASI_crossesbelow ;

#Order Setups
def buyTrigger = buy_criteria[-1] ****and MYVARIABLE>=1****;
plot buyTriggerPlot = if buyTrigger[1] ****and MYVARIABLE>=1**** then plotLow else Double.NaN;
buyTriggerPlot.SetDefaultColor(GlobalColor("VividCyan"));
buyTriggerPlot.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buyTriggerPlot.SetLineWeight(1);
buyTriggerPlot.HideTitle() ;

However, inserting this into any of these places doesn't work; the arrows are still painting even if the condition is violated. Is there somewhere else in the code that such a trigger condition would need to be placed?
 
N

ngunda

New member
VIP
Hello all!

Really appreciate all the efforts in this forum! great job.

I am wondering is there a final version of this study/WL column/scanner? and greatly appreciate if you can share TOS sharable links for the same?
 
BenTen

BenTen

Administrative
Staff
VIP
@ngunda You can get the script on the first page of this thread. Watch the video from this thread if you don't know how to use the scanner.

The watchlist column can be found here.
 
L

lmk99

Member
VIP
This is great work, thank you for sharing. I want to make a small customization of adding another condition that has to be met in order for the buy and sell arrows to paint. For example, changing to something like this (the part I'm adding surrounded by asterisks):

Code:
def buy_criteria  =  ( bulltrend ****and MYVARIABLE>=1****) ;
def sell_criteria =  ASI_crossesbelow ;

#Order Setups
def buyTrigger = buy_criteria[-1] ****and MYVARIABLE>=1****;
plot buyTriggerPlot = if buyTrigger[1] ****and MYVARIABLE>=1**** then plotLow else Double.NaN;
buyTriggerPlot.SetDefaultColor(GlobalColor("VividCyan"));
buyTriggerPlot.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buyTriggerPlot.SetLineWeight(1);
buyTriggerPlot.HideTitle() ;

However, inserting this into any of these places doesn't work; the arrows are still painting even if the condition is violated. Is there somewhere else in the code that such a trigger condition would need to be placed?

FYI if anyone is having a similar issue, for some reason that I don't understand adding my own variable trigger condition wouldn't work without using GetValue. But by using GetValue (e.g. "def CurrentMYVARIABLE = GetValue(MYVARIABLE, 0)"), it's working. The correct place to add it (e.g. "and CurrentMYVARIABLE >=1") was this line: "plot buyTriggerPlot"
 
L

lmk99

Member
VIP
Also, wanted to share that I tried adding this to the trigger for showing the buy arrows:

Code:
def lowavg = average(low,2);
plot buyTriggerPlot = if buyTrigger[1] and (lowavg[0]>=lowavg[1]) then plotLow else Double.NaN;

I can't see any downside of adding that. It seems to only have the result of preventing the buy arrows from painting in the beginning of downtrends. Is there any reason this isn't a significant improvement as it seems to be?
 
R

rj3137

New member
@BenTen I know you said in comment #19 that this indicator doesnt repaint aka disappear but this indicator definitely repaints. Im using renko and after it turned blue, signaling a buy, a red renko was formed and the blue went away and turned back to red. Is there a non repainting script? Appreciate your help

EDIT- The halftrend does not repaint
 
Last edited:

Similar threads

Top