Trend Painter Indicator With Buy & Sell Signals for ThinkorSwim

murkr

murkr

Member
VIP
@BonBon Okay so I'm slightly modifying the original #1 post's code then? because that part is from post #1.

Now my Trendpainter code looks like this below.

Code:
input ThermoLookBackBars = 50;
input PlotType = {default AdaptiveMovingAverages, Standard};

def HighLowScore = 1000 * ((high - high[1]) / (high[1]) +
(low - low[1]) / low[1]);

#ATR TrailingStop Code
input trailType = {default modified, unmodified};
input ATRPeriod = 5;
input ATRFactor = 3.5;
input firstTrade = {default long, short};

def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
    then high - close[1]
    else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
    then close[1] - low
    else (close[1] - low) - 0.5 * (low[1] - high);
def ATRMod = ExpAverage(Max(HiLo, Max(HRef, LRef)), 2 * ATRPeriod - 1);

def loss;
switch (trailType) {
case modified:
    loss = ATRFactor * ATRMod;
case unmodified:
    loss = ATRFactor * Average(TrueRange(high,  close,  low),  ATRPeriod);
}

rec state = {default init, long, short};
rec trail;
switch (state[1]) {
case init:
    if (!IsNaN(loss)) {
        switch (firstTrade) {
        case long:
            state = state.long;
            trail =  close - loss;
        case short:
            state = state.short;
            trail = close + loss;
    }
    } else {
        state = state.init;
        trail = Double.NaN;
    }
case long:
    if (close > trail[1]) {
        state = state.long;
        trail = Max(trail[1], close - loss);
    }
    else {
        state = state.short;
        trail = close + loss;
    }
case short:
    if (close < trail[1]) {
        state = state.short;
        trail = Min(trail[1], close + loss);
    }
    else {
        state = state.long;
        trail =  close - loss;
    }
}

def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);

plot TrailingStop = trail;
TrailingStop.Hide();
#End ATR Trailing Stop Code

def A = Highest(high[1], ThermoLookBackBars);
def B = Lowest(low[1], ThermoLookBackBars);

def FiftyTwoWeekHigh = A;

def FiftyTwoWeekLow = B;

def FiftyTwoWeekScore = 10 * (((high
- FiftyTwoWeekHigh) / FiftyTwoWeekHigh) +
((low - FiftyTwoWeekLow) / FiftyTwoWeekLow));

def ThermoScore = ExpAverage(HighLowScore + FiftyTwoWeekScore, ThermoLookBackBars);

input FastLengthShort = 5;
input SlowLengthShort = 15;
input EffRatioShort = 10;
input FastLengthLong = 10;
input SlowLengthLong = 25;
input EffRatioLong = 5;

def AMA = MovAvgAdaptive(ThermoScore, FastLengthShort, SlowLengthShort, EffRatioShort);
def AMA2 = MovAvgAdaptive(ThermoScore, FastLengthLong, SlowLengthLong, EffRatioLong);

plot Line1;
Line1.Hide();
plot Line2;
Line2.Hide();

switch (PlotType) {
case AdaptiveMovingAverages:
    Line1 = AMA;
    Line2 = AMA2;
case Standard:
    Line1 = ThermoScore;
    Line2 = ThermoScore;
}

def InvisibleLine = close * 0;
plot Line3 = InvisibleLine;
Line3.Hide();

def Buy = Line1 > 0 and Line2 < 0 and state == state.long;
def StrongBuy = Line1 > 0 and Line2 >= 0 and state == state.long;
def Sell = Line1 < 0 and Line2 > 0 and state == state.short;
def StrongSell = Line1 < 0 and Line2 <= 0 and state == state.short;

plot GU = BuySignal;
GU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
GU.SetDefaultColor(GetColor(8));
GU.SetLineWeight(2);

plot GX = SellSignal;
GX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
GX.SetDefaultColor(GetColor(8));
GX.SetLineWeight(2);


def uptrend = buy;
def Stronguptrend = strongbuy;
def downtrend = sell;
def Strongdowntrend = strongsell;

AssignbackgroundColor (if uptrend then Color.Dark_GREEN else if Stronguptrend then Color.Green else if downtrend then color.dark_RED else if Strongdowntrend then Color.RED else Color.Black);

AddLabel(yes,if uptrend then "UP" else if Stronguptrend then "Buy" else if downtrend then "Down" else if Strongdowntrend then "Bear" else "Neutral", if stronguptrend then color.black else if strongdowntrend then color.black else color.white );
But my chart background still changes to green. as you can see here. Am I putting this code in the wrong area?

 
BonBon

BonBon

New member
@murkr As a reminder the original is for the chart. The revisions I made are for the watchlist column and the scan. It is not for the chart. You must use the original script for the chart.
 
murkr

murkr

Member
VIP
@BonBon
Ohh okay, when you told us to add your code to the bottom of the original code I thought you meant to edit the original code that is on the graph.

Okay noobs out there, I think I figured it out.

Copy the code in post #81 where I edit the original code with BonBon's code at the end.

go to your watchlist, right click> customize.
In the drop-down menu, click custom quotes.
Edit anyone of those custom1-20 you see
Delete the default Simplemovingavg
Click the "think script editor tab"
Paste in the code from post #81
right next to the column name change from D to 1-Minute (if you are looking at the 1-minute chart)

in the end, a new column will pop up in your watchlist corresponding to the Trendpainter color symbols.

 
murkr

murkr

Member
VIP
@BenTen I often have a lot of columns display "loading" and it takes awhile to populate. Is there a way to avoid this or are all of you dealing with this same issue?

 
BenTen

BenTen

Administrative
Staff
VIP
@murkr Not something we can control, to be honest. It's more about ToS's ability to handle the requests from these custom columns. I would reduce the number of custom columns and only use what is essential to avoid the "loading" issue.
 
BenTen

BenTen

Administrative
Staff
VIP
@Z3VON What are you trying to scan for? The up and down arrows? If so, use the original indicator in post #1 and then watch the video tutorial from this thread.
 
T

Thomas

Active member
@BonBon Thank you for posting a chart picture. 99% of the posts in all the indicator descriptions here, describe what they have created, adding some code with instructions, but most of the time it's not clear what the final result should look like.

@murkr Here's how to share a scan or whatever, it's so simple with the "SHARE," button on the chart, the scan or indicator, why people don't use it??????? this was what you asked and Bon made corrections.........https://tos.mx/82XUKqF
 
3AMBH

3AMBH

Member
2019 Donor
VIP
Is there anyone here actually trading with Trend Painter on a consistent basis? If, are you a day trader or swing trader? Thank you
 
G

Gabrielx77

Member
Is there anyone here actually trading with Trend Painter on a consistent basis? If, are you a day trader or swing trader? Thank you
Yes, i’ve been trading with it for the last two weeks and my success rate is 87.5%; however, i do not buy and sell solely when the reverse signal appears. I set a profit target and get out once i hit it.
 
T

Thomas

Active member
Can you detail how you are making your claim,....pictures with words, your set up, etc....any secrets, disregard.....
 
BenTen

BenTen

Administrative
Staff
VIP
@Thomas I assume you're talking to @Gabrielx77. He has shared a lot, actually. You can find them using the following links: [1] [2] [3]
 
T

Thomas

Active member
@Thomas I assume you're talking to @Gabrielx77. He has shared a lot, actually. You can find them using the following links: [1] [2] [3]
Yes Ben,....don't know why it didn't like may my fault......
 
G

Gabrielx77

Member
Can you detail how you are making your claim,....pictures with words, your set up, etc....any secrets, disregard.....
I’ll post all of the trades I made since last Monday using RV1 & Trend Painter in the ‘Relative Volume’ Thread. Strategy is fairly simple.
 
T

Thomas

Active member
I’ll post all of the trades I made since last Monday using RV1 & Trend Painter in the ‘Relative Volume’ Thread. Strategy is fairly simple.
Thanks not necessary,......congrats,.....keep up good trading.......
 
murkr

murkr

Member
VIP
@BenTen I like this trend painter but I would also like to see the bar colors (green or red). How can this be achieved?

Maybe, instead of painting the bar green, blue, or red you can have the chart background be highlighted in green, blue, or red. That way I can still see the bar colors (red or green) but also still see the trend painter.

Is this possible to do?

 
BenTen

BenTen

Administrative
Staff
VIP
@murkr I made it a lower study for you:

Code:
declare lower;

input ThermoLookBackBars = 50;
input PlotType = {default AdaptiveMovingAverages, Standard};

def HighLowScore = 1000 * ((high - high[1]) / (high[1]) +
(low - low[1]) / low[1]);

#ATR TrailingStop Code
input trailType = {default modified, unmodified};
input ATRPeriod = 5;
input ATRFactor = 3.5;
input firstTrade = {default long, short};

def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
    then high - close[1]
    else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
    then close[1] - low
    else (close[1] - low) - 0.5 * (low[1] - high);
def ATRMod = ExpAverage(Max(HiLo, Max(HRef, LRef)), 2 * ATRPeriod - 1);

def loss;
switch (trailType) {
case modified:
    loss = ATRFactor * ATRMod;
case unmodified:
    loss = ATRFactor * Average(TrueRange(high,  close,  low),  ATRPeriod);
}

rec state = {default init, long, short};
rec trail;
switch (state[1]) {
case init:
    if (!IsNaN(loss)) {
        switch (firstTrade) {
        case long:
            state = state.long;
            trail =  close - loss;
        case short:
            state = state.short;
            trail = close + loss;
    }
    } else {
        state = state.init;
        trail = Double.NaN;
    }
case long:
    if (close > trail[1]) {
        state = state.long;
        trail = Max(trail[1], close - loss);
    }
    else {
        state = state.short;
        trail = close + loss;
    }
case short:
    if (close < trail[1]) {
        state = state.short;
        trail = Min(trail[1], close + loss);
    }
    else {
        state = state.long;
        trail =  close - loss;
    }
}

def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);

plot TrailingStop = trail;
TrailingStop.Hide();
#End ATR Trailing Stop Code

def A = Highest(high[1], ThermoLookBackBars);
def B = Lowest(low[1], ThermoLookBackBars);

def FiftyTwoWeekHigh = A;

def FiftyTwoWeekLow = B;

def FiftyTwoWeekScore = 10 * (((high
- FiftyTwoWeekHigh) / FiftyTwoWeekHigh) +
((low - FiftyTwoWeekLow) / FiftyTwoWeekLow));

def ThermoScore = ExpAverage(HighLowScore + FiftyTwoWeekScore, ThermoLookBackBars);

input FastLengthShort = 5;
input SlowLengthShort = 15;
input EffRatioShort = 10;
input FastLengthLong = 10;
input SlowLengthLong = 25;
input EffRatioLong = 5;

def AMA = MovAvgAdaptive(ThermoScore, FastLengthShort, SlowLengthShort, EffRatioShort);
def AMA2 = MovAvgAdaptive(ThermoScore, FastLengthLong, SlowLengthLong, EffRatioLong);

plot Line1;
Line1.Hide();
plot Line2;
Line2.Hide();

switch (PlotType) {
case AdaptiveMovingAverages:
    Line1 = AMA;
    Line2 = AMA2;
case Standard:
    Line1 = ThermoScore;
    Line2 = ThermoScore;
}

def InvisibleLine = close * 0;
plot Line3 = InvisibleLine;
Line3.Hide();

def Buy = Line1 > 0 and Line2 < 0 and state == state.long;
def StrongBuy = Line1 > 0 and Line2 >= 0 and state == state.long;
def Sell = Line1 < 0 and Line2 > 0 and state == state.short;
def StrongSell = Line1 < 0 and Line2 <= 0 and state == state.short;

plot value = 0;
Value.AssignValueColor(if Buy then Color.DARK_GREEN else if StrongBuy then Color.GREEN else if Sell then Color.DARK_RED else if StrongSell then Color.RED else Color.BLUE);
 
murkr

murkr

Member
VIP
@BenTen THANKS! This works great!
EDIT: It's a little hard to see the color transition because the line is so thin.

Is there a way you can change that line to bars? Similar to this Advanced Volume Indicator?



 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
@murkr Sure, find the last two lines in the modified script I posted and replace them with the following:

Code:
plot value = volume;
Value.AssignValueColor(if Buy then Color.DARK_GREEN else if StrongBuy then Color.GREEN else if Sell then Color.DARK_RED else if StrongSell then Color.RED else Color.BLUE);
Value.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 

Similar threads

Top