Simple TFC (Time Frame Continuity) Study

Cribbage

Member
I'm trying to study TFC on a few time frames. I would like a lower study with a zero line that shows a plot that gives a +1 when the specified time frame is green, -1 when red, 0 when neutral. I scraped some of the simple parts from PelonSax's brilliant suite of strat indicators to try to do it on my own thinking it would be simple.

The problem I'm running into is that it plots the price of the asset, rather than telling me if the condition is true or not. These seems like something I can normally bang out but I'm stymied. Thanks for any help.

Code:
##Cribbage 8/18/23 TFC Review, base code from Pelon Sax codes on Use Think Script
##https://usethinkscript.com/threads/indicator-for-think-or-swim-based-on-rob-smiths-the-strat.3312/
##Can't get it to work as simply +1 green / -1 red as it seems to use the value of the asset

declare lower;

input Time_Frame = AggregationPeriod.hour;
plot H = high(period = Time_Frame);
plot L = low(period = Time_Frame);
def O = open(period = Time_Frame);
def C = close(period = Time_Frame);

plot red = O<C;
plot green = O>C;

#plot zeroline = O;
#zeroline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#zeroline.SetLineWeight(2);

#plot Dir = green;
#plot dir = red or green;
 
Solution
I'm trying to study TFC on a few time frames. I would like a lower study with a zero line that shows a plot that gives a +1 when the specified time frame is green, -1 when red, 0 when neutral. I scraped some of the simple parts from PelonSax's brilliant suite of strat indicators to try to do it on my own thinking it would be simple.

The problem I'm running into is that it plots the price of the asset, rather than telling me if the condition is true or not. These seems like something I can normally bang out but I'm stymied. Thanks for any help.

Code:
##Cribbage 8/18/23 TFC Review, base code from Pelon Sax codes on Use Think Script
##https://usethinkscript.com/threads/indicator-for-think-or-swim-based-on-rob-smiths-the-strat.3312/...
I'm trying to study TFC on a few time frames. I would like a lower study with a zero line that shows a plot that gives a +1 when the specified time frame is green, -1 when red, 0 when neutral. I scraped some of the simple parts from PelonSax's brilliant suite of strat indicators to try to do it on my own thinking it would be simple.

The problem I'm running into is that it plots the price of the asset, rather than telling me if the condition is true or not. These seems like something I can normally bang out but I'm stymied. Thanks for any help.

Code:
##Cribbage 8/18/23 TFC Review, base code from Pelon Sax codes on Use Think Script
##https://usethinkscript.com/threads/indicator-for-think-or-swim-based-on-rob-smiths-the-strat.3312/
##Can't get it to work as simply +1 green / -1 red as it seems to use the value of the asset

declare lower;

input Time_Frame = AggregationPeriod.hour;
plot H = high(period = Time_Frame);
plot L = low(period = Time_Frame);
def O = open(period = Time_Frame);
def C = close(period = Time_Frame);

plot red = O<C;
plot green = O>C;

#plot zeroline = O;
#zeroline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#zeroline.SetLineWeight(2);

#plot Dir = green;
#plot dir = red or green;

Code:
#mtf_grn_red
#https://usethinkscript.com/threads/simple-tfc-time-frame-continuity-study.16420/
#Simple TFC (Time Frame Continuity) Study

declare lower;

def na = double.nan;
#def bn = barnumber();

input Time_Frame = AggregationPeriod.hour;
#def H = high(period = Time_Frame);
#def L = low(period = Time_Frame);
def O = open(period = Time_Frame);
def C = close(period = Time_Frame);

def red = O > C;
def green = O < C;
#def dir = if green then 1 else if red then -1 else 0;
def dir = if (open(period = Time_Frame) < close(period = Time_Frame)) then 1
 else if (open(period = Time_Frame) > close(period = Time_Frame)) then -1
 else 0;

input show_pulse_line = yes;
plot zeroline = if show_pulse_line then 0 else na;
#zeroline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zeroline.SetLineWeight(2);

plot z = if show_pulse_line and !isnan(close) then dir else na;
z.SetDefaultColor(Color.cyan);

input show_dots = yes;
plot dots = if show_dots and !isnan(close) then 0 else na;
dots.SetPaintingStrategy(PaintingStrategy.POINTS);
dots.AssignValueColor(if dir > 0 then color.green else if dir < 0 then color.red else color.gray);
dots.setlineweight(4);
dots.hidebubble();
#
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
291 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