![]() |
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 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I have two strategies for trading the same security (eg: EURUSD on a short term and on a long term strategy). I want them to work independently, without knowledge or consideration as to what the other strategy is doing. Ie, I don't mind doubling my risk, or having my two strategies make equal, opposing trades (since they'll close out at different times anyway). My problem is that I use "Position.MarketPosition == MarketPosition.Flat" as a condition to ensure that each strategy handles only one trade at a time. As a result, when strategy A is long EURUSD, strategy B cannot trade, since the account is not "flat" EURUSD. This is because Position.MarketPosition == MarketPosition.Flat is a reference to the account position. In light of these facts, it becomes clear that Position.MarketPosition == MarketPosition.Flat is not a valid mode of position control when running two strategies side by side trading the same security. I would like to know how I can programme my two strategies to run side by side on the same security without one interrupting the other. Is it possible? As alternatives to "Position.MarketPosition == MarketPosition.Flat", I have tried using Position.Quantity and Variables0-9 to determine if the strategy has traded, but neither seems to work (since Variable0 is undefined at the beginning of a loop, and for some strange reason, position.quantity work). |
|
|
|
|
|
#2 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
Also, if there is no way to prevent the strategies from clashing, I might have to consider opening a separate IB account so that the issue does not arise. Will I be able to use the same NT license for both IB accounts? Am hoping to find a solution though!
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
skyholder84, NinjaTrader strategies are completely independent of each other. As such, they cannot read position information from other strategies. Since NinjaScript is based off of C#, you are able to code up a position tracker however you wish, from writing to a file and then reading that file in your other strategy, the whole way to a full-featured MySQL database that tracks all orders, fills, and positions.
So it is possible, but not in a direct fashion.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
Would I be able to say, set a different order quantity for each strategy to act as a control?
Illustration: Strategy A trades only 1 contract Strategy B trades 2 contracts The control logic would go like this: If(StrategyAGeneralConditions = True && Position.Quantity != 1 && Position.Quantity != 3) {EnterLong(20000, "LS1");} - If Position Quantity is 0, neither strategy has traded, and Strategy A is good to go. - If Position Quantity is 2, only Strategy B has traded, and Strategy A is also good to go. - If Position Quantity is 3, both strategies have traded, and Strategy A is blocked from further trading (Of course, a similar measure will be written in Strategy B) Hence, as long as Position.Quantity != 1, my strategy can "deduce" that it hasn't traded. Can I use the Position.Quantity function as a control in this way? |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi skyholder84,
Your net account position will reflect activity for both strategies, but all the properties you're using only apply within the strategy instance that access them. If you check MarketPosition, you're checking that strategies position rather than the account position. There are only a handful of account level properties you can access. The rest are specific to the strategy instance calling them.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Running Strategies in Replay with Multiple Accounts | FormulaXTrader | Automated Trading | 5 | 03-14-2011 03:24 AM |
| Running Ninja Strategies with Multiple Data Feeds in Simulation Mode | KBJ | Version 7 Beta General Questions & Bug Reports | 3 | 07-12-2010 09:09 PM |
| Running multiple strategies simultaneously | d.allen101 | Strategy Development | 7 | 08-14-2009 05:50 AM |
| Running Multiple Strategies on 1 Instrument | SystemTrading | Strategy Development | 5 | 02-25-2009 12:04 PM |
| PCTools Internet Security software. Anyone running this ok? | saltminer | Connecting | 1 | 01-27-2009 07:31 AM |