#region Variables
...
private DateTime Timer = DateTime.Now;
private double myPrice = 0;
private bool firstrun = true;
...
#end region
protected override void OnBarUpdate()
{
if (firstrun = true)
{
Timer.AddSeconds(DateTime.Now.Second+5);
firstrun = false;
}
if(Timer.Second > DateTime.Now.Second)
{
Timer.AddSeconds(-1);
if(Timer.Second==DateTime.Now.Second)
{
LongBreakoutPrice = GetCurrentAsk();
Timer.AddSeconds(DateTime.Now.Second+5);
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Programming an event to occur once every 5 seconds?
Collapse
X
-
Programming an event to occur once every 5 seconds?
I am trying to create a strategy to change a double value once every 5 seconds. I am using the DateTime class but I'm not sure if this is the right way to do it.
Is there a timer class? I'm trying to make a time value to be 5 seconds greater than the current time, and then subtract it by 1 second. This looks like a HORRIBLE way to implement it but I have no idea where to start. I tried compiling a strategy to run like this and to draw a line on the chart where the double value is and it is not really working the way I want it to. And can I have the statement Timer.AddSeconds(DateTime.Now.Second+5); under void initialize()?Code:Last edited by dennho; 01-27-2010, 05:28 AM.Tags: None
-
dennho, please review the reference sample below dealing with the TriggerCustomEvent() you could use for this task - http://www.ninjatrader-support2.com/...ead.php?t=5965
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
332 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment