NexusFi: Find Your Edge


Home Menu

 





for MC.NET C#: How do I input a time, and compare it to the current bar's time?


Discussion in MultiCharts

Updated
    1. trending_up 2,210 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

for MC.NET C#: How do I input a time, and compare it to the current bar's time?

  #1 (permalink)
thoughtful
Klamath Falls OR
 
Posts: 60 since Apr 2020
Thanks Given: 21
Thanks Received: 80

How do I work with times? There's no help from MC documentation, I found some builtin indicators that use time but it didn't help me, and online C# documentation for DateTime is so confusing & complex I gave up trying to understand it.

I'm making a simple indicator that plots vertical lines to mark the day session start-time & end-time. MC (and most other software) doesn't have a builtin indicator to do this [lame].

*******************
my code so far:

[Input] public int StartTime {get;set;}
...
StartTime= 800; //8:00 AM, I only need to input hours & minutes
...
if(Bars.Time[0] >= StartTime){ //this won't compile obviously
//I draw a vertical line to mark the start of the day session, I know how to do this part
}
*******************

Can anyone tell me how to code this?
Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
65 thanks
Funded Trader platforms
42 thanks
Battlestations: Show us your trading desks!
25 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
The Program
19 thanks
  #2 (permalink)
thoughtful
Klamath Falls OR
 
Posts: 60 since Apr 2020
Thanks Given: 21
Thanks Received: 80

OP here...
I just figured out a solution. Doh. Believe me, I tried to figure it out before, but I just happened to find more info on the DateTime type by chance. Boy, C# stuff can be cryptic/confusing.

*******************
here's my solution:

[Input] public int StartTime {get;set;} //same as before
...
StartTime= 800; //same as before
...
if((Bars.Time[0].Hour * 100)+Bars.Time[0].Minute >= StartTime){ //the solution
//draw a vertical line
}
*******************

So, NEVERMIND!

Reply With Quote
  #3 (permalink)
thoughtful
Klamath Falls OR
 
Posts: 60 since Apr 2020
Thanks Given: 21
Thanks Received: 80


Too bad you can't delete your threads, now this thread will be on this website for YEARS LOLOL.

Reply With Quote




Last Updated on June 15, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts