Potential Explosion Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
This script looks at times where MACD is within a specified range (very close to 0 values) and price action is very constrained (under 2%). Historically price has made a strong move after these conditions.
The arrows in this indicator doe not predict future movement. It's there in case you guys do not want to have the candles painted. And the arrows can also help in case you want to scan for new signals.




thinkScript Code

Code:
# Potential Explosion
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/rwBArbXJ-Explosive-Potential/

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);

def Diff = Value - Avg;
def ZeroLine = 0;

input barsbackPrice = 15;
input priceThreshold = 0.6;
input barsbackMacd = 15;
input macdDiffThreshold = 9;
input macdValueThreshold = 6;

def highest = highest(close, barsbackPrice);
def lowest = lowest(close, barsbackPrice);

def macdLine = Value;

def priceVarianceBool = (absValue((highest - lowest) / lowest) * 100) < priceThreshold;
def macdDiffBool = absValue(highest(macdLine, barsbackMacd) - lowest(macdLine, barsbackMacd)) < macdDiffThreshold;
def macdRangeBool = macdLine < macdValueThreshold and macdLine > -macdValueThreshold;

def macdAndPriceFlat = macdDiffBool and macdRangeBool and priceVarianceBool;

assignPriceColor(if macdAndPriceFlat then color.blue else color.white);

plot arrow = macdAndPriceFlat;
arrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
arrow.SetDefaultColor(Color.CYAN);
arrow.SetLineWeight(1);
See this comment If you wish to display only one arrow at the start of a consolidation range.
 
Last edited:
P

Playstation

Active member
VIP
somehow i managed to turn every candle color and up arrow :eek:


15mins. Tried on 1H, same. Are you guys having this problem too?
 
BenTen

BenTen

Administrative
Staff
VIP
@Playstation No problem for me. Take a look at the original thread. I was also using the 15m.
 
H

Hariharan

New member
@Playstation No problem for me. Take a look at the original thread. I was also using the 15m.
Does not seem to work on higher time frames like 4H or Daily. Can you recommend some good indicators that you have used for 4H and daily time frames for my study purposes? Many thanks Ben.
 
P

pk1729

New member
Warehouse
VIP
I have the same problem as Playstation on AMZN chart. For SHOP it shows only arrow. Check this for date 12/13.

@BenTen I think this code change should fix the multiple arrow issue, change

Code:
plot arrow = macdAndPriceFlat;
to

Code:
plot arrow = macdAndPriceFlat and macdAndPriceFlat[1] is false;
 
BenTen

BenTen

Administrative
Staff
VIP
@pk1729 Thank you for that. The arrows are added to each candlestick that has a tight MACD range. Also, it was designed to be used on the scanner as well. Using your method, we would have to increase the lookback period in the scanner. Aesthetic wise I can see why people would prefer to have a single arrow instead of a bunch within the same area. I have made a note about your snippet in the original thread in case anyone would prefer to have a single arrow at the beginning of the consolidation range.
 
I

ikpllc

New member
@pk1729 Thank you for that. The arrows are added to each candlestick that has a tight MACD range. Also, it was designed to be used on the scanner as well. Using your method, we would have to increase the lookback period in the scanner. Aesthetic wise I can see why people would prefer to have a single arrow instead of a bunch within the same area. I have made a note about your snippet in the original thread in case anyone would prefer to have a single arrow at the beginning of the consolidation range.
Sorry to be dense here, but to use this as a scan, do I just set it to where the 'Arrow' = true? Doesn't seem to be working...
 
I

ikpllc

New member
@ikpllc Correct. What is not working? Please post a screenshot of the error.
Ok, I believe I fixed it. Only other question is...in your opinion, what's the best time frame to use on the chart? I'm finding decent picks on the scan when I do 15 mins. Use 15 mins on the chart as well?
 

Top