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,821 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?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
Trump Media to sell instant access to market-moving soci …
Traders Hideout
No book, only a stair: journaling fills where price move …
Cryptocurrency
Datafeed for Atas
Platforms and Indicators
EA
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
BERN ALGOS algo trading journal
3 thanks
NexusFi site changelog and issues/problem reporting
2 thanks
TopStep Trader disappointment
2 thanks
Want your NinjaTrader indicator created, free?
1 thanks
Running trading strategies on a VPS
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