Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
In C# how do I compare the current bar's time with a hardcoded 14:30:00?
if ((String.Compare(Time[0].ToString("yyyyddMM"),"20140309") < 0) ||
(String.Compare(Time[0].ToString("yyyyddMM"), "20140330") >0))
{
// do what you want to do...
}
if ((String.Compare(Time[0].ToString("HHmmss"),"143000") < 0) ||
(String.Compare(Time[0].ToString("HHmmss"), "144500") >0))
{
// do what you want to do...
// do nothing between 14:30:00 and 14:45:00
}
but i'm also creating class libraries/trading strategies that run outside of NT
and then a more standard c# approach is better
but if you stay withing NT and don't run the code outside NT,
then the solution of @shodson is cleaner... and preferable
Thanks for the responses! The Multicharts.Net version I came up with is this:
However, now I have another question: How do I get that code to run only once if I am using tick data? The other problem is that by using seconds, I sometimes get no result for that day, because no ticks happened right at the 0th second. Any suggestions?
i was just going to say.... with that if, it will only trigger if exactly on that time there is a bar,
if there is 5 second silence, then your code would not be triggered
therefore you would more likely do something like this :