In C# how do I compare the current bar's time with a hardcoded 14:30:00? - MultiCharts | futures io social day trading
futures io futures trading


In C# how do I compare the current bar's time with a hardcoded 14:30:00?
Updated: Views / Replies:1,793 / 12
Created: by JHall65 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

In C# how do I compare the current bar's time with a hardcoded 14:30:00?

  #1 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received

In C# how do I compare the current bar's time with a hardcoded 14:30:00?

In C# how do I compare the current bar's time with a hardcoded 14:30:00?

Reply With Quote
 
  #2 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,505 since Sep 2013
Thanks: 1,706 given, 3,719 received
Forum Reputation: Legendary

The answer...

as an example :

if ((String.Compare(Time[0].ToString("yyyyddMM"),"20140309") < 0) ||
(String.Compare(Time[0].ToString("yyyyddMM"), "20140330") >0))
{
// do what you want to do...
}



Is this what you need ?

regards,
Ron

Reply With Quote
 
  #3 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,505 since Sep 2013
Thanks: 1,706 given, 3,719 received
Forum Reputation: Legendary

and time



JHall65 View Post
In C# how do I compare the current bar's time with a hardcoded 14:30:00?

as an example :

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
}



Is this what you need ?

regards,
Ron

Reply With Quote
 
  #4 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

Answer
This post has been selected as an answer to the original posters question Answer

Or, more simply, using the ToTime() method...

 
Code
if (ToTime(Time[0]) == 143000)
   // do something

Reply With Quote
The following user says Thank You to shodson for this post:
 
  #5 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received


rleplae View Post
as an example :

if ((String.Compare(Time[0].ToString("yyyyddMM"),"20140309") < 0) ||
(String.Compare(Time[0].ToString("yyyyddMM"), "20140330") >0))
{
// do what you want to do...
}



Is this what you need ?

regards,
Ron


Ron, thanks for your help! I am trying to record a settlement price. So it would be nice to know the format to use for 14:30.

Thanks again,

Jason

Reply With Quote
 
  #6 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,505 since Sep 2013
Thanks: 1,706 given, 3,719 received
Forum Reputation: Legendary

syntax


JHall65 View Post
Ron, thanks for your help! I am trying to record a settlement price. So it would be nice to know the format to use for 14:30.

Thanks again,

Jason

@shodson gave a shorter, more simple solution

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

Reply With Quote
 
  #7 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received


rleplae View Post
but i'm also creating class libraries/trading strategies that run outside of NT and then a more standard c# approach is better

Without using anything Ninjatrader-specific...

 
Code
if (Time[0].Hour == 14 && Time[0].Minute == 30)
    // do stuff

However, Time[0] is a Ninjatrader-specific DataSeries so you'll have to de-Ninja that if you want to be pure...

Reply With Quote
The following 2 users say Thank You to shodson for this post:
 
  #8 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received

Multicharts.Net C# Solution

Thanks for the responses! The Multicharts.Net version I came up with is this:
 
Code
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute == 30 && Bars.TimeValue.Second == 00 ) {
m_settlementPrice.Value = Bars.Close.Value;
}
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?

Reply With Quote
 
  #9 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,505 since Sep 2013
Thanks: 1,706 given, 3,719 received
Forum Reputation: Legendary

my thoughts

Answer
This post has been selected as an answer to the original posters question Answer


JHall65 View Post
Thanks for the responses! The Multicharts.Net version I came up with is this:
 
Code
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute == 30 && Bars.TimeValue.Second == 00 ) {
m_settlementPrice.Value = Bars.Close.Value;
}
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 :

if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute >= 30 && myBarFlag==0 )
{
m_settlementPrice.Value = Bars.Close.Value;
myBarFlag = 1;
}

if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute < 30 && Bars.TimeValue.Minute >= 20 )
{
myBarFlag = 0;
}


this would trigger the update with the first tick after 14:30:XX
and reset the flag a few minutes before that time


how does that sound ?

Reply With Quote
 
  #10 (permalink)
Elite Member
Denver Colorado
 
Futures Experience: Intermediate
Platform: Multicharts
Favorite Futures: Forex
 
Posts: 23 since Apr 2013
Thanks: 3 given, 2 received


Perfect! That's exactly what I was looking for. Thanks for your help!

Reply With Quote

Reply



futures io > > > > In C# how do I compare the current bar's time with a hardcoded 14:30:00?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
bid&Ask on Chart for current bar only aczk EasyLanguage Programming 3 February 24th, 2014 08:49 AM
Kinetick Users - Anyone have a huge swing on CL Data starting at 00:00 djoyce854 Reviews of Brokers and Data Feeds 2 July 9th, 2013 11:13 AM
Current bar height fttrdr NinjaTrader 1 November 2nd, 2012 01:35 AM
ES trading break from 16:30 to 17:00 only during DSL? aquarian1 Emini Index Futures Trading 4 March 17th, 2012 02:54 PM
Volume for Current Bar RambleDog NinjaTrader 4 May 16th, 2011 08:37 PM


All times are GMT -4. The time now is 01:25 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.14 seconds with 39 queries on phoenix via your IP 54.92.201.232