NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-23-2012, 03:53 AM   #1
a1982yusuf
Junior Member
 
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
Default Time based stop

Hello,
is there a way to enter time based stops in ninjatrader using tick charts? I know how to do this using time based charts using the bars since entry command, but was wondering if someone could help me with the right syntax to use using non-time based charts.
thanks
a1982yusuf is offline  
Reply With Quote
Old 07-23-2012, 04:05 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello a1982yusuf,
The Time[0] value in a tick chart will be not uniformed (like a time based chart). But you can still evaluate the Time[0] to enter a position by placing a code like
Code:
if (ToTime(Time[0]) >= 100000)  //do something after 10 AM
{
   //do something
}
Please let me know if I can assist you any further
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 07-23-2012, 04:11 AM   #3
a1982yusuf
Junior Member
 
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
Default

Thanks JoyDeep. Sorry for not being clear. My problem is once i enter a trade, I want to have a time based stop to exit the trade.
a1982yusuf is offline  
Reply With Quote
Old 07-23-2012, 04:21 AM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello a1982yusuf,
Thanks for the clarification.

You can simply use the Exit() method to exit your position.
Code:
if (ToTime(Time[0]) >= 150000)  //exit position after 3PM
{
    if (Position.MarketPosition == MarketPosition.Long)
          ExitLong();
    else if (Position.MarketPosition == MarketPosition.Short)
           ExitShort();
}
Please refer to our help guide to know more
http://www.ninjatrader.com/support/h...l?exitlong.htm
http://www.ninjatrader.com/support/h...?exitshort.htm
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 07-23-2012, 04:37 AM   #5
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello a1982yusuf,
For any time based stops you can also try this code

Code:
if (Time[0].Subtract(Time[this.BarsSinceEntry()]).TotalMinutes > 3)  //exit trade after 3 minutes of entry
{
	//do something
}
Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 07-23-2012, 04:54 AM   #6
a1982yusuf
Junior Member
 
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
Default

Perfect! this is what I was looking for. I will try this and let you know.
a1982yusuf is offline  
Reply With Quote
Old 07-23-2012, 04:57 AM   #7
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello a1982yusuf,
Thanks for your note.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
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
How to add an indicator based on time-based bars to a tick chart? aviat72 Version 7 Beta General Questions & Bug Reports 1 07-27-2010 04:10 PM
The time labels are still based on the end time clearpicks Version 7 Beta General Questions & Bug Reports 1 07-21-2010 10:34 AM
Stop Loss based on calculation 561timw General Programming 7 09-11-2009 02:21 PM
ATR based Stop Loss moon_rainz Strategy Development 2 07-17-2008 11:42 PM
Need help with strategy based on Simulated stop vking ATM Strategies (Discretionary Trading) 9 10-18-2007 06:27 AM


All times are GMT -6. The time now is 09:39 PM.