[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question on Multiple ExitLong limit orders placed on the same bar (TS2000i)



PureBytes Links

Trading Reference Links

I'm working in Easy Language for TS2000i.  This is a question about
multiple ExitLongs from specific entries, placed on the same bar.

My Strategy allows for same and different entry signals.  Let's use an
example.

These are my entries:
                                         Total
Date   Type   Contracts   Signal Name   Contracts
3/16   Buy       7         Signal_1         7
3/19   Buy       1         Signal_2         8
4/14   Buy       3         Signal_3        11
4/19   Buy       3         Signal_4        14

Now, I want to scale out of these 14 contracts.  The exits I want are as
follows:
Date    Sig Name           Contracts Sold
4/22      XL-001                2
4/23      XL-002                7
4/26      XL-Final              5  

I am keeping track in an array the number of contracts bought by each
signal.  So when I scale out of this I can set the unitsToSell variable
to the correct number.  I also know how many signals I have used, so I
am able to loop through them all, with this series of "if" statements
within the loop:

If iBuySignalNum = 1 Then
  ExitLong("XL-001") From Entry("Signal_1") iUnitsToSell Shares
        At dExitLongStop Limit
Else If iBuySignalNum = 2 Then
  ExitLong("XL-002") From Entry("Signal_2") iUnitsToSell Shares
        At dExitLongStop Limit
Else If iBuySignalNum = 3 Then
  ExitLong("XL-003") From Entry("Signal_3") iUnitsToSell Shares
        At dExitLongStop Limit
Else If iBuySignalNum = 4 Then
  ExitLong("XL-004") From Entry("Signal_4") iUnitsToSell Shares
        At dExitLongStop Limit
Else If iBuySignalNum = 5 Then
  ExitLong("XL-005") From Entry("Signal_5") iUnitsToSell Shares
        At dExitLongStop Limit
        etc...

I have done a bunch of print statements, and the exitlong orders are
getting placed at the position I expect.  On the 4/23 bar in particular,
I want to exitlong 7 contracts.  So I am setting the following 3
exitlong limit orders:

iUnitsToSell = 5;
ExitLong("XL-001") From Entry("Signal_1") iUnitsToSell Shares
        At dExitLongStop Limit
iUnitsToSell = 1;
ExitLong("XL-002") From Entry("Signal_2") iUnitsToSell Shares
        At dExitLongStop Limit
iUnitsToSell = 1;
ExitLong("XL-003") From Entry("Signal_3") iUnitsToSell Shares
        At dExitLongStop Limit

These orders are set within the context of the above if statements.  I
know they are getting set because I can see the print statements showing
it occur, printing out all the appropriate variables.  However...

It doesn't work the way I expect or desire.

Instead of selling 7 contracts on 4/23, I'm only selling 2.  The XL-002
and XL-003 orders get executed.  The XL-001 does not.  Instead, the
XL-001 does not get executed until the bar after 4/23, which is 4/26.

Is there any limit on the number of exitlong orders that can be executed
in this manner on one bar?  Does anyone have any suggestions for
troubleshooting this?

Thanks much.
Chris