Simultaneous sell and buy signals
Author: mikesblack
Creation Date: 7/26/2012 9:48 PM
profile picture

mikesblack

#1
When I have a sell signal on a day for Bar+1 "Exit At Market", my system won't produce a buy signal for that day, considering I have ( Active Positions.Count <2)for each condition for buys, more than 2.

Given that, the following day will signal an open trade for an issue I was unaware was being signaled the day prior considering the system was "thinking" that the next days sells wasn't putting "active positions to 0 or less than 2 for buying purposes.

What can I do to allow for 2 or less open positions, given a sell signal would open up an opportunity to purchase new signals? In other words, can I allow for a sell signal( "sell at market") to allow for buying opportunities that I need to show?

Sorry if my question seems awkward, and please let me know if I should rephrase.
profile picture

Eugene

#2
Probably we could live without rephrasing if you can show the code ("as-small-as-possible") that demonstrates that behavior.
profile picture

mikesblack

#3
Believe the matter is buy and sell orders for next bar gets confused as the system won't give a new buy signal, (assuming conditions for buy is there) since it hadn't sold the 2 positions for that next day( only 2 active positions allowed). It is only the next bar will that buy order show up for that day. Future reports will show that I should have had the position, but by then it is too late.



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

Eugene

#4
Kindly let me remind that...
QUOTE:
· It's usually a mistake to use LastPosition logic (especially IsLastPositionActive) in MP Strategies. You can unwittingly close the last Position, leaving Positions that were opened earlier unprocessed.

As advised in the WealthScript Programming Guide, Programming Trading Strategies > Multi-Position Strategies, I'd eliminate this remnant first.
profile picture

mikesblack

#5
Thanks Eugene. Changed the code as per the manual and so it works.
profile picture

Eugene

#6
Glad to help Mike.
profile picture

mikesblack

#7
I am still experiencing the same issue for both multi and single symbol back tests: E.g.Active positions<2, 2 open positions are in portfolio, Sell and buys are at market, Sell rule is generated when I should also get a buy signal. As it is a sell signal will not open up for a new active position on that day. Result is: Next trading day, after collecting new data, I show a new position, despite not getting a signal for it.
CODE:
Please log in to see this code.
and
CODE:
Please log in to see this code.
profile picture

Eugene

#8
I didn't see anything suspicious here. The problem might be elsewhere (i.e. what's left behind).
profile picture

mikesblack

#9
Today, I have one less open position for EDMC than the system shows for open positions. I did not receive a buy signal for EDMC yesterday when I should have. For clarity, I did a single position test with EDMC for today and for yesterday. Same thing. Seems when there are 2 active positions as there was, and a sell signal prevents that buy signal for the next bar, the system won't produce a new buy signal ; however after the sell, the next day, shows that I should have had a buy signal( one more position than I had).
In essence: Two open positions, a sell signal and a buy signal at the same bar that should happen does not for that day when there are 2 actives. It's only the next bar do I find out I needed to buy.
What should I do?
profile picture

Cone

#10
Have you tried in Raw Profit mode? What sizing are you using?

You should test a time-based exit before other types. They're both AtMarket exits, so I don't expect it will change anything but since the code is incomplete you never know.
profile picture

mikesblack

#11
Hi Cone, Sizing 6 percent and Raw profit both are producing this error. I'll try time based exit and let you know. My exit consists of many else statements and so I wonder if this may be the issue? I'll start with that. Thanks
profile picture

mikesblack

#12
Additionally, if you can think of what or why I am getting this outcome could you suggest possibilities.
profile picture

mikesblack

#13
Sorry fellas, but I am stuck. First, do you understand what is happening? Have I described what is happening clearly enough? As it is, I could use Your help , please!
profile picture

mikesblack

#14
QUOTE:
Place exit logic above entry trading rules to prevent the exit logic from being applied to Positions that are opened on the very same bar.
This seems to explain what I am trying to work around. Exit logic then entry. Sorry to be repetitive, limit on open positions to 2 or less and yet a sell signal for the next bar will not allow for a concurrent buy( which I want)if 2 positions remain open. Only later after the day later, I then show that a buy was triggered. (after the fact)
profile picture

Eugene

#15
Help us help you Mike: provide the complete code demonstrating the effect together with the enviornment (we seem to have the position sizing but what are the symbols, bar scale, data loading range?)
profile picture

mikesblack

#16
Daily, symbols( one position or multiple positions)Data range (any; I can tell 500 bars or select dates)Will provide code ASAP; however can I send privately as a ticket? Thanks Eugene.
profile picture

Eugene

#17
Please provide an "as-small-as-possible" code skeleton (that doesn't depend on 3rd party libraries) to demonstrate the anomaly.
profile picture

mikesblack

#18
sorry,working with what I got. A loyal and long term customer, not a hacker or devious user that needs a lead. Prhaps a you can extend some, but not gret deal o effort to get this user on track. Is this reasonable ?
profile picture

Eugene

#19
Sure, it's reasonable to show you a functioning example. Let's completely forget about your purchased code with the DLL, leaving its support/enhancements to its respectable creator, and start from scratch.

Please restate your first question as clear as possible, i.e. what you want to get in the end, and we'll try to come up with something.
profile picture

mikesblack

#20
Thanks Eugene. I'll put my mind to it and return.
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).