Join useThinkScript to post your question to a community of 21,000+ developers and traders.
thanks BenTen, the script works well. but there is a little problem, the indicator is on a separate box.
then is it possible i plot rmi in the same study n it only spike if the candle goes below/above the supertrend line n rmi hits oversold/overbought region ? just trying to see how to weave 2 indicators together@tutianlong Not possible in the mobile app. That’s why we have it as a lower study.
@tutianlong Not possible in the mobile app. That’s why we have it as a lower study.
# Mobius
# SuperTrend
# Chat Room Request
input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
plot SuperTrendUp = close crosses above ST;
plot SuperTrendDown = close crosses below ST;
#SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrendUp.SetDefaultColor(Color.YELLOW);
SuperTrendUp.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
SuperTrendDown.SetDefaultColor(Color.PINK);
SuperTrendDown.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
# SuperTrend Scan
# Mobius
# V01.10.2015
# Comment out (#) the direction NOT to use for a scan
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
def h = high;
def l = low;
def c = close;
def v = volume;
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if c < ST[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
plot SuperTrendUP = if ST crosses below close then 1 else 0;
#plot SuperTrendDN = if ST crosses above close then 1 else 0;
# End Code SuperTrend
@BenTen I am having trouble with the scanner. I have read this thread and using the code from the first post. I am getting false positives or signals for ST that has been running for a few days. What I am looking for is a scan that will provide a new ST bullish signal. Below is what I am using for a scan.
Stock Hacker filters
Here is the study code.
Code:# SuperTrend Scan # Mobius # V01.10.2015 # Comment out (#) the direction NOT to use for a scan input AtrMult = .70; input nATR = 4; input AvgType = AverageType.HULL; def h = high; def l = low; def c = close; def v = volume; def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR); def UP = HL2 + (AtrMult * ATR); def DN = HL2 + (-AtrMult * ATR); def ST = if c < ST[1] then Round(UP / tickSize(), 0) * tickSize() else Round(DN / tickSize(), 0) * tickSize(); plot SuperTrendUP = if ST crosses below close then 1 else 0; #plot SuperTrendDN = if ST crosses above close then 1 else 0; # End Code SuperTrend
This returns 57 results, with around half that are false signals. Here are a few examples:
False signal with ST showing existing Bearish Trend
Existing Bullish Trend
Please let me know if I am doing something wrong to get these false signals. Thank you for your time!
My suggestion is that you search for stocks using Average Daily Volume...not regular Volume as your setting now with the volume will not show results UNTIL 1,000,000 volume is hit for the given day...By then it could be way too late to even make any moves.
Average("data" = VOLUME, "length" = 10) is greater than 1000000
Add a study filter in the upper right...and its under volume. I normally set to greater than 500KThank you @HighBredCloud for the suggestion.
Is this the code you would use to accomplish that?
Code:Average("data" = VOLUME, "length" = 10) is greater than 1000000
Also, I don't think that explains the false positives I am receiving with the scan. Any thoughts on that?
@corello Here is the code for that. It comes in 2 parts.
Step 1: Create a new Strategy (not a Study) > Copy and Paste the original code in the first page into it.
Step 2: Add the following code to the end of the script:
Code:# The following code is for backtesting def SuperTrendUP = if ST crosses below close then 1 else 0; def SuperTrendDN = if ST crosses above close then 1 else 0;
Step 3a: If you want to test out bullish strategy then add this code after the code from Step 2:
Code:# Bullish Orders AddOrder(OrderType.BUY_TO_OPEN, condition = SuperTrendUp, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY"); AddOrder(OrderType.SELL_TO_CLOSE, condition = SuperTrendDN, price = open,100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");
Step 3b: If you want to test out bearish strategy then add this code after the code from Step 2:
Code:# Bearish Orders AddOrder(OrderType.SELL_TO_OPEN, condition = SuperTrendDN, price = open,100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL"); AddOrder(OrderType.BUY_TO_CLOSE, condition = SuperTrendUp, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");
Do not place both codes from 3a and 3b into the same script.
@mc01439@kshires4 - Please post the code.
# SuperTrend Yahoo Finance Replica - Modified from Modius SuperTrend
# Modified Modius ver. by RConner7
# BULL SCANNER #
# Works similar to how Yahoo Finance Supertrend works and displays. Holds supertrend value until cross.
input AtrMult = 1.00;
input nATR = 6;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (AtrMult * ATR);
def LW_Band_Basic = HL2 + (-AtrMult * ATR);
def UP_Band = if ((UP_Band_Basic < UP_Band[1]) or (close[1] > UP_Band[1])) then UP_Band_Basic else UP_Band[1];
def LW_Band = if ((LW_Band_Basic > LW_Band[1]) or (close[1] < LW_Band[1])) then LW_Band_Basic else LW_Band[1];
def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band
else if ((ST[1] == UP_Band[1]) and (close > Up_Band)) then LW_Band
else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band
else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band
else LW_Band;
plot ST_Cross = if (ST crosses below close) within 2 bars then 1 else 0;
# SuperTrend Yahoo Finance Replica - Modified from Modius SuperTrend
# Modified Modius ver. by RConner7
# BULL SCANNER #
# Works similar to how Yahoo Finance Supertrend works and displays. Holds supertrend value until cross.
input AtrMult = 1.00;
input nATR = 6;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (AtrMult * ATR);
def LW_Band_Basic = HL2 + (-AtrMult * ATR);
def UP_Band = if ((UP_Band_Basic < UP_Band[1]) or (close[1] > UP_Band[1])) then UP_Band_Basic else UP_Band[1];
def LW_Band = if ((LW_Band_Basic > LW_Band[1]) or (close[1] < LW_Band[1])) then LW_Band_Basic else LW_Band[1];
def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band
else if ((ST[1] == UP_Band[1]) and (close > Up_Band)) then LW_Band
else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band
else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band
else LW_Band;
plot ST_Cross = if (ST crosses below close) within 2 bars then 1 else 0;
AssignBackgroundColor(if close crosses below st
then Color.DARK_RED
else if close crosses above st
then Color.DARK_GREEN
else color.LIGHT_GRAY);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Archived: TMO True Momentum Oscillator | Indicators | 346 | ||
Archived: RSI Divergence Indicator | Indicators | 131 | ||
Archived: Opening Range Breakout | Indicators | 340 | ||
S | Smart Supertrend For ThinkOrSwim | Indicators | 13 | |
M | SuperTrend Oscillator [LUX] For ThinkOrSwim | Indicators | 7 |
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.