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,792 / 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?

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

Now I'm getting some odd results. Maybe you can easily see what's going on here:

 
Code
	
// This Block of code records the first closing price after 14:30. 
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute >= 30 && m_MyBarFlag == 0) 
{
Output.WriteLine("Hour: {0} Minute: {1} Data1 Close: {2}  Data2 Close: {3} Settlement Price: {4} Bar Flag {5}",
Bars.TimeValue.Hour, Bars.TimeValue.Minute, Bars.CloseValue, BarsOfData(2).CloseValue, Bars.Close.Value, m_MyBarFlag);

m_settlementPrice.Value = (Bars.CloseValue - BarsOfData(2).CloseValue);

m_MyBarFlag = 1;	// This marks that a value was recorded already.
			}

if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute < 20) m_MyBarFlag = 0;	// This resets the flag for the next day.
The Output of that code on 30 days worth of tick data:
Hour: 14 Minute: 30 Data1 Close: 93.96 Data2 Close: 93.39 Settlement Price: 93.96 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.61 Data2 Close: 93.15 Settlement Price: 93.61 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.35 Data2 Close: 92.88 Settlement Price: 93.35 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.84 Data2 Close: 93.35 Settlement Price: 93.84 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.88 Data2 Close: 93.35 Settlement Price: 93.88 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 94.51 Data2 Close: 93.79 Settlement Price: 94.51 Bar Flag: 0


Why would there not be 30 lines written to output, and why is the settlement price not being calculated?


Last edited by JHall65; August 28th, 2014 at 04:21 PM.
Reply With Quote
 
  #12 (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


JHall65 View Post
Now I'm getting some odd results. Maybe you can easily see what's going on here:

 
Code
	
// This Block of code records the first closing price after 14:30. 
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute >= 30 && m_MyBarFlag == 0) 
{
Output.WriteLine("Hour: {0} Minute: {1} Data1 Close: {2}  Data2 Close: {3} Settlement Price: {4} Bar Flag {5}",
Bars.TimeValue.Hour, Bars.TimeValue.Minute, Bars.CloseValue, BarsOfData(2).CloseValue, Bars.Close.Value, m_MyBarFlag);

m_settlementPrice.Value = (Bars.CloseValue - BarsOfData(2).CloseValue);

m_MyBarFlag = 1;	// This marks that a value was recorded already.
			}

if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute < 20) m_MyBarFlag = 0;	// This resets the flag for the next day.
The Output of that code on 30 days worth of tick data:
Hour: 14 Minute: 30 Data1 Close: 93.96 Data2 Close: 93.39 Settlement Price: 93.96 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.61 Data2 Close: 93.15 Settlement Price: 93.61 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.35 Data2 Close: 92.88 Settlement Price: 93.35 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.84 Data2 Close: 93.35 Settlement Price: 93.84 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.88 Data2 Close: 93.35 Settlement Price: 93.88 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 94.51 Data2 Close: 93.79 Settlement Price: 94.51 Bar Flag: 0


Why would there not be 30 lines written to output, and why is the settlement price not being calculated?


i think it has to do, where that code is
i don't see any errors right away

Reply With Quote
 
  #13 (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

Understood



JHall65 View Post
Now I'm getting some odd results. Maybe you can easily see what's going on here:

 
Code
	
// This Block of code records the first closing price after 14:30. 
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute >= 30 && m_MyBarFlag == 0) 
{
Output.WriteLine("Hour: {0} Minute: {1} Data1 Close: {2}  Data2 Close: {3} Settlement Price: {4} Bar Flag {5}",
Bars.TimeValue.Hour, Bars.TimeValue.Minute, Bars.CloseValue, BarsOfData(2).CloseValue, Bars.Close.Value, m_MyBarFlag);

m_settlementPrice.Value = (Bars.CloseValue - BarsOfData(2).CloseValue);

m_MyBarFlag = 1;	// This marks that a value was recorded already.
			}

if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute < 20) m_MyBarFlag = 0;	// This resets the flag for the next day.
The Output of that code on 30 days worth of tick data:
Hour: 14 Minute: 30 Data1 Close: 93.96 Data2 Close: 93.39 Settlement Price: 93.96 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.61 Data2 Close: 93.15 Settlement Price: 93.61 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.35 Data2 Close: 92.88 Settlement Price: 93.35 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.84 Data2 Close: 93.35 Settlement Price: 93.84 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 93.88 Data2 Close: 93.35 Settlement Price: 93.88 Bar Flag: 0
Hour: 14 Minute: 30 Data1 Close: 94.51 Data2 Close: 93.79 Settlement Price: 94.51 Bar Flag: 0


Why would there not be 30 lines written to output, and why is the settlement price not being calculated?

The reason for this behavior is due to the fact that on certain days there is no bar between , 14:00 and 14:20 that resets the flag. I have modified the code to reset the flag once we are passed midnight, that way the first bar after 14:30 will be captured and trigger the logic.

// This Block of code records the first closing price after 14:30.
if (Bars.TimeValue.Hour == 14 && Bars.TimeValue.Minute >= 30 && m_MyBarFlag == 0)
{
Output.WriteLine("Hour: {0} Minute: {1} Data1 Close: {2} Data2 Close: {3} Settlement Price: {4} Bar Flag {5}",
Bars.TimeValue.Hour, Bars.TimeValue.Minute, Bars.CloseValue, BarsOfData(2).CloseValue, Bars.Close.Value, m_MyBarFlag);

m_settlementPrice.Value = (Bars.CloseValue - BarsOfData(2).CloseValue);

m_MyBarFlag = 1; // This marks that a value was recorded already.
}

if (Bars.TimeValue.Hour < 14 ) m_MyBarFlag = 0; // This resets the flag for the next day.

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 07:40 PM.

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-17 in 0.09 seconds with 25 queries on phoenix via your IP 54.163.209.109