Exit Logic For Trade That Doesn't Exist On Chart
Author: kcbars
Creation Date: 12/6/2014 10:45 AM
profile picture

kcbars

#1
I'm testing a strategy for auto-trading. It's a one minute strategy running on approximately 100 symbols, based upon the optimized parameters. I'm baffled because the strategy executed a trade for symbol RCPT, and continued to process exit logic for it until it finally covered. However, when I run the strategy, no trade exists today for that symbol. I can't figure out how it would continue to process the trade all the way through the process when nothing appears in the strategy? Unless it was somehow using parameters different than in the optimized settings? The other trades that have occurred today appear correct. I'm curious if anyone has ever had such an issue, or if I'm doing something wrong? Thanks.

CODE:
Please log in to see this code.
profile picture

Eugene

#2
QUOTE:
However, when I run the strategy, no trade exists today for that symbol


This is usually a sign of a peeking error.

1. You're peeking into the future here:
CODE:
Please log in to see this code.


More details in the WealthScript Programming Guide > Programming Trading Strategies > Peeking > Trading based on Position Active Status.

2. Also, this exit should preface AtStop/AtLimit orders - raise it above them as exemplified in the same chapter of the manual:

CODE:
Please log in to see this code.


3. This may lead to an index out of range exception:
CODE:
Please log in to see this code.
profile picture

Eugene

#3
Consequently, corrected version might look like this:

CODE:
Please log in to see this code.
profile picture

kcbars

#4
Eugene, first thank you for taking the time to redo the code. A couple of questions. On number 1 above, this is intended to be a same bar exit before the rest of the strategy executes. On the new code, it looks like it's going to happen on the next bar. I guess I'm not sure I understand how it would peeking if it's a same bar exit?
On #3, is this why you added the is.intraday & Abort section above? Or how would it be out of range? Thank you.
profile picture

Eugene

#5
Kevin,
QUOTE:
On #3, is this why you added the is.intraday & Abort section above? Or how would it be out of range?

Please disregard that. I misread it as High[p.EntryBar + 3] because using a fixed value didn't make sense to me for it's not adaptive. What a trick of the brain.
QUOTE:
On number 1 above, this is intended to be a same bar exit before the rest of the strategy executes

Sorry, I didn't realize you were doing a same bar exit. In this case, the code looks right. Have you enabled SBE in Preferences > Trading?
profile picture

kcbars

#6
Yes, have enabled it in preferences, and it seems to work well. Thanks for the assistance. I still don't really get why it did what it did in the original question, but I think I'll try running your improved code for a while (I'll change for same bar exit) and see what happens. Thanks.
profile picture

Cone

#7
1. Are you using the Strategy Monitor?

2. Did you start the S. Montor (or streaming) before 0930?

3. At what time, precisely, did the trade occur?

It's always possible that a trade "spike" occurred that was later busted. It happens.
profile picture

kcbars

#8
Yes to numbers 1 and 2. The trade occurred at 9:59. I actually sent a screen shot with the details via a support ticket before posting here if you want to examine. Should I start the strategy monitor before 930? Thanks.
profile picture

Cone

#9
QUOTE:
Should I start the strategy monitor before 930?
Definitely. If you get behind updating 100 symbols for a 1-minute Strategy, it will be difficult (if not impossible) to catch up after the market session has started.

QUOTE:
Unless it was somehow using parameters different than in the optimized settings?
Your suspicion appears to be the cause.
After running a quick test, I've found that the S. Monitor is not applying Preferred Values. I thought I remembered this being on the Open Issues list at one time, but I can't locate the reference to the bug or a fix... we're going to have to call it a new bug :(

You should be able to verify this is the case if you re-run your strategy without PVs enabled... the trade should appear. If it doesn't, try again using the default value in the script.
profile picture

Eugene

#10
QUOTE:
After running a quick test, I've found that the S. Monitor is not applying Preferred Values. I thought I remembered this being on the Open Issues list at one time,

Once there was such a bug in v6.1, fixed in v6.2.34.
profile picture

kcbars

#11
Well, I can't get the trade to appear no matter what I try. So who knows? Maybe just one of those things. But if something similar occurs again I will report. Thanks for all of the help.