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?
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! :)
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.
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.