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 > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 02-12-2010, 09:25 PM   #1
shazzmoe
Senior Member
 
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
Default Trade based on 2nd chart

Just wondering if it is possible to execute a trade on one market/chart from another.

For example, if i want to fire off a trade in the ES or YM each time the $TICK chart moves a certain way how would I do that. I understand a lot about ninja script but don't have any idea how to reference multiple charts in a strategy or if its even possible.
shazzmoe is offline  
Reply With Quote
Old 02-13-2010, 08:55 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

Yes, this is possible. Please refer to this link:
http://www.ninjatrader-support.com/H...struments.html
NinjaTrader_Ben is offline  
Reply With Quote
Old 02-16-2010, 07:41 AM   #3
shazzmoe
Senior Member
 
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
Default

first of all thank you very much for your help, it works fantastic.

However there is one other thing I'm wondering if it is possible. Can I have an automated program like this stop executing once it hits x number of targets or stop losses?

For example say I want it to not trade anymore until I restart it once it gets stopped out three times in a row. Will it remember something like a counting variable as it continues to make trades? If it does, is there a simpler way than doing something like:

when position is not flat checking if the close[0] is == to stop add one to the stopped out variable. Once stopped out if variable is > 2 it will not be able to reach the trading code.

PS my automator calculates intrabar
shazzmoe is offline  
Reply With Quote
Old 02-16-2010, 07:49 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

shazzmoe,

You can do that, but you will need to program your own counter yourself. Whenever you get stopped just increase a counter variable by 1. Then in your trading conditions tell it to not be true if the counter >= 3 for instance.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-16-2010, 09:37 AM   #5
shazzmoe
Senior Member
 
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
Default

That's good to know this is doable, but I should have asked more specifically how do I know (in my code) that it has hit a stop?

also, i can't find anything on timers. I know how to exit a position at a specific time, but is is possible to exit after a trade has been active for 30mins?
Last edited by shazzmoe; 02-16-2010 at 09:50 AM.
shazzmoe is offline  
Reply With Quote
Old 02-16-2010, 02:00 PM   #6
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

shazzmoe, please see the reference titled monitoring stop-loss and profit-target orders for your first question. As for the timer, this reference sample goes over custom events and timer objects. You could also use BarsSinceEntry() if using minute-based bars.
NinjaTrader_Austin is offline  
Reply With Quote
Old 02-17-2010, 11:38 AM   #7
shazzmoe
Senior Member
 
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
Default

First of all thanks again for all your support, I now have a program that should do exactly what I want it to do.

However I have noticed that when I place the automator on a chart it automatically runs through the past data. For example, I have it to stop trading after X number of trades. But because It looks at the past data it starts out thinking it has done all its trades and thus will never trade. When I set my chart to not go back more than 40 bars (when there have been no acceptable trades) it outputs the correct variables for me and I'm assuming will trade properly at this point.

Is there a way to prevent this? I would really like my chart to look back more than a couple bars if possible.
shazzmoe is offline  
Reply With Quote
Old 02-17-2010, 11:57 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

shazzmoe,

Whenever you run a strategy it will always look through all your historical bars as if it were real-time bars for processing.

If you want to prevent historical processing but still have historical bars, add this to the beginning of OnBarUpdate().

Code:
if (Historical)
     return;
NinjaTrader_Josh 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
Adding 2nd Data Stream to Chart rsi77 Charting 3 01-27-2009 02:35 PM
Trade entry based off of High/Low of clicked on 1 minute bar on chart takacsj Charting 1 09-19-2008 03:20 AM
I added a 2nd symbol, but it doesn't show on the chart tradefaz General Programming 3 09-03-2008 08:38 AM
Time in Trade Based Functionality whitmark Suggestions And Feedback 1 10-18-2006 01:12 AM
Can't place orders in 2nd IB account that is connected 2nd Merv Connecting 2 12-12-2005 12:39 AM


All times are GMT -6. The time now is 04:56 PM.