Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Is it possible calling Time of the day without any event-driven known method in NT7

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is it possible calling Time of the day without any event-driven known method in NT7

    My goal is simple, calling time of the day regardless of any NT7 event-driven method is called, I mean I'd like to build my own time-driven method. Sounds simple but I believe it's not given NT7 fixed event-driven architecture. It should be something like:

    Code:
    // Variable declaration
    private TimeSpan 	start= new TimeSpan(16, 59, 00);
    private TimeSpan 	end= new TimeSpan(17, 14, 59);
    
    // Core
    if ( ( DateTime.Now.TimeOfDay > start ) && ( DateTime.Now.TimeOfDay < end ) )
    {
      // Do something;
    }

    Looking at this code sample, some question pop:

    Code:
    private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
    		{
    			TriggerCustomEvent(MyCustomHandler, 0, myTimer.Interval);
    		}		
    
    		private void MyCustomHandler(object state)
    		{
    			// Comparing and customer actions
            
    		}
    1. The only way to call "TriggerCustomEvent" is through "TimerEventProcessor" ?
    2. Is there any other way to call "TriggerCustomEvent" just from TimeOfDay?


    I'm doing my search but any suggestions would be appreciated as always !
    Last edited by pstrusi; 07-16-2018, 07:58 AM.

    #2
    Hello pstrusi,

    If you are wanting to trigger actions even if no ticks are being received (such as when the market is closed), then yes, use a timer.

    Below is a public link to an example of using a timer.


    TriggerCustomEvent() will synchronize the series to be up-to-date if these need to be used. (like calling the time or close price of bar)

    If you are needing actions to take place in real-time but are able to wait for ticks to be received to drive the actions, then use CalculateOnBarClose as false (or add a secondary series for intra-bar granularity).
    Last edited by NinjaTrader_ChelseaB; 07-16-2018, 09:37 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    147 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,282 views
    0 likes
    Last Post Leafcutter  
    Working...
    X