Thursday, November 13, 2008

thinkScript - Previous day's HLC + Today's Open


This study will chart the HLC of the previous trading day, and it will also plot today's opening price.

The “TIME” input, you will need to manually type in the specific time aggregation you are using, i.e. if you are looking at 5 minute chart, you must enter 5, if you are using 15 minute bars in your chart, you will enter 15 as the TIME.

As for the MARKET_OPEN input, this is the first bar of the day. The MARKET_CLOSE is a bit more complex…. This is the very last bar of the day. So, if you are looking at 15 minute bars, you must enter 1545. If you are looking at 5 minute bars, you must enter 1555.


Please recall that the times is stated in a 24hour form and it is Eastern Time. So, for example, 1600 is 4:00pm ET.

This will NOT work with TICK charts. Please note that this will only work if you are looking at "Trading Hours Only" within the Charts tab...


!!! FOR EDUCATIONAL PURPOSES ONLY!!! - PLEASE READ DISCLAIMER POST


input market_open = 930;

input market_close = 1545;

input time = 15;

rec begin_open = if(secondsTillTime(market_open) == 0, open,begin_open[1]);

rec begin_high = if(secondsTillTime(market_close) == 0, Highest(high, ((390 / time))),begin_high[1]);

rec begin_low = if(secondsTillTime(market_close) == 0, lowest(low, ((390 / time))), begin_low[1]);

rec begin_close = if(secondsTillTime(market_close) == 0, close, begin_close[1]);

plot highest = if(begin_high == 0, double.nan, begin_high);

highest.setdefaultcolor(color.orange);

plot lowest = if(begin_low == 0, double.nan, begin_low);

lowest.setdefaultcolor(color.light_red);

plot end = if(begin_close == 0, double.nan, begin_close);

end.setdefaultcolor(color.dark_gray);

plot opening = if(begin_open == 0,double.nan,begin_open);

opening.setdefaultcolor(color.blue);

3 comments:

Josiah said...

Cool script! I made some similar thinkscripts to show OHLC values for any timeframe (daily weekly monthly etc.) on lower timeframe charts, as well as an indicator to show the premarket highs and lows the same way.

Unknown said...

Hello, I have applied the script to a 5min chart and changed the parameters to 930 open and 1555 close. The lines are plotting correctly but for some reason there is now a 15min delay in price. I have live data on every other chart in my workspace. Any idea why this is happening?

Unknown said...

What does the 390 / time represent?