PreMarket Horizontal Line

ahramper1

New member
VIP
Hello Guys,
I am looking for a script for TOS that can put a horizontal line from a set time, let's say for the closing price of the 0800 am candle in the 1-hour timeframe (main timeframe), and that this line can be seen in different timeframes as in the screenshots that I attached. This line should only be drawn for the day, and the next day the line of the previous day disappears, and only the new line for 0800 am should be shown.

Thank you in advance.
 

Attachments

  • Screenshot 2023-07-05 Draw_Horizontal_Line_when_Candle_Close_Between_0800_to_0900_am.png
    Screenshot 2023-07-05 Draw_Horizontal_Line_when_Candle_Close_Between_0800_to_0900_am.png
    342.1 KB · Views: 126
  • Screenshot 2023-07-05 Draw_Horizontal_Line.png
    Screenshot 2023-07-05 Draw_Horizontal_Line.png
    289.2 KB · Views: 123
Hello Guys,
I am looking for a script for TOS that can put a horizontal line from a set time, let's say for the closing price of the 0800 am candle in the 1-hour timeframe (main timeframe), and that this line can be seen in different timeframes as in the screenshots that I attached. This line should only be drawn for the day, and the next day the line of the previous day disappears, and only the new line for 0800 am should be shown.

Thank you in advance.

As you want to use the "closing price of the 0800 am candle in the 1-hour timeframe (main timeframe),". then this will only plot on chart's with aggregations less or equal to 1-hour.

Your image shows that you want it to display on a 4-hour chart, and regrettably, it will not. If you choose to use the 4-hour chart as the main basis in your example, there is not a bar at 0800 , so the code below will use the next bar after this time (0900). This would mean that you would have to change the time input to 0900 to get the other charts to hopefully match the close on the 4-hour chart.

The following should work when all timeframes are aggregations less than or equal to the main chart's aggregation and the time input is available.

Screenshot 2023-07-06 143354.png
Code:
#Price_at_aggregation_at_Time

input showlastonly = yes;
input openingTime  = 0800;
input aggregation  = AggregationPeriod.HOUR;
input price        = fundamentalType.CLOSE;
input bubble       = yes;
input label        = yes;


def sec1 = SecondsFromTime(openingTime);

def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0);

def price1  = if isTime1 then fundamental(price, period =aggregation) else price1[1];

plot priceagg = if showlastonly and GetDay() != GetLastDay() then Double.NaN else if sec1 >= 0 then price1 else Double.NaN;
priceagg.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

AddLabel(label,
(if aggregation == AggregationPeriod.MONTH
 then "M"
 else if aggregation == AggregationPeriod.WEEK
 then "W"
 else if  aggregation >= AggregationPeriod.DAY
 then aggregation / 60000 / 1440 + "D"
 else if aggregation >= AggregationPeriod.HOUR
 then aggregation / 60000 / 60 + "H"
 else aggregation / 60000 + "m")
+ (if price == fundamentalType.CLOSE
   then " Close"
   else if price == fundamentaltype.open
   then " Open"
   else if price == fundamentaltype.high
   then " High"
   else " Open")
+ "@" + openingTime + " : " + AsDollars(priceagg), Color.YELLOW);

AddChartBubble(bubble and IsNaN(close[-1]) and !IsNaN(close), priceagg, (if openingTime < 1000 then "0" else "") + AsPrice(openingTime) + "\n" + AsDollars(priceagg), priceagg.TakeValueColor());
 
Last edited:

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

As you want to use the "closing price of the 0800 am candle in the 1-hour timeframe (main timeframe),". then this will only plot on chart's with aggregations less or equal to 1-hour.

Your image shows that you want it to display on a 4-hour chart, and regrettably, it will not. If you choose to use the 4-hour chart as the main basis in your example, there is not a bar at 0800 , so the code below will use the next bar after this time (0900). This would mean that you would have to change the time input to 0900 to get the other charts to hopefully match the close on the 4-hour chart.

The following should work when all timeframes are aggregations less than or equal to the main chart's aggregation and the time input is available.
Good evening @SleepyZ, thank you very much for this indicator, it is just what I needed, tailored to what I had thought. I was testing the indicator for the 4 hour timeframe and I adjusted the opening time settings to the 0500 candle and the aggregation to 4 hours, and the horizontal lines show the same information with the other charts of 1 hour, 15 minutes, and 5 minutes (I am attaching a screeshot with the 4 charts). I am very grateful for the help I have received from you.
 

Attachments

  • Screenshot 2023-07-06 Pre_Market_Horizontal_Line_4h_1H_15m_5m.png
    Screenshot 2023-07-06 Pre_Market_Horizontal_Line_4h_1H_15m_5m.png
    324 KB · Views: 98

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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