PDA

View Full Version : Ticks to seconds -- code help


kcsystemtrader
03-31-2009, 10:13 AM
I get an entry signal of '1' from an indicator on a tick by tick timeframe. As soon as I get the '1', I want to start measuring seconds (i.e. timestamp when the '1' is thrown and then start a timer countdown basically). After 'x' amount of seconds have passed I want to re-evaluate the signal before placing an order.

Anyone know how to timestamp this event and then do something 'x' seconds later? Would you use TriggerCustomEvent? Thanks,

kc

NinjaTrader_Josh
03-31-2009, 10:24 AM
kc,

Unfortunately this requires much more advanced C# than we can offer indepth assistance for. You will likely need to create your own custom timer event. Please see this reference sample: http://www.ninjatrader-support2.com/vb/showthread.php?t=5965

kcsystemtrader
03-31-2009, 04:33 PM
kc,

Unfortunately this requires much more advanced C# than we can offer indepth assistance for. You will likely need to create your own custom timer event. Please see this reference sample: http://www.ninjatrader-support2.com/vb/showthread.php?t=5965

I was afraid of that...thanks, I'll try to work through the sample.

mrlogik
03-31-2009, 05:51 PM
I got your back :-)


private int TimeToSec()
{
int t = ((Time[0].Hour * 3600) + (Time[0].Minute * 60) + (Time[0].Second) + (Time[0].Millisecond / 1000));
return t;
}


This function will convert any time of the day into seconds. You can then calculate a delta on each call.

hope this helps