# 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
##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
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
##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
#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();
#``````

87k+ Posts
389 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?