I have a strategy which I run against the OEX 100 using Fidelity which causes me a problem. When I test in backtest mode I run in Portfolio Simulation mode and set a priority on trades because often multiple stocks will trigger on any day. For example a recent backtest indicated 337 trades taken 182 missed because of capital limitations. My problem is when I try to run that same strategy daily and use the alerts to post the trades to Fidelity. The strategy seems to run in Fixed positon mode when run daily and gives me alerts for all trades regardless of capital constraints or priorities. I can manually keep up with my captial limits and only take the trades the strategy would have taken using the priorities but since the strategy enters a stop position on every trade, every day after a while it gets very confusing as to which stop alerts are real and need to be placed and which are generated for trades I didn't take because of capital constraints. I've even tried using the Pos Sizer option for Max entries per Day which seems to work in backtesting, but doesn't work correctly in realtime. I guess I could rewrite the strategy to look at every stock in the list daily, store the possible trades in a matrix and then only issue buy statements for those that meet the capital limitations, but this would be a LOT of work.
Is there something I'm missing?
Size:
Color:
QUOTE:
When I test in backtest mode I run in Portfolio Simulation mode and set a priority on trades
What order types does the strategy use? market or limit/stop?
QUOTE:
The strategy ... gives me alerts for all trades regardless of capital constraints or priorities.
That's by design. You should always see all alerts. Depending on your answer above, I can give more guidance.
QUOTE:
every day after a while it gets very confusing as to which stop alerts are real and need to be placed
Understandable. You should follow your strategy's priorities, but if you don't the Portfolio Synch feature is enabled by default on WLPro. That means it won't try to exit a Position you don't own, so you can place all the exit Alerts each day and the ones that don't correspond to live Positions will be discarded automatically without error. Futhermore, Port Synch can match the Position size for exit orders.
Let's answer the first question and take it from there.
Size:
Color:
When I'm entering a new trade it always a market order. When exiting trades I always use two OCO orders one is a profit limit and one is a stop order. I can't use your last suggestion since I'm trading more than one model in the account so the stock may be there from another strategy.
Size:
Color:
QUOTE:
I can't use your last suggestion since I'm trading more than one model in the account so the stock may be there from another strategy.
You should keep Portfolio Synch enabled. That will at least prevent errors for entering orders for Positions that you don't own. Just don't use the "Exit Orders" option so that you don't exit all shares. You have to be consistent to use the same sizing and data starting point (for Portfolio Sim mode) so that your signals stay in synch with the number of shares you actually own.
WLP 4 used "trading baskets". You could assign strategies to trade from a particular basket. I really think this is required for what you're doing. Multi-System backtesting, called "Combination Strategies" is coming next month, and frankly there's no good way to control the allocations for live trading except by using multiple accounts. Baskets may need to come back eventually.
Size:
Color:
Eugene, Cone
Hope I have posted my question to the right thread. I do understand that WLP is a theoretical system vs. actual. I also do understand the portfolio sync feature. There is still an issue that impedes the use of my strategy in a real-time day trading (intra-day) system.
Assume a simple single-position strategy that buys a position and holds it until it sells it at a higher price. When we apply this strategy and auto-stage the orders, if the strategy tries to exit the position and the shares had actually never been bought, the portfolio sync option kicks in and the trade does not get placed. This is fine. But the problem is that WLP, in theory, thinks that it has purchased the position and it will not try to purchase it again, even if the right conditions occur.
This is already happening to me: When I started my strategy this morning at around 1 pm (a few hours after market open), WLP detected a buy at around 11 am and in theory had placed a buy order. After 1 pm, there we a few more buy signals, WLP, however, ignored all of them b/c I am using a single position strategy and it thinks is already has done the purchase. I missed a few buy opportunities after 1 pm. As you can see, Porfolio sync is designed to correct conditions only when exiting, for entering it is powerless.
Do you have any recommendations? Is there any way for intrday trading, when WLP starts, it knows what it actually holds?
-thanks, J
Size:
Color:
QUOTE:
But the problem is that WLP, in theory, thinks that it has purchased the position and it will not try to purchase it again, even if the right conditions occur.
Correct.
Your strategy supposedly was programmed and tested to trade 1 position starting from 9:30. If you need to set initial conditions for when you actually start trading, then you have to program that.
You could, for example, add an exit condition that exits any position at the time your start trading. Pseudo-code:
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
int theTime = IntegerTime from Community.Components;
I think it's
GetTime.
Size:
Color:
Eugene, Cone
Thanks for your feedback. My issue has to do with, I guess, theoretical versus actual trading: WLP thinks that I have performed a trade while in practice the trade was not executed. As a result, WLP might be trying to sell a position while in reality it should be buying it. Let me repeat the example again with slight modifications:
When I started my strategy this morning a few hours after market opened (because I was busy doing other things), WLP had already detected a buy in an earlier hour (before I actually ran my program) and in theory had placed a buy order. After I actually ran my program, there we a few more buy signals, WLP, however, ignored all of them b/c it was thinking it already had done the purchase: it was attempting to exit my position (which I never I had in reality) while I should have been trying to enter a position. I missed a few buy opportunities.
I think I might understand your suggestion: Use the system time when my program starts up and assume orders were actually not placed if the time stamp on a a bar is less than the time when the system was started. If so, I see a couple of issues:
1- My simulations no longer work
2- What if I run WLP, actually do a trade, then WLP crashes, I restart WLP, and now WLP is again out of sync, ignoring the trade.
I think the real solution should be that WLP should know which trades were actually had been done. It is already doing it with Portfolio Sync, but this feature is only applied when exiting positions. If WLP could check the actual portfolio, it could have ignored the buy trade that I mentioned in my example.
Perhaps another solution might be to generate a log report when WLP auto-places a trade. Going back to my example again, it could have realized that the early buy trade was never done because it does not see any log report from auto-place.
I appreciate your comments. My partner who works on this system with me mentioned perhaps I should get up @ 6:30 am to run the program to make sure WLP stays in sync with reality :-)
-best, J
Size:
Color:
QUOTE:
Use the system time when my program starts up and assume orders were actually not placed if the time stamp on a a bar is less than the time when the system was started.
No, that's not it. First, I'm assuming that by "my program" you mean "my script", right? Next, we're not using system time, rather the timestamps of the bars. Finally, what we're doing is making sure that your script exits any hypothetical trades and starts running the entry logic when you start trading.
QUOTE:
, I see a couple of issues:
1- My simulations no longer work
2- What if I run WLP, actually do a trade, then WLP crashes, I restart WLP, and now WLP is again out of sync, ignoring the trade.
1- What do you mean?
2- That's not the case. If Wealth-Lab created a trade that was actually filled, you won't be out of synch. You'll only be out of synch if during the time it took to get everything running again that the theoretical trade had exited. If trading many positions, for sure, this may be difficult to manage, but you'd just bounce your Account Positions against the list of open trades and manually manage the Positions that should have been exited.
I'm curious why you used "WLP crashes" in your example? Are you having trouble with this? Under what conditions?
QUOTE:
I think the real solution should be that WLP should know which trades were actually had been done.
There are pros and cons, and Wealth-Lab has already done it both ways. We are where we are for a reason, and that reason is actually to make it easier for WLP to exit trades that were entered manually.
QUOTE:
generate a log report when WLP auto-places a trade
What about the Orders tool and the Accounts tool Local Trade History log?
QUOTE:
I should get up @ 6:30 am
If you're on the west coast, then you should be up before that to have everything ready to go by 0630. Just go live on the east coast for a month, then it will be easy to wake up at even 0530.
Size:
Color:
Cone,
Thanks for the comments. I just got back from my holidays, let me dig into this issue again and try to understand your suggestions, especially the one on moving to the east coast (:-), I'll get back with you later.
-best, j
Size:
Color:
Cone,
Hi, seems like there has already been a lot of historical debates and perhaps b/c of this I don't quite understand. Let me take another stab at this from a different angle.
1. My script ideally starts when the market opens, but it may not, it may start once the market has already opened, there is not pre-defined start time that I can use.
2. Once the script starts for real trading, it must be in synch with my actual portfolio. If the script in theory thinks that I am holding a position, where in reality I am not, it MUST exit that position in order to be ready for real trading.
3. Once the script starts, if it thinks that I am not holding any position while in reality I am holding a position, somehow I must manually enter the existing position so that it starts off with the right initial conditions.
4. I am thinking of the following design to achieve "2". Once the script starts, if I detect a position, I open up a dialog box to ask the user if this position is valid. If the user says "no", I will exit that. Now I am in sync. The dialog box needs to come only once when the system starts. This is very similar to what you proposed by using the gettime and performing a time analysis. The issue with your solution is that you assumed I start at a particular time where as there is not such predefined start time.
5. To solve "3", once the script starts, if it does not hold any positions, I can ask the user if he needs to enter a position manually. I am not sure about this approach.
I appreciate your comments on the following two questions:
1- What are your thoughts on my approach? Does that work? Am I on the wrong track?
2- Instead of prompting the user and do this manually, I can actually automate my approach ONLY IF I had access to my portfolio. WLP already has capability to download the portfolio. It would be very easily for WLP team to provide functionality to allow a user to iterate through this list. What is the problem with that? Is there a security issue? I do understand that there is reason WLP is where it is, but providing this functionality won't disturb that. Nobody is forced to use this new functionality. Why limit the creativity of end users? Would it be possible to strongly ask the WLP to include this feature in the next release? Allowing a user to gain access to his portfolio is logical, it is easy to implement for WLP, and it allows users freedom to perform more exiting applications.
-best, J
Size:
Color:
You've got the right idea about how things work, the real problem is that you're not trading your strategy "correctly" (i.e., consistently). Anyway, since you want to trade that way, there are solutions for almost everything... but you can't currently get access to the WLP portfolio from a script... call your Fidelity rep about that and request it. Someday they'll come around, maybe.
My suggested approach to your solution would be to create a file that contained a list of symbols for which you hold Positions at the start of the day. You just edit that file before starting. The script reads the list to determine if the symbol running in the script is "Long" at the start of the day. If it is, the script creates a position if required. If not, the script ensures that you're flat. It's just a logic problem.
Size:
Color:
Here's what I come up with... see if you follow the logic -
CODE:
Please log in to see this code.
1. The first run through, nothing happens except to store the datetime of the last bar in global memory. This marks when you first initialized the script for that symbol for the day.
2. Ever ytime
after the first run for each symbol, the script will create a Position on the bar found in #1 if that symbol is in the file.
3. If the symbol is not in the file, then no Position will exist because the script starts processing from the bar on which you initialized it for the day.
Voila.
Size:
Color:
Cone,
Hi, I really appreciate you taking your time to come up with the script, I think I understand your logic. Before I go ahead and modify my code, do you think we have the right approach now? You wrote: "You've got the right idea about how things work, the real problem is that you're not trading your strategy "correctly" (i.e., consistently). Anyway, since you want to trade that way..."
Am I still missing something? With your logic, would we trading the strategy correctly now? What would have been the better approach, if any?
Using bar = startbar + 1 in the for loop, certainly speeds up the processing, any drawbacks?
-thanks, J
Size:
Color:
I'm just suggesting that if you're trading a script that you've backtested, then you should be consistent about trading it.. starting at 0930 everyday and ending at 1600. There should be few cases that the script will be out of synch with live Positions.
Re: startbar + 1 drawbacks
Not any that I can think of unless there's some logic in your script that requires knowledge of past trade history.
Also, just to note that when using this method that involves global memory, you need to restart Wealth-Lab each day to reinitialize it. (Or you could add logic to do that.)
Size:
Color: