Repaints AsGoodTrendColorCandles_MTFs For ThinkOrSwim

Repaints

csricksdds

Trader Educator
VIP
###This ASGoodTrendColorCandles_MTFs Indicator looks back 6 periods on each time frame divided by .5 painting the candle trend Green or Red. I use this as continued verification for my AsGoodAsItGets Long/Short Buy/Sell Indicator since it might repaint and I'm looking for further trend verification.
###Inspiration for this from the TTM_Trend Indicator which is a free indicator on TOS but doesn't provide code.
###Charles Ricks v.1 10/31/22 This indicator automatically address most time frames.

input AGP0 = AggregationPeriod.Min;
input AGP = AggregationPeriod.Five_Min;
input AGP1 = AggregationPeriod.Fifteen_Min;
input AGP2 = AggregationPeriod.Thirty_Min;
input AGP3 = AggregationPeriod.Hour;
input AGP4H = AggregationPeriod.FOUR_Hours;
input AGP4 = AggregationPeriod.DAY;
input AGP5 = AggregationPeriod.Week;
input AGP6 = AggregationPeriod.Month;

input TrendPeriods = 6;

def OP = open(period = AGP);

def HI = high(period = AGP);

def LOW = low(period = AGP);

def Close = close(period = AGP);

def HighestHigh = highest(HI, trendPeriods);

def LowestLow = lowest(LOW, trendPeriods);

def CandleTrend = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP0 = open(period = AGP0);

def HI0 = high(period = AGP0);

def LOW0 = low(period = AGP0);

def Close0 = close(period = AGP0);

def HighestHigh0 = highest(HI, trendPeriods);

def LowestLow0 = lowest(LOW, trendPeriods);

def trend0 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);


def OP1 = open(period = AGP1);

def HI1 = high(period = AGP1);

def LOW1 = low(period = AGP1);

def Close1 = close(period = AGP1);

def HighestHigh1 = highest(HI, trendPeriods);

def LowestLow1 = lowest(LOW, trendPeriods);

def trend1 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP2 = open(period = AGP2);

def HI2 = high(period = AGP2);

def LOW2 = low(period = AGP2);

def Close2 = close(period = AGP2);

def HighestHigh2 = highest(HI, trendPeriods);

def LowestLow2 = lowest(LOW, trendPeriods);

def trend2 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP3 = open(period = AGP3);

def HI3 = high(period = AGP3);

def LOW3 = low(period = AGP3);

def Close3 = close(period = AGP3);

def HighestHigh3 = highest(HI, trendPeriods);

def LowestLow3 = lowest(LOW, trendPeriods);

def trend3 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);


def OP4 = open(period = AGP4);

def HI4 = high(period = AGP4);

def LOW4 = low(period = AGP4);

def Close4 = close(period = AGP4);

def HighestHigh4 = highest(HI, trendPeriods);

def LowestLow4 = lowest(LOW, trendPeriods);

def trend4 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP4H = open(period = AGP4H);

def HI4H = high(period = AGP4H);

def LOW4H = low(period = AGP4H);

def Close4H = close(period = AGP4H);

def HighestHigh4H = highest(HI, trendPeriods);

def LowestLow4H = lowest(LOW, trendPeriods);

def trend4H = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP5 = open(period = AGP5);

def HI5 = high(period = AGP5);

def LOW5 = low(period = AGP5);

def Close5 = close(period = AGP5);

def HighestHigh5 = highest(HI, trendPeriods);

def LowestLow5 = lowest(LOW, trendPeriods);

def trend5 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

def OP6 = open(period = AGP6);

def HI6 = high(period = AGP6);

def LOW6 = low(period = AGP6);

def Close6 = close(period = AGP6);

def HighestHigh6 = highest(HI, trendPeriods);

def LowestLow6 = lowest(LOW, trendPeriods);

def trend6 = if ((Close - LowestLow) / (HighestHigh - LowestLow)) > .5

then 1

else 0;

AssignPriceColor(if CandleTrend then color.green else color.red);

###End
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Wow. This is really good. thank you so much. Can we ask you questions on how to trade options and things like that? I have lots of questions and these indicators are really helpful. Thank you
 
I'm glad my indicators are helpful. I see that you're a new member. This is a good site for learning and everyone tries to be helpful and my best advice is for you to find indicators you are comfortable with and learn to 'follow the money' and the "trend of the market"
 
@csricksdds Looks like a decent start, but I have a couple questions.

I notice that you just keep assigning the bars green/red with the same line throughout the script:

Code:
AssignPriceColor(if CandleTrend then color.green else color.red);

You define other trend variables though, but never use them. I'm wondering if the subsequent AssignPriceColor lines should make use of those variables?

Then, by that logic, this would mean the candles turn green if ANY of the timeframes are showing a trend, correct? Wouldn't we maybe want to take an accumulated average of ALL the timeframes? And if that average is > 0.5, that would be green, otherwise red? Just thinking out loud, haven't tested yet.
 
AAAAAND after a quick test, I realized that the indicator works the same with the following line at the bottom of the script, and all of the preceding AssignPriceColor lines commented out:

Code:
# TEST
AssignPriceColor(if ((CandleTrend + trend0 + trend1 + trend2 + trend3 + trend4 + trend4H + trend5 + trend6)/9)>.5 then color.green else color.red);

Next step might be to turn this into a trading strategy, mitigating some of the whipsaws as much as possible!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
420 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top