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,748 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
16 thanks
Darmok and Jalad at Tanagra
3 thanks
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
1 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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


© 2026 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 - Downloads - Top
no new posts