If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

This answers could be found in the attached trace file.
As you can see they are both run on Sim101 and its 2 different currencypairs, USDCAD and USDSEK. I have re-created this problematic behaviour in both my eSignal datafeed as well as my Simulated datafeed.

As I also deal with risk positioning, then I need to add other currencypairs using the add() command in Initialize() in order to be able to do that. I was asking if maybe this is causing the problem?

Please see the attached code and trace file from my previous email where I have attached the code for LoadAllCurrencyPairs() that is using the Add() function and is called from within Initialize().

A summary of HOW the erroneous behaviour occurs:
I run 2 independent charts on 2 different currency pairs running my strategy.
Chart 1 got an order entry.
When entry on chart number 2 is enabled, it enters its Deactivation() function in my strategy on Chart 2 ( I use a message box for debugging), that disables the strategy on Chart 1.
In other words, after Chart 1 is in position and when Chart 2 enables its entry then the strategy in Chart 1 is disabled from the code in my strategy on Chart 2, but there is NO message box showing up on Chart 1.
I added this message box for debugging purposes.

Also noticed:
When I have a chart number X running my strategy that has taken an entry position, and then I go to my Positions tab and Close an open position I entered manually before, than this close ALSO disables my strategy in chart X

Also noticed:
WHEN, and only WHEN I run my strategy on 2 or more charts using the very same currency pair (Barsinprogress==0) then this erroneous behaviour does NOT appear.
It only appears when I use different chart windows with different currency pairs.

What this means is that the strategies are NOT fully isolated, and I think this has something to do with HOW I add the other currency pairs into my primary barsinprogress==0 chart. I have attached the function that adds my other currency pairs (barsinprogress !=0) in this thread.

Maybe the problems occurs when I open a new chart with a currency pair that has been already opened as a secondary currency pair in the first chart through my Add() function?!?

Comment

We need to clear a few items up and I would like to request your Log, not just your Trace.

1. So your "deactivation" logic is your own and you intentionally disable other strategies? This seems to be contrary to your statement that it is unexpected.
What is your "deactivation" logic? Is this something you can provide to help us assist you in this matter?
I am confused on the overall logic for DeActivation(). Why would Add() have anything to do with it? Why would it only concern itself with other primary instruments that do not match the current strategies?
These are all questions I cannot answer without your code or you advising in detail.

2. The Message Box generally appears when you "deactivate" a strategy?

3. Closing a position that a strategy is managing from the the Positions tab should disable the strategy that is managing the position.

Comment

We need to clear a few items up and I would like to request your Log, not just your Trace.

Attached in this email, but as I stated before, there is nothing of value in the Log file.

1. So your "deactivation" logic is your own and you intentionally disable other strategies? This seems to be contrary to your statement that it is unexpected.
What is your "deactivation" logic? Is this something you can provide to help us assist you in this matter?

The "Deactivation" logic and code is below, and it does NOT intentionally disable other strategies. What happens is that when my first chart window, trading a currencypair is being activated and gets an entry, then when I open a different chart, trading a different currencypair. When this 2:nd chart gets an entry, then somehow it goes to Deactivation() function in strategy running on chart 2, and suddenly disables the 1:st chart window and strategy, so it stops working. As I explained above, it is almost like these strategies somehow effect eachother. BUT, this behaviour does NOT happen if I open a second chart using the same currencypair as I used on the first chart.
Let me know if this makes sense?

I am confused on the overall logic for DeActivation(). Why would Add() have anything to do with it? Why would it only concern itself with other primary instruments that do not match the current strategies?
These are all questions I cannot answer without your code or you advising in detail.

Because when I disable (comment out) the function LoadAllCurrencyPairs(), that uses add() to add other underlying currency pairs for my lot sizing function, then I do not have this behavior at all, and everything works fine. The erroneous behavior starts the moment I add other underlying currency pairs into my strategy, than I get this strange behavior when I open new charts to trade a different currency pair. It is important to note that I am always adding all currency pairs from my Forex-list for potential cross currency comparison each time I open a new window using a currency pair as a instrument I want to trade.

2. The Message Box generally appears when you "deactivate" a strategy?

Yes, right now it does. I added a Message Box into the Deactivation function for debugging purposes. I always use Message Boxes for debugging purposes.

3. Closing a position that a strategy is managing from the the Positions tab should disable the strategy that is managing the position.

Yes, it does, but also deactivates other strategies that run on other preliminary currency pairs as I explained above. I want to know what is causing this behavior.

I look forward to your response.

Thank you, looking forward to your answer as this is such a critical situation to me.

Comment

After putting MessageBoxes everywhere where the CancelAllOrders() native functions is being called I found out that it is inside OnPositionUpdate() in my code that the CancelAllOrders() function is being called that cancel my other strategies:

Comment

CancelAllOrders() is not supported in NinjaTrader 7. The function is there but it is not supported for use in NinjaScript. The only overloads it has are to cancel all entries or all exits and it would appear it also disables strategies. I would recommend straying away from this function and potentially tracking your orders in your code and then cancelling them with CancelOrder().

Comment

CancelAllOrders() is not supported in NinjaTrader 7. The function is there but it is not supported for use in NinjaScript. The only overloads it has are to cancel all entries or all exits and it would appear it also disables strategies. I would recommend straying away from this function and potentially tracking your orders in your code and then cancelling them with CancelOrder().

Thank you for your earlier reply.
After doing further debugging I have replaced CancelAllOrders() with CancelOrder() and it is NOT working, and I get the very same erroneous behavior using CancelOrder(), this is how my new SetNotActive() function looks like where this problem occurs predominantly.

BUT, can I really use CancelOrder() IF I am ONLY using market order type throughout my strategy and NOT limit order type for all my orders?

I am only using EnterLong(), EnterShort() together with ExitLong() and ExitShort() functions in my strategy due to the previous problem with incompatibility problems between using eSignal as preliminary datafeed and then placing LimitOrders through Ninjatrader7 and executing them through FXCM. This did NOT work at all unfortunately!

Comment

You would need to ensure the Market Orders IOrder objects is being set to null when filled if you are trying to ensure this is not CancelOrder() causing this item.

You may wish to look to the StrategyState code you have. At this point I would recommend debugging your strategy further.

Thank you for your reply!
I have tried to debug by activating the TraceOrder function as well as making sure that each IOrder object is set to null after ExitLong() or ExitShort() function is being run (filled).
Unfortunately, the Output Window does not give any valuable output when my problem occurs.

Example of how my ExitShort() code looks like:
if (CurrentPrice >= RayPrice(_currentRayContainer.StopRay))
{
_currentExitOrderSTOP = ExitShort("Exit Short STOP","");
MessageBox.Show("_currentExitOrderSTOP has ExitShort and this is is content before I null it: " + Convert.ToString(_currentExitOrderSTOP));
_currentExitOrderSTOP = null;

Example of how my ExitLong() code looks like:
_currentExitOrderSTOP = ExitLong("Exit Long STOP","");
MessageBox.Show("_currentExitOrderSTOP has ExitLong and this is is content before I null it: " + _currentExitOrderSTOP);
_currentExitOrderSTOP = null;

Comment

I sent you a video.
My strategies are disabling each other, they are not isolated.
If I setup more then 1 chart running my strategy, and then one Entry line gets triggered, then it disables my my other strategies.

Comment

Can you provide the most updated version for testing on our end? You can send this to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H' in the subject line and a reference to this thread in the body of the email.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.