I want to build a sound alert into my strategy that goes off 5 minutes before a chosen time (say a scheduled news release at 10:00 am).
My first idea was this:
if (Times[0][0].TimeOfDay > new TimeSpan(9, 54, 00) && Times[0][0].TimeOfDay < new TimeSpan(10, 00, 00))
This way I would get a sound signal 5 times from 9:55 to 9:59. I like this, but in order to maintain it I need to type two times per alert. Not handy and error prone.
My second idea was this:
if (ToTime(Time[0]) >= NewsTime1Warning && ToTime(Time[0]) < NewsTime1))
I would define NewsTime1 to be 100000 and NewsTime1Warning would be NewsTime1 minus 5 minutes.
I like this better because I only have to type one time instead of two.
Unfortunately, I cannot find an elegant solution here. While I would need to subtract 500 from say 93000 (to become 92500) I would need to subtract 4500 from 100000 (to become 95500). I can certainly write this in a long if statement, but it does not seem good coding and I am sure there is a function that does what I wish to do.
Would anyone be so kind and give me a hint, please?
P
Comment