I'd start with buy on first green and sell on 2nd blue. Is there a way to configure strategies like you can studies where you can change the parameters in the edit studies window under input and options? For example, If I wanted to test sell on first red ( instead of 2nd blue) I could change it there instead of editing the script? Thank You for your assistance.@Mkirk Sure, just tell me your desired buy and sell conditions.
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);
AssignPriceColor(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);
AddLabel(yes, Concat("Current Reading is ", (if Buy then "Up Trend" else if StrongBuy then "Strong Up Trend" else if Sell then "Down Trend" else if StrongSell then "Strong Down Trend" else "Neutral")), 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.GRAY);
AddOrder(OrderType.BUY_TO_OPEN, condition = GU, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");
AddOrder(OrderType.SELL_TO_CLOSE, condition = GX, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Cover");
Greetings everyone
Please see below. These are the changes I made to the original trendpainter code so it can be used as a watchlist column and and as a scan. The original code is to be used within the chart study.
#Revised TrendPainter code for Watchlist Column (thermolookbackbars and the trading session must mirror that of the trendpainter on the chart). I removed the original "asignbackground color" and "addlabel' script and replaced it with the below.
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 );
#Revised TrendPainter code for Stock Hacker scan (thermolookbackbars and the trading session must mirror that of the trendpainter on the chart and watchlist column). I removed the "asignbackground color" and "addlabel' script and replaced the 'plot" with "def". The only plot statement is the one below. This was added at the end of the script.
plot scan = strongbuy;
If you want to plot the buysignal, sell signal, strongsell etc simply replace strongbuy.
Hope this helps.
@wtan here's what I did. The script below is from the original, just modified it a bit for my scan.Hi, do you mean add a study, select the trendpainter code under the edit condition? I can see different plots available but no strongbuy option.
# 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.
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 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;
# end of code
@wtan here's what I did. The script below is from the original, just modified it a bit for my scan. There may be other ways, but it works for me. A screenshot of the scan should help you going. 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.
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 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;
# end of code
Yes, Study Alerts only work when the Chart is up... Scan Alerts can fire in the background and are editable either via Scan or the Marketwatch > Alerts tab... Chart Alerts, set by Right-Clicking on the Chart and selecting Create Alert should fire regardless of whether the underlying chart is up... Chart Alerts are also maintained via Marketwatch > Alerts tab...I added Post #6 at the end of the trend painter code; however I am not getting any alerts on TOS.
Am i supposed to have the charts up in order to be alerted? Should i create a watchlist then have all the charts on my screen? Please let me know. Thank you for your reply!!
will this snippet work on any strategy you add it to/?@coolice521 Try this
Code:# Alerts Alert(up, " ", Alert.Bar, Sound.Chimes); Alert(down, " ", Alert.Bar, Sound.Bell);
will this snippet work on any strategy you add it to/?
AddOrder(OrderType.BUY_AUTO, GU);
AddOrder(OrderType.Sell_AUTO, GX);
Find this statement at the bottom of the study:Hello scripting experts, I tinkered unsuccessfully, with the base code for chart study to get it to avoid painting the candlestick.
I would prefer to view the default up/down candles & only display the GU GX indicators along with the current trend label on the chart.
Is anyone doing this & will share either code or a shared link? TIA.
Comment it out by placing a # hashtag in front of it.AssignPriceColor(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);
# AssignPriceColor(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);
What you posted is not a valid script. It was a snippet that was supposed to be pasted to the study in the first post of this thread as shown below:Can somone help me here?
def uptrend = buy;
def Stronguptrend = strongbuy;
def downtrend = sell;
def Strongdowntrend = strongsell;
The def is being errored out. Am i doing something wrong here?
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;
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 );
in the above code, strong buy and strong sell are not defined. Can you please add them?This indicator is based on the work of The Lawyer Trader's Trend_Fuzz study. I just added buy and sell arrows to help you pick your entry points for long and short positions.
Labels are included in the top left-hand corner to let you know the current market condition. When the candles are painted red it means the stock is currently in a downtrend, green candles represent uptrend, and blue candles mean neutral.
thinkScript Code
Rich (BB 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); AssignPriceColor(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); AddLabel(yes, Concat("Current Reading is ", (if Buy then "Up Trend" else if StrongBuy then "Strong Up Trend" else if Sell then "Down Trend" else if StrongSell then "Strong Down Trend" else "Neutral")), 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.GRAY);
Shareable Link
https://tos.mx/kZjt1k
I took out the lower study from the original code. If you want to add it, place this at the end of the script above.
Rich (BB code):declare upper; input over_bought = 80; input over_sold = 20; input KPeriod = 10; input DPeriod = 10; input priceH = high; input priceL = low; input priceC = close; input slowing_period = 3; input smoothingType = {default SMA, EMA}; def lowest_k = Lowest(priceL, KPeriod); def c1 = priceC - lowest_k; def c2 = Highest(priceH, KPeriod) - lowest_k; def FastK = if c2 != 0 then c1 / c2 * 100 else 0; def FullK; def FullD; switch (smoothingType) { case SMA: FullK = Average(FastK, slowing_period); FullD = Average(FullK, DPeriod); case EMA: FullK = ExpAverage(FastK, slowing_period); FullD = ExpAverage(FullK, DPeriod); } def pricefilterup = if close > close[50] then 1 else 0; def pricefilterdown = if close < close [50] then 1 else 0; def OverBoughtAdd = if FullK < over_bought and FullK[1] >= over_bought then 1 else 0; def OverSoldAdd = if FullK > over_sold and FullK[1] <= over_sold then 1 else 0; def na = Double.NaN; #Plot arrows plot up = if StrongBuy and OverSoldAdd and pricefilterup then low - (3 * TickSize()) else na; plot down = if StrongSell and OverBoughtAdd and pricefilterdown then high + (3 * TickSize()) else na; up.SetPaintingStrategy(PaintingStrategy.ARROW_UP); down.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
LNL Trend System for ThinkOrSwim | Indicators | 25 | ||
L3 Banker Fund Flow Trend Oscillator for ThinkOrSwim | Indicators | 33 | ||
Trend Meter For ThinkOrSwim | Indicators | 38 | ||
J | Donchian Channel Trend For ThinkOrSwim | Indicators | 5 | |
Donchian Trend Ribbon For ThinkOrSwim | Indicators | 18 |
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.