PDA

View Full Version : enter only between 700 - 1615


starrynight
02-18-2009, 06:46 AM
Using the wizard , how can I make my strategy enter only after 7 am and exit all at 4:15 pm ?

I want to have the strategy running before and after these times but need it to only enter on signals that trigger between 7 and 415 .

I tried having the strategy enter if the volume is high enough but I use tick charts and this made using volume in this way difficult .

NinjaTrader_Josh
02-18-2009, 07:19 AM
Hi starrynight,

Please see this reference sample for creating time filters: http://www.ninjatrader-support2.com/vb/showthread.php?t=3226

starrynight
02-18-2009, 07:58 AM
So if I copy and paste this into my strategies code I've got what I need right ? .......

/* Checks to see if the time is during the busier hours (format is HHMMSS or HMMSS). Only allow trading if current time is during a busy period.
The timezone used here is (GMT-05:00) EST. */
if ((ToTime(Time[0]) >= 70000 && ToTime(Time[0]) < 160000) ||

Then just run my strategy " exit on close" = true to close open positions .

NinjaTrader_Josh
02-18-2009, 08:02 AM
No, ExitOnClose does not work with the time filter. It works with your session times. If your filter coincided with the session end time then it would work, otherwise you need to explicitly place exit orders to close your positions at the end of your time range.

if (ToTime(Time[0] >= 160000)
ExitLong();Bear in mind that this code snippet will not work in closing you out of your position if 4PM is market close. You would be submitting your order too late.

starrynight
02-22-2009, 05:32 AM
I want to leave the session time 12 am - 12 am ( default) but want to close any open position at 3:55 pm so as not to leave an open position during low volume times .

Can I do this with the wizard ?

NinjaTrader_Ben
02-22-2009, 11:06 AM
Hello,

Yes, you can. Just use Time Value > User Definded Inputs. Time value can be found under Time>Time value.

Then in your actions section put in ExitLong() and/or ExitShort().

starrynight
02-22-2009, 11:47 AM
OK , I tried that . I selected "time value "on the left ( the value shown is present time ), greater than (>) and then "user defined input" on the right . For "user defined input" I selected 1545 ( 3:45 PM ) under default .

I get back - Return type of left expression 'Date Time' and right expression 'Int32' do not match. You need to select a different item .

What did I miss here ?

NinjaTrader_Ben
02-23-2009, 02:14 AM
Hello,

The data type has to be the same. I am thinking it is not possible now. Sorry about that. I will have someone double check that there is no other way.

You can program it, but it may not be possible in the Wizard.

starrynight
02-23-2009, 05:49 AM
No problem , what I did try is this ....

When the following conditions are true:

Time value- > Time value-

(Value = present time) (Value= 3:55 pm)


Do the following:

Exit short / Exit long

Problem is when I tried it that didnt seem to work . Let me know if I'm on the right path or if anyone has other ideas .

Exactly what I'm trying to achieve is to leave my strategies session time 12 AM - 12 AM , run my strategy 24 hrs , but submit exit orders 5 minutes before the NYSE bell .

NinjaTrader_Bertrand
02-23-2009, 09:46 AM
Try selecting Time series on the left side, the leave barsAgo at 0, as this sbould give you the current time - then select Time value on the right side and enter your time setting.