![]() |
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
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Yes, this is possible. Please refer to this link: http://www.ninjatrader-support.com/H...struments.html
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
|
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.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
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.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jun 2009
Posts: 120
Thanks: 2
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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;
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |