PDA

View Full Version : Using multiple entry/exit signals simultaneously


Learning1
09-18-2007, 09:13 AM
Thanks to Josh for posting the entry on Using multiple entry / exit signals simultaneously. His script created a fair bit of clarity for me and helped move my current strategy forward. This brings me to my question.

The long strategy I am currently working on has 3 different entry conditions and 3 Different exit conditions. The Entries are labeled LEa, LEb, LEc.

Things seem to be fine on the entry front, but I have a couple of quirks on the exit side I am trying to locate. One possibility might be in the way I coded the exit orders. They are as follows:

if (Exit Condition 1 occurs ... Not the actual code)


{
ExitLongLimit(longExit1,"LX1", "LEa");
ExitLongLimit(longExit1,"LX1", "LEb");
ExitLongLimit(longExit1,"LX1", "LEc");
}


if (Exit Condition 2 occurs ... Not the actual code)

{
ExitLongLimit(longExit2,"LX2", "LEa");
ExitLongLimit(longExit2,"LX2", "LEb");
ExitLongLimit(longExit2,"LX2", "LEc");
}


if (Exit Condition 3 occurs ... Not the actual code)

{
ExitLongLimit(longExit3,"LX3", "LEa");
ExitLongLimit(longExit3,"LX3", "LEb");
ExitLongLimit(longExit3,"LX3", "LEc");
}


Here is my question: Does NinjaScript process all 3 exit conditions for all 3 Entry conditions? Let's say I am Long with 3 different positions LEa, LEb, and LEc. If Exit condition 2 occurs is there any reason all 3 long positions would not trigger an Exit long order at longExit2?

When I test this in the sim account I seem to be getting sporadic exits and I am trying to narrow whether it is due to an error in my conditions or in the fashion I have grouped the multiple exit orders.

Thanks for the help!!!

Learning1

NinjaTrader_Josh
09-18-2007, 10:55 AM
You could be experiencing varying fill conditions. Just because one order was filled doesn't mean the other seemingly identical order will also be filled. If you are simply trying to close all open positions you can do so without any fromEntrySignal. Do something like ExitLongLimit(100); where 100 is the limit price.

Learning1
09-18-2007, 01:33 PM
Thanks Josh. I am seeking to exit all open positions in the event any one of the 3 exit conditions are triggered. I gave this an attempt and I am not getting any limit exit orders submitted. (This may be due to a BarsInProgress issue as the exit conditions pull data from an additional timeframe).

I previously was getting exit limit orders when each "exit from" was listed. Should ExitLongLimit work on all open positions(even those labelled)? Any other suggesitons?

Thanks for the Help!

NinjaTrader_Josh
09-18-2007, 01:49 PM
When you don't specify which one I believe it just kills all your open positions and tries to make you flat. Try a market order exit to see if your exit conditions are working. From what you are saying, it is not submitting any orders. Or is it simply not filling you?

Learning1
09-18-2007, 02:02 PM
If I do not specify each position ... i.e. ExitLongLimit(Target,LX1) - it does not submit a limit order.

(I have not yet tried ExitLongLimit(Target,LX1,"")


If I do specify each position ...
ExitLongLimit(Target,LX1);
ExitLongLimit(Target,LX2);
ExitLongLimit(Target,LX3);
It submits an exit order, but only seems to apply that order to the 1st Long Entry (LEa).
If there are LEb and LEc positions open, the ExitLimitOrder does not resubmit. So the exit order seems to only apply to one open position even though all 3 are listed as actions when the condition is triggered.

NinjaTrader_Josh
09-18-2007, 02:17 PM
Do not provide any signal name in your exit. You can see the various forms of syntaxing here http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?ExitLongLimit.

The reason you aren't getting orders is because the way you have it you are giving the limitPrice and then the fromEntrySignal. The problem is you don't have a fromEntrySignal named LX1.

Learning1
09-18-2007, 02:27 PM
Thanks Josh. I think I get it. I'll try ExitLongLimit(Target,LX1,"").
The reason for the LX1 is to ID which exit condition is triggering the order.