Click here to Login

                                                   Horizontal line on the intraday chart with the day's opening price?


Josh McCormick
2020-07-15 15:15:06

I've been able to plot a horizontal line across my intraday chart with *yesterday's closing price*:

// Plot yesterday's closing value
prevclose=TimeFrameDecompress(TimeFrameApply (-1,close));
Plot (prevclose,"PREV CLOSE", colorDeepSkyBlue, ChartLine, StyleWidth2|StyleDashed|StyleHideYAxisValue);

QUESTION 1: What I really want to do is to plot a horizontal line across my intraday chart with *the current day's opening price*. Is there a straightfoward way to do this, or will I need to code something more complex?

UPDATE: I think I figured out how to do what I wanted. Is this the right way to do it?

// Plot each day's opening price across the Intraday chart
opening=BarsSince (day() != ref(day(),1)); // How many bars ago was the first bar of the day?
todayopened=Ref(open,opening); // Record the value of open() for that many bars ago.
Plot (todayopened,"OPEN",colorDeepSkyBlue, ChartLine, StyleWidth2|StyleDotted|StyleHideValues);

I saw that I could replace Ref(open,opening) with HistoPrice (_open,opening) but it doesn't seem to be any better.

QUESTION 2: Is there some sort of function like IsIntraday() so I can detect if I'm on an intraday chart?

2020-07-22 11:40:02


Best Answer
1/ It is correct. There is also another easier way:

c = HistoPrice(_open, 0);
plot(c, "");

2/ There is an IsEOD() function

Josh McCormick
2020-07-22 14:05:37


That's a lot more simple, thanks!

I had to make one more adjustment to avoid plotting a line across zero on the historical (daily) chart. Here's what I ended up with:
c = HistoPrice(_open, 0);
plot(max(c,(iseod()==1)*close), "");
UpdateColor (iseod()==1, ColorTransparent);

Based on my understanding of the scripting language, I can't do an if-then statement that will allow me to avoid the plot() function if IsEOD is true. So instead, when IsEOD is true, I set c to equal the closing value (to avoid stretching the vertical auto-scaling) and then an UpdateColor that sets the color to Transparent (so that it isn't shown on-screen).

If there is a way to use conditional IF...THEN...ELSE statements *in the scripting language* with functions like Plot(), let me know! :)

2020-07-24 16:36:35


No, this is not possible

2020-07-24 16:37:12


The only "if" you can do is with variables.
a = iff(condition, true, false);

Josh McCormick
2020-07-25 04:04:48


Good info, thanks.

For others who may end up reading this, I wanted to offer another If command that they might get some good use out of. When graphing the output of various indicators, you may want to apply a different text label (and, hey, let's go ahead and change the color too) depending on what the value of a variable might be.

Plot (a, IffStr(a>=0,"BULLS","BEAR"), colorBlack, ChartNone, StyleWidth3);
UpdateColor (a>0,colorGreen);
UpdateColor (a<0,colorRed);

But I'm getting off track here. Hey, thank you for the answers and the support!

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
Top 20 stocks with the highest 10 day rate of change - Current an...
How far are the close prices from the support line
Screen for finding potential high volume momentum growth for the ...
Number of dividend payments per day in the U.S. Stock Market
Stocks with the highest Volume Increase

How-to Lessons
How to plot a stock using different periods in the same chart
How to plot the number of stock tweets per day
How to plot a time-series that do not update the chart scale
How to plot two different time frames in the same chart
How to scale and move the chart Y-axis

Related Forum Threads
SUM for the past X days with intraday time series
Intraday Trading with the "Create a Trading System" tool.
Locks up when market is open while using the *daily* chart with I...
Limiting the scale of a candlestick chart with volume?

Blog Posts
Detect chart patterns using the auto support/resistance indicator
Backtesting chart patterns using the auto support and resistance ...
How to Adjust the Time Displayed in your Intraday Charts
How to measure market strength with the composite tool
6 New Ways to Download Free Intraday Data for the U.S. Stock Mark...

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.