![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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
}
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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();
}
http://www.ninjatrader.com/support/h...l?exitlong.htm http://www.ninjatrader.com/support/h...?exitshort.htm
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Joydeep for this post: |
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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
}
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 times in 0 posts
|
Perfect! this is what I was looking for. I will try this and let you know.
|
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello a1982yusuf,
Thanks for your note. Please let me know if I can assist you any further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Joydeep for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |