NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 03-07-2011, 08:51 AM   #1
561timw
Member
 
Join Date: Dec 2008
Posts: 33
Thanks: 0
Thanked 0 times in 0 posts
Default Don't take trade on Friday after 3:30

I would like help with the code needed to prevent trading on Friday after 3:30. My straegy runs from Sun at 6:00 until it closes out any open positions on Friday at 3:30 and I want to prevent new trades from kicking off Friday after 3:30.

Thanks
561timw is offline  
Reply With Quote
Old 03-07-2011, 09:33 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello 561timw,

Here is a line that may used to check for this:
bool myTradeFilter = Time[0].DayOfWeek != DayOfWeek.Friday && ToTime(Time[0]) <= 153000;

Please see this link which can help working with DateTime objects:
http://www.ninjatrader.com/support/f...ad.php?t=19292
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-07-2011, 12:09 PM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by 561timw View Post
I would like help with the code needed to prevent trading on Friday after 3:30. My straegy runs from Sun at 6:00 until it closes out any open positions on Friday at 3:30 and I want to prevent new trades from kicking off Friday after 3:30.

Thanks
Code:
if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 153000 && ToTime(Time[1]) < 153000 ) NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything();
This will take you flat and close down you strategy in one fell swoop. Unfortunately, the command is not a supported function, so be warned that it may stop working if NT decides to nix it any time in the future.
Last edited by koganam; 03-07-2011 at 12:11 PM.
koganam is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compute Highest High between 9:30 AM and 10:30 AM mgbloomfield Indicator Development 5 03-20-2013 04:26 PM
How long does it to load 30 Range Charts, 30 days of data pehon Connecting 6 07-01-2010 10:43 AM
9.30 open price, 4.30 close diffused Strategy Development 3 01-20-2009 01:18 PM
Exit on Close exited 30 Minutes Early (instead of 30 secs) wayneFH Strategy Development 6 04-28-2008 04:52 AM
$97.30 Sell-Stop Order Filled at $96.30! davidfw1866 ATM Strategies (Discretionary Trading) 3 11-08-2007 06:43 AM


All times are GMT -6. The time now is 11:50 AM.