How to set up date and time into an indicator.

jeanbotelho

New member
Hello guys. I'd like some help with my indicator.

I just create lines to show corrections from the bottom to the top and vice-versa in a specific time frame.
I would like to create an option through which I could set date and time (only intraday, if possible) for this indicator to work.
For example: I'd like to setup an option for the indicator start plotting today, at 4:00AM.
Could anyone help me?

This is the script that I have.
I'd like to add an option for plotting only starting at a specific date and time or only today.

Thank you.

### Trend Tracker
### Created by Jean Botelho
### Inspired in the Rastreador de Tendência by Leo Nonato and Wagner Belzonte UAI


## Inputs

input TimeFrame = AggregationPeriod.DAY;
input length = 22;
input priceH = FundamentalType.HIGH;
input priceL = FundamentalType.LOW;
#input displace = 0;


### Definitions

def priceHigh = highest(Fundamental(priceH, period = timeframe), length);
def priceLow = lowest(Fundamental(PriceL, period= timeframe), length);
def range = priceHigh - priceLow;

def Line90 = priceLow + (0.9 * range);
def Line80 = priceLow + (0.8 * range);
def Line70 = priceLow + (0.7 * range);
def Line30 = priceLow + (0.3 * range);
def Line20 = priceLow + (0.2 * range);
def Line10 = priceLow + (0.1 * range);

#### Plots

#plot intervalo = range;
#intervalo.setstyle(curve.SHORT_DASH);
plot Line901 = Line90;
Line901.SetStyle(Curve.SHORT_DASH);
plot Line801 = Line80;
Line801.SetStyle(Curve.MEDIUM_DASH);
plot Line701 = Line70;
Line701.SetStyle(Curve.SHORT_DASH);
plot Line301 = Line30;
Line301.SetStyle(Curve.SHORT_DASH);
plot Line201 = Line20;
Line201.SetStyle(Curve.SHORT_DASH);
plot Line101 = Line10;
Line101.SetStyle(Curve.SHORT_DASH);

##### Colors
Line901.SetDefaultColor(Color.WHITE);
Line801.SetDefaultColor(Color.VIOLET);
Line701.SetDefaultColor(Color.DARK_GREEN);
Line301.SetDefaultColor(Color.DARK_GREEN);
Line201.SetDefaultColor(Color.VIOLET);
Line101.SetDefaultColor(Color.WHITE);

### END

I know it's going to be easy for you guys. But I'm just starting.
Thank you, one more time.
 
Give this a shot. You can change the start and end periods or turn it off altogether if you rather have it go 24 hrs.

C++:
### Trend Tracker
### Created by Jean Botelho
### Inspired in the Rastreador de Tendência by Leo Nonato and Wagner Belzonte UAI


## Inputs

input TimeFrame = AggregationPeriod.DAY;
input length = 22;
input priceH = FundamentalType.HIGH;
input priceL = FundamentalType.LOW;
#input displace = 0;
input tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
input OpenTime = 0930; #hint OpenTime: Opening time of market
input CloseTime = 1600; #hint CloseTime: Closing time of market

### Definitions
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
# Only use market hours when using intraday timeframe
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;

def priceHigh = highest(Fundamental(priceH, period = timeframe), length);
def priceLow = lowest(Fundamental(PriceL, period= timeframe), length);
def range = priceHigh - priceLow;

def Line90 = priceLow + (0.9 * range);
def Line80 = priceLow + (0.8 * range);
def Line70 = priceLow + (0.7 * range);
def Line30 = priceLow + (0.3 * range);
def Line20 = priceLow + (0.2 * range);
def Line10 = priceLow + (0.1 * range);

#### Plots

#plot intervalo = range;
#intervalo.setstyle(curve.SHORT_DASH);
plot Line901 = if MarketOpen then Line90 else double.NaN;
Line901.SetStyle(Curve.SHORT_DASH);
plot Line801 = if MarketOpen then Line80 else double.NaN;
Line801.SetStyle(Curve.MEDIUM_DASH);
plot Line701 =if MarketOpen then  Line70 else double.NaN;
Line701.SetStyle(Curve.SHORT_DASH);
plot Line301 = if MarketOpen then Line30 else double.NaN;
Line301.SetStyle(Curve.SHORT_DASH);
plot Line201 = if MarketOpen then  Line20 else double.NaN;
Line201.SetStyle(Curve.SHORT_DASH);
plot Line101 = if MarketOpen then Line10 else double.NaN;
Line101.SetStyle(Curve.SHORT_DASH);

##### Colors
Line901.SetDefaultColor(Color.WHITE);
Line801.SetDefaultColor(Color.VIOLET);
Line701.SetDefaultColor(Color.DARK_GREEN);
Line301.SetDefaultColor(Color.DARK_GREEN);
Line201.SetDefaultColor(Color.VIOLET);
Line101.SetDefaultColor(Color.WHITE);
 

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

Thank you so mu
Give this a shot. You can change the start and end periods or turn it off altogether if you rather have it go 24 hrs.

C++:
### Trend Tracker
### Created by Jean Botelho
### Inspired in the Rastreador de Tendência by Leo Nonato and Wagner Belzonte UAI


## Inputs

input TimeFrame = AggregationPeriod.DAY;
input length = 22;
input priceH = FundamentalType.HIGH;
input priceL = FundamentalType.LOW;
#input displace = 0;
input tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
input OpenTime = 0930; #hint OpenTime: Opening time of market
input CloseTime = 1600; #hint CloseTime: Closing time of market

### Definitions
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
# Only use market hours when using intraday timeframe
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;

def priceHigh = highest(Fundamental(priceH, period = timeframe), length);
def priceLow = lowest(Fundamental(PriceL, period= timeframe), length);
def range = priceHigh - priceLow;

def Line90 = priceLow + (0.9 * range);
def Line80 = priceLow + (0.8 * range);
def Line70 = priceLow + (0.7 * range);
def Line30 = priceLow + (0.3 * range);
def Line20 = priceLow + (0.2 * range);
def Line10 = priceLow + (0.1 * range);

#### Plots

#plot intervalo = range;
#intervalo.setstyle(curve.SHORT_DASH);
plot Line901 = if MarketOpen then Line90 else double.NaN;
Line901.SetStyle(Curve.SHORT_DASH);
plot Line801 = if MarketOpen then Line80 else double.NaN;
Line801.SetStyle(Curve.MEDIUM_DASH);
plot Line701 =if MarketOpen then  Line70 else double.NaN;
Line701.SetStyle(Curve.SHORT_DASH);
plot Line301 = if MarketOpen then Line30 else double.NaN;
Line301.SetStyle(Curve.SHORT_DASH);
plot Line201 = if MarketOpen then  Line20 else double.NaN;
Line201.SetStyle(Curve.SHORT_DASH);
plot Line101 = if MarketOpen then Line10 else double.NaN;
Line101.SetStyle(Curve.SHORT_DASH);

##### Colors
Line901.SetDefaultColor(Color.WHITE);
Line801.SetDefaultColor(Color.VIOLET);
Line701.SetDefaultColor(Color.DARK_GREEN);
Line301.SetDefaultColor(Color.DARK_GREEN);
Line201.SetDefaultColor(Color.VIOLET);
Line101.SetDefaultColor(Color.WHITE);
Thank you so much.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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