Sunrise & Sunset

Post any software related questions or comments here. This is also the place to ask for help if you can't figure out how to do something in Wave59.
dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Sunrise & Sunset

Post by dwedding » Fri May 25, 2018 7:45 pm

How do I use the Astro indicators to display the time of Sunrise and the time of Sunset on intraday charts?

sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Re: Sunrise & Sunset

Post by sbank » Fri May 25, 2018 9:12 pm

Here is an example from the QScript help under astro_riseset(). If you bring up the data window (ctrl-d) you can see the value. (Probably a nicer way would be to have a vertical bar at the time. But wasn't sure if this is all you were after, or something more complicated.)

Code: Select all

# this will execute on the very first bar the QScript runs
if (barnumber == barsback) {
    risetime=0;
}

# this block will only trigger at first bar of the day
if (day != day[1])
{
   # returns the rising time of the sun in New York for the given day
   risetime = astro_riseset(year, month, day, time, 40.7, 74.0, astro_sun, astro_rise);

}

plot1=risetime;         
Just for fun BTW, there is this article in Wikipedia for those that want to try to tackle this equation by hand:

https://en.wikipedia.org/wiki/Sunrise_equation

Also NOAA has a nice spreadsheet that shows some of these calculations:

https://www.esrl.noaa.gov/gmd/grad/solc ... tails.html

dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Re: Sunrise & Sunset

Post by dwedding » Fri May 25, 2018 10:02 pm

Thanks for your reply. I'll try out your script, but yes I did think that there was a vertical line somewhere in the Astro indicators that was much like the vertical lines for the planets.

BTW, I like the idea of using Excel spreadsheets for Astro calculations. I've been searching the internet for the Swiss Ephemeris spreadsheets to do some planetary calculations. The ephemeris spreadsheets that I've come across are not easy to decipher and they don't work on my Windows 64 bit system. I know this is not the topic for this forum, but since you mentioned spreadsheets, I'm still looking for a simple example of how to use the Swiss Ephemeris in Excel. I'm studying the programming documentation for it and gradually getting some understanding of it.

Back to my question. I will try your script and still look for a chart indicator that shows Sunrise and Sunset. Thanks for your help.

dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Re: Sunrise & Sunset

Post by dwedding » Tue May 29, 2018 6:35 am

I did find a way to plot the time of a sunrise and a sunset on an intraday chart, but it doesn't look accurate according to a website that provides these times by calculation. Also there doesn't seem to be a way to change the color of the sunrise and sunset lines.

Sunrise and sunset calculator
https://planetcalc.com/300/

On Wave59 first, go to the "astro" tab. Click "planet rise/set" under the dropdown tab. Make sure New York is checked. Then check both "rising" and "setting" times. This will display the rising and setting times of all planets on a chart. Now look for the red line marked "H" on bottom early in the morning with the line on bottom of the H. This is sunrise. Now look toward the end of the day for the red line with the H on top but the line horizontally on TOP of the H. This is sunset. If you select a 1 minute chart, use the measuring tool/bar counter to measure between both red lines and this will give you the minutes between sunrise and sunset.

dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Re: Sunrise & Sunset

Post by dwedding » Tue May 29, 2018 6:35 am

I did find a way to plot the time of a sunrise and a sunset on an intraday chart, but it doesn't look accurate according to a website that provides these times by calculation. Also there doesn't seem to be a way to change the color of the sunrise and sunset lines.

Sunrise and sunset calculator
https://planetcalc.com/300/

On Wave59 first, go to the "astro" tab. Click "planet rise/set" under the dropdown tab. Make sure New York is checked. Then check both "rising" and "setting" times. This will display the rising and setting times of all planets on a chart. Now look for the red line marked "H" on bottom early in the morning with the line on bottom of the H. This is sunrise. Now look toward the end of the day for the red line with the H on top but the line horizontally on TOP of the H. This is sunset. If you select a 1 minute chart, use the measuring tool/bar counter to measure between both red lines and this will give you the minutes between sunrise and sunset.

sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Re: Sunrise & Sunset

Post by sbank » Tue May 29, 2018 3:02 pm

Is your local time different than Eastern Time?

The astro_riseset() is returned in your local time?

Looking at your link, and also using Wolfram Alpha (https://www.wolframalpha.com/input/?i=s ... +york+city) I see that the rise time is set to 5:28am ET according to both sites.

I am seeing astro_riseset() return 5:29am ET. (So a difference of 1 minute.)

EDIT: Here is a quick mockup with vertical lines of just the sunrise.

Code: Select all

# this will execute on the very first bar the QScript runs
if (barnumber == barsback) {
    rise_time=0;
    rise_bar=0;
}

# this block will only trigger at first bar of the day
if (day != day[1])
{
   # returns the rising time of the sun in New York for the given day
   rise_time = astro_riseset(year, month, day, time, 40.7056, 74.008, astro_sun, astro_rise);
   rise_bar = Date_to_Bar(year, month, day, rise_time);
}

REF_sunrise=trendline(rise_bar,chart_low,rise_bar,chart_high,teal);
set_tl_style(REF_sunrise,ps_dot);  

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Sunrise & Sunset

Post by earik » Wed May 30, 2018 5:45 pm

Keep in mind that W59 doesn't know the distance above sea level for a particular location, and also won't take atmospheric conditions into consideration. So it will be slightly less accurate than NOAA, etc. But they should both be pretty close. If you're hours off, check to make sure you are using the same latitude/longitude, as well as the same time zone as whatever other source you check.

Earik

dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Re: Sunrise & Sunset

Post by dwedding » Thu May 31, 2018 3:12 am

All the planets are listed and can be selected individually, but it would be nice if the sun was also listed so it also can be selected for the sunrise and sunset with its own color.
Attachments
Format Planet Rise.JPG
Format Planet Rise.JPG (28.37 KiB) Viewed 357258 times
Last edited by dwedding on Fri Jun 01, 2018 3:56 pm, edited 1 time in total.

dwedding
Posts: 45
Joined: Wed Jul 05, 2017 8:00 pm
Contact:

Re: Sunrise & Sunset

Post by dwedding » Fri Jun 01, 2018 3:22 pm

I placed your code in the Qscript editor, built it and saved it. However, when I load it as an indicator; it doesn't work. I might be doing something wrong, but I don't know what it could be.
sbank wrote:
Tue May 29, 2018 3:02 pm
Is your local time different than Eastern Time?

The astro_riseset() is returned in your local time?

Looking at your link, and also using Wolfram Alpha (https://www.wolframalpha.com/input/?i=s ... +york+city) I see that the rise time is set to 5:28am ET according to both sites.

I am seeing astro_riseset() return 5:29am ET. (So a difference of 1 minute.)

EDIT: Here is a quick mockup with vertical lines of just the sunrise.

Code: Select all

# this will execute on the very first bar the QScript runs
if (barnumber == barsback) {
    rise_time=0;
    rise_bar=0;
}

# this block will only trigger at first bar of the day
if (day != day[1])
{
   # returns the rising time of the sun in New York for the given day
   rise_time = astro_riseset(year, month, day, time, 40.7056, 74.008, astro_sun, astro_rise);
   rise_bar = Date_to_Bar(year, month, day, rise_time);
}

REF_sunrise=trendline(rise_bar,chart_low,rise_bar,chart_high,teal);
set_tl_style(REF_sunrise,ps_dot);  

sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Re: Sunrise & Sunset

Post by sbank » Mon Jun 04, 2018 1:27 pm

When you say, doesn't work. Do you see an error? Or do you just not see anything show up on the screen? (If you see any error, please post it.)

If you do not see anything on the chart, then make sure when you created the indicator, you are picking "price" and not "screen" for the indicator.
2018-06-04 (1).png
2018-06-04 (1).png (76.27 KiB) Viewed 357244 times

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests