Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thanks, in uptrend and downtrend I want to find the consolidation area, is it possible?@majidg What is your interpretation of upTrend...??? A very common method would be:
Ruby:close > close[1] # OR # close > close[1] and close[1] > close[2] # OR # ExpAverage(close, 9) > ExpAverage(close, 9)[1]
There are any number of ways to determine trend and those a just a few...
Thanks, in uptrend and downtrend I want to find the consolidation area, is it possible?
@majidg @rad14733 Rad is right, we need a bit more definition of what you mean by "uptrend". My apology. But Trend Painter is a good indicator I use and like. You might want to search and start there, then use the code I have provided for a scan. Good luck! @cabe1332Again, that depends on your logical definition of "consolidation"... All coding is based on logic...
That's great, thanks for providing the above codes and screen shot.Hey @majidg, I have found the Trend Painter Indicator very useful (screenshot below). You can search and add it to your charts. Below is the code I use to scan uptrend stocks. The code will give you a "Buy", "Strong Buy", and "Neutral" state of the stock. Add the code as a filter study for scans. Good luck! @cabe1332
# Trend Painter Indicator With Buy & Sell Signals
# Credit to then usethinkscript.com team for this script and share. It's an awesome indicator.
#
# Candle definitions/legends
# DARK_GREEN = Buy
# GREEN = Strong Buy
# DARK_RED = Sell
# RED = Strong Sell
# BLUE = Neutral or Otherwise
#Think of the BLUE as amber color at a traffic light signal, it is warning you that something is about to change.
#By changing the color scheme to a two COLOR green/red in my opinion would not give you the underlying sentiment of the momentum.
#start 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);
def 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 FastLengthLong = 9;
input SlowLengthLong = 26;
input EffRatioLong = 5;
def AMA = MovAvgAdaptive(ThermoScore, FastLengthShort, SlowLengthShort, EffRatioShort);
def AMA2 = MovAvgAdaptive(ThermoScore, FastLengthLong, SlowLengthLong, EffRatioLong);
def Line1;
#Line1.Hide();
def 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;
def neutral = if !buy and !strongBuy and !sell and !strongSell then 1 else 0;
#def GU = BuySignal;
#GU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#GU.SetDefaultColor(GetColor(8));
#GU.SetLineWeight(2);
#def GX = SellSignal;
#GX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#GX.SetDefaultColor(GetColor(8));
#GX.SetLineWeight(2);
plot scan = buy or strongbuy or neutral;
#end code
I entered the code in TOS and I don't see the above screen shot. Not sure why it is not same as the above. is the above uptrend scan code?Hey @majidg, I have found the Trend Painter Indicator very useful (screenshot below). You can search and add it to your charts. Below is the code I use to scan uptrend stocks. The code will give you a "Buy", "Strong Buy", and "Neutral" state of the stock. Add the code as a filter study for scans. Good luck! @cabe1332
# Trend Painter Indicator With Buy & Sell Signals
# Credit to then usethinkscript.com team for this script and share. It's an awesome indicator.
#
# Candle definitions/legends
# DARK_GREEN = Buy
# GREEN = Strong Buy
# DARK_RED = Sell
# RED = Strong Sell
# BLUE = Neutral or Otherwise
#Think of the BLUE as amber color at a traffic light signal, it is warning you that something is about to change.
#By changing the color scheme to a two COLOR green/red in my opinion would not give you the underlying sentiment of the momentum.
#start 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);
def 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 FastLengthLong = 9;
input SlowLengthLong = 26;
input EffRatioLong = 5;
def AMA = MovAvgAdaptive(ThermoScore, FastLengthShort, SlowLengthShort, EffRatioShort);
def AMA2 = MovAvgAdaptive(ThermoScore, FastLengthLong, SlowLengthLong, EffRatioLong);
def Line1;
#Line1.Hide();
def 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;
def neutral = if !buy and !strongBuy and !sell and !strongSell then 1 else 0;
#def GU = BuySignal;
#GU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#GU.SetDefaultColor(GetColor(8));
#GU.SetLineWeight(2);
#def GX = SellSignal;
#GX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#GX.SetDefaultColor(GetColor(8));
#GX.SetLineWeight(2);
plot scan = buy or strongbuy or neutral;
#end code
Hi @cabe1332 , i have looked into the Trend Painter Indicator code in another post. But I am very interested in knowing how i put the 2 pieces of code together (or how to apply these) in order to get the same view in your screen capture.Hey @majidg, I have found the Trend Painter Indicator very useful (screenshot below). You can search and add it to your charts. Below is the code I use to scan uptrend stocks. The code will give you a "Buy", "Strong Buy", and "Neutral" state of the stock. Add the code as a filter study for scans. Good luck! @cabe1332
# Trend Painter Indicator With Buy & Sell Signals
# Credit to then usethinkscript.com team for this script and share. It's an awesome indicator.
#
# Candle definitions/legends
# DARK_GREEN = Buy
# GREEN = Strong Buy
# DARK_RED = Sell
# RED = Strong Sell
# BLUE = Neutral or Otherwise
#Think of the BLUE as amber color at a traffic light signal, it is warning you that something is about to change.
#By changing the color scheme to a two COLOR green/red in my opinion would not give you the underlying sentiment of the momentum.
#start 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);
def 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 FastLengthLong = 9;
input SlowLengthLong = 26;
input EffRatioLong = 5;
def AMA = MovAvgAdaptive(ThermoScore, FastLengthShort, SlowLengthShort, EffRatioShort);
def AMA2 = MovAvgAdaptive(ThermoScore, FastLengthLong, SlowLengthLong, EffRatioLong);
def Line1;
#Line1.Hide();
def 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;
def neutral = if !buy and !strongBuy and !sell and !strongSell then 1 else 0;
#def GU = BuySignal;
#GU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#GU.SetDefaultColor(GetColor(8));
#GU.SetLineWeight(2);
#def GX = SellSignal;
#GX.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#GX.SetDefaultColor(GetColor(8));
#GX.SetLineWeight(2);
plot scan = buy or strongbuy or neutral;
#end code
Hey @KLMS, adding Trend Painter is pretty easy to add into your chart. A thousand links are on this site on how to apply scripts, studies, and more. I am not sure which pieces in the screenshot view you are looking at or interested in. If I can help I will but need more info. Good luck! @cabe1332Hi @cabe1332 , i have looked into the Trend Painter Indicator code in another post. But I am very interested in knowing how i put the 2 pieces of code together (or how to apply these) in order to get the same view in your screen capture.
Sorry if this is a stupid question.
If I can apply this to my charts, that will be very indicative.
Won't come up for me either and I have download several ind. with no problem . There is a small section at the bottom of the code that stays black when I paste it ,so that seems to be the problem for me anyways .I entered the code in TOS and I don't see the above screen shot. Not sure why it is not same as the above. is the above uptrend scan code?
@HEC @KLMS the code I provided is used for scanning uptrend "Buy", "Strong Buy" or Neutral stocks. Don't use it as an indicator. I've said that on my post.Won't come up for me either and I have download several ind. with no problem . There is a small section at the bottom of the code that stays black when I paste it ,so that seems to be the problem for me anyways .
@cabe1332 is this the one you use?
@Tidan I use trend reversal, try the link below. I just the modified signals and text a little.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
A | High Short Interest % Scan | Questions | 0 | |
C | SAR MACD Scan | Questions | 3 | |
MACD-V - adjusted for LBR310 scan | Questions | 0 | ||
S | BB Compression Scan - Find out which are Contraction after Expansion | Questions | 0 | |
S | Scan For Price Drops | Questions | 2 |
Start a new thread and receive assistance from our community.
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.
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.