Shorts Not Covering
Author: sdbens20
Creation Date: 10/24/2011 9:56 PM
profile picture

sdbens20

#1
I have a trading system that I want to use to go long and short. The intent is to have only one position in a stock (long or short or out) at a time. The problem is that longs open and close as intended but shorts frequently fail to cover(close) when the rules are met. More than half of the shorts do not cover.

The system's code shown below was created from rules by WLP.

CODE:
Please log in to see this code.


All parameters have unique names. Can you see why many shorts are failing to close?

Thanks,

Sherm

profile picture

Eugene

#2
Here the code closes all shorts gracefully. Specifying a particular scenario (symbols, bar scale etc.) might clear things up.
profile picture

sdbens20

#3
Eugene,

Scale: Daily
Data Range: 1 Year
Position Size: $100,000 (RP)
Symbol: .DJI

Optimization Parameters:
http://imageshack.us/photo/my-images/832/optimizationparameters.jpg/
Note: Last parameter not included.

Partial Results:
http://imageshack.us/photo/my-images/850/partialresults.png/
Note: Last 7 trades not shown.

I'm using Windows 7 Pro, 64-bit, on an i7 computer. WLP is Version 6.2.34.0, 64-bit Edition.

Please let me know if there more information needed.

Thanks,

Sherm
profile picture

Eugene

#4
I don't have the .DJI but on ^DJI, no single trade since 1990 was left without covering using the default strategy parameters (not sure what do you mean by "Last parameter not included").
profile picture

Cone

#5
I have .DJI, but I can't duplicate it either with the default parameters.

After looking at your results, I'm confident that you have not provided us with the strategy that you're testing. The strategy in your initial post only allows for a single open Position, so it's impossible to have open short positions while trading other active positions.

At some point you must have clicked on "Multiple open positions Allowed" in the Strategy Builder, and that may have the effect that you describe due to your programmed logic.
profile picture

sdbens20

#6
Cone,

If at some point, I clicked on "Multiple open positions Allowed" but then clicked on "Single Open Position" and re-ran the strategy, would the "Multiple open positions Allowed" still be in effect?

I just ran the strategy below in its "Rules" form using default parameters.
http://imageshack.us/photo/my-images/62/rules102511.jpg/

Please note that "Single Open Position" is selected.

I then ran and optimized the parameters per the two screen shots below:

http://imageshack.us/photo/my-images/607/optctrlscreen110251.jpg/
http://imageshack.us/photo/my-images/339/optctrlscreen2102511.png/

Note: the second screen shot shows the last parameter being optimized. It did not appear in the first Optimization Control picture because the Strategy Parameters window is too small.

The next next picture shows a partial list of results, highest Net Profit first.

http://imageshack.us/photo/my-images/7/partialresultsmostprofi.jpg/

This last screen shot shows trades generated by the highest Net Profit result. Please note all the open short trades.

http://imageshack.us/photo/my-images/100/trades1102511.jpg/

There were a total of 85 trades. 2 short trades opened and closed. 26 shorts opened but did not close.

Can you see why I am getting this impossible outcome?

Thanks,

Sherm
profile picture

Cone

#7
No, I can't see why. It's impossible with the code that you posted. Try repeating the procedure with that.

Separately, please create a support ticket and attach the xml Strategy file so I can take a look from that angle.
profile picture

sdbens20

#8
1) The problem of unclosed shorts appears in optimized runs of the both the rules and code versions of the strategy. In making your declarations of "impossibility", have you been basing you review of results of optimization runs? If not, please do so.
2) Please clarify, repeat what procedure?
3) Did you look at the 5 images I sent you?
4) You mentioned "It's impossible with the code that you posted." I can assure you that the code posted on 10/24/2011 at 9:56 PM and the rules I posted 10/26/2011 at 9:37 PM do produce unclosed short trades in optimization runs.
5) What is a xml Strategy file and how is it created?
profile picture

Eugene

#9
An "else" separating the long entry from the short one solves the problem. Furthermore, I think that the previous version of the code wasn't up to your expectations.
CODE:
Please log in to see this code.
profile picture

Cone

#10
Admittedly I was wrong about the impossible - the way the wizard code produces entry signals allows multiple positions to be created on the same bar. When you mix LastPosition logic with multiple positions, it just doesn't work.

The positions on the same-bar issue is actually a wizard deficiency that we've highlighted in the past, but I've got too short a memory - sorry about that.

---
I just want to add that I would have been able to duplicate the problem when I ran the code if all the details were provided, in this case, especially the Data Loading configuration and parameter values.
profile picture

Eugene

#11
Robert, to duplicate the problem see the optimized parameter screenshot -- the line on top (22,82,1,0,102,82,2,31,60,82).
profile picture

Cone

#12
Not required now.
profile picture

sdbens20

#13
Cone,

Seems like my 10/25, 9:35 PM post should have provided enough information to address your "I just want to add that I would have been able to duplicate the problem when I ran the code if all the details were provided, in this case, especially the Data Loading configuration and parameter values." comment. Maybe paying more attention to the information provided would have tempered your "After looking at your results, I'm confident that you have not provided us with the strategy that you're testing. The strategy in your initial post only allows for a single open Position, so it's impossible to have open short positions while trading other active positions." feedback.

An improvement in the tone of your responses would be appropriate and appreciated.
profile picture

Cone

#14
I've been wrong before, and I'll be wrong again. However, the images in that post don't show the parameters used, and the problem doesn't occur with 1 year of data using the default parameters.

Anyway, I'm sorry for my misplaced confidence.
profile picture

sdbens20

#15
Any plans to fix the wizard deficiency?

Thank you for the corrected code.
profile picture

Cone

#16
There are plenty of deficiencies to choose from, but this one didn't get picked up for 6.3. It's actually pretty rare that someone runs into it, and it's pretty easy to fix by a light edit. The Strategy Builder will always have it's limitations, but I'd agree that something that can be done with it should work correctly.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).