#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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
152 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
87 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
131 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
127 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
106 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment