Good afternoon all,
I'm interested in switching back and forth between two ETFs with Wealth Pro 5.6. The first ETF is the primary, and the second ETF is the inverse. I'm trying to set up Wealth Pro to buy and sell with a trailing stop loss (dollar) and then buy the inverse ETF to follow the same algorithm until swithing back to the primary ETF when the market goes up. Ideally the alogrithm would continue indefinitely until turned off manually.
Thanks,
Mike Mosley
Size:
Color:
Hi Mike,
Not exactly understood. Do you just switch from one ETF to another but the entry/exit condition stays the same?
Size:
Color:
Hi Eugene,
The primary ETF would ideally be bought with an intraday market order (86% margin equity) and then go up or down with the market. Once the trailing stop loss (dollar amount) would be reached, then the primary ETF would be sold (ideally indicating a downward market movement). The inverse ETF would be purchased to try to capitalize on the downward movement until the market moved up (hitting the inverse ETF's trailing stop loss dollar parameter). At that time, the inverse ETF would be sold and a market order would be placed to purchase the primary ETF on hopefully an upward movement....Riding (capitalizing on) the intraday ups and downs.
Methods: Intraday market orders for purchase & trailing stop loss for selling based on dollar amounts. 86% of margin equity used on purchases. Indefinite alogorithm loop/process to follow the ups and downs.
Any help is appreciated!
Thanks,
Mike Mosley
Size:
Color:
This makes things clear. Since there's no primary entry condition, let's assume that Wealth-Lab buys the primary ETF on the first bar.
Here you go. This Strategy trades the DIA/DOG pair (could be modified), shows a chart of inverse ETF below and draws trade arrows on the chart:
CODE:
Please log in to see this code.
Size:
Color:
Wow thanks Eugene!
Since the primary & inverse ETFs interact with each other on a percentage basis (not dollar basis), I changed the above code from a trailing stop loss ($) to a trailing stop loss (%).
Here's what I substituted in.
// Trailing stop %
double high = p.MFEAsOfBar(bar) / p.Shares + p.EntryPrice;
double amount = high - high * (1.50 / 100.0d);
Question 1)
Is it normal under the trade tab to have duplicates of each trade? i.e.,
DIA xxx shares
DIA xxx shares
DOG yyy shares
DOG yyy shares
DIA zzz shares
DIA zzz shares
Thanks again!
Leeroy
Size:
Color:
QUOTE:
on a percentage basis (not dollar basis),
...yet the topic name says: "trailing stop loss (
dollar)" ;)
QUOTE:
Is it normal under the trade tab to have duplicates of each trade? i.e.,
No, you're probably trying to run it in Multi-Symbol Mode. Don't do that. Run this strategy on a single symbol, clicking on the primary ETF i.e. DIA. Like other "Symbol Rotation" and "Pairs Trading" strategies, it should be run in Single Symbol Mode (though it's OK to apply Portfolio Simulation mode to it.)
Size:
Color:
Thanks Eugene, is there a way to adjust the default commission trade fee? I think it's at $16 a trade.
Size:
Color:
It's the commission structure at Fidelity. Preferences > Commissions.
Size:
Color:
It's strange, the preference says $8, but when I go to the performance tab and divide the Total Commission by Number of Trades, it comes out to $16 a trade?
Size:
Color:
A bit strange to hear that a Fidelity customer doesn't know their commission structure?
$16 per roundtrip, i.e. $8 per trade.
Size:
Color:
So Number of Trades under the performance tab actually means number of roundtrips?
When I run the program in the simulation mode with simulated capital at a %100 equity and 1 to 1 margin, the program says I eventually don't have sufficient funds for all the trades. Is this because the strategy loses all the simulated capital, or is it a margin/equity issue? When I run it in the raw profit mode, it shows positive gains.
Thanks again Eugene for the information!
Size:
Color:
Wealth-Lab User Guide > Strategy Window > Backtesting Strategies > 100% of Equity Sizing.
Size:
Color:
Good morning,
I've had no problems back testing it, but when I try real time with a paper account, it tries selling even though it hasn't purchased anything yet....Then repeats the sell alert over and over again naturally in the strategy monitor. I've purchased manually but then it sells...No buy/sell process loop for some reason like during the back testing.
Size:
Color:
Just because you launched the strategy in Strategy Monitor doesn't mean it has to start fresh each time. There's a lookback period, and your rules are programmed to buy immediately, so it did purchase something already. So, this exit signal is generated for a theoretical position that was created in the past.
Size:
Color:
Is there a systematic way to start fresh or erase the lookback period?
It also appears to be generating the same alert twice (Sell DOG, Sell DOG) at a time (but normally assocated with the inverse ETF).
I've tried to trick it my mimicking the previous lookback period, but it still wants to sell over and over.
Size:
Color:
...But it runs perfectly in back testing.
Size:
Color:
The strategy seems to run fine in the Strategy Monitor when the scale is set to daily; however, it seems to generate the above problems when the scale is set to 1 minute, which unfortunately I need.
In the Strategy Monitor when I set the scale to 1 minute, under the Action column it says Updating stock symbol, but the Updating never goes away.
Any information is appreciated.
Size:
Color:
1-minute is a lot of data. Have you already disabled on demand data update in the Data Manager and manually updated the DataSet with DIA/DOG (or whatever pair you specified)?
Size:
Color:
Oops. The code contains an error; it's peeking into the future (can't sell at stop ETF1 and buy at open ETF2).
Let me fix it and get back to you.
Size:
Color:
Thanks Eugene, I appreciate your time with this algorithm!
I tried varying the daily scale over several days in Strategy Monitor, and it ran into problems depending on the day (like you said, the history data sets up a backlook period). The minutes scale will either say updating continuously, or all updates returned, or sometimes I'm successful with the run strategy now right click, but it will try selling the inverse ETF twice even though nothing was purchased in the first place (the sell inverse ETF twice happened yesterday during the real time market). I disabled on demand data update in the Data Manager and manually updated the DataSet
Size:
Color:
Re: peeking error in old code. It's impossible to determine at which price inside the
same bar to buy another ETF, when a position is closed by triggered trailing stop. With intraday data, it's not much of a problem since the time difference between the bar when one position is exited and another opened is just 1 intraday bar. This is not the case with daily bars, where the delay is likely to result in reduced profitability. The code mistakenly tried to purchase another ETF on the open of the bar where trailing stop triggered - it has been fixed.
Try this one. Create a DataSet with these symbols: DIA DOG PSQ QID QLD QQQQ SH SPY UOPIX USPIX and update it. Several primary/inverse ETF pairs are predefined (e.eg. DIA/DOG, QID/QLD etc.), to change them edit the "
pair" function. Run the code on a pair symbol with the shortest history. The paired symbol will be chosen automatically. Also added ability to choose between point-based and percentage-based (default) trailing stop.
CODE:
Please log in to see this code.
Size:
Color:
Thanks Eugene! You're much smarter than I am! If possible, I'm just trying to trade a single pair (DIA, DOG) like in the orginal program only using trailing stop loss (%), but corrected for the peeking into the future problem. The 27 Jan program tested perfectly in the back testing but just had the real time problem.
I altered the above program, but now the back testing doesn't yield the same positive results.
CODE:
Please log in to see this code.
Size:
Color:
At least on daily data, the backtest should not yield the same positive results any more because they were mainly caused by the peeking error. As said above, my code #1 was mistakenly buying the 2nd "leg" of the pair on the open of the bar where the 1st "leg" exited on a stop. This is impossible w/o a crystal ball.
Size:
Color:
With any of the above programs, when I tried varying the daily scale over several days in Strategy Monitor, they ran into problems depending on the day (like you said, the history data sets up a backlook period). The minutes scale will either say updating continuously, or all updates returned, or sometimes I'm successful with the run strategy now right click, but it will try selling the inverse ETF twice even though nothing was purchased in the first place (the sell inverse ETF twice happened on Fri during the real time market). I disabled on demand data update in the Data Manager and manually updated the DataSet. Am I not using Strategy Monitor correctly?
Is it possible to create a program that doesn't need history data...Just looks at the current market and the current position held in the account to start the process?
I'm not sure the peeking error was the problem as I'm still running into the same problems....
Size:
Color:
Any thoughts....?
Size:
Color:
I don't detect a question in the first paragraph except at the end, and, if the question is "do I need to use data on-demand for the Strategy Monitor", the answer is no. The S. Monitor will always attempt to fill the history when it executes. You should never, however, select "All Data" in the Strategy Activation settings for intraday scales. If you do, and you've haven't collected the data ever, then it can take several minutes to download the data for just a single symbol.
QUOTE:
Is it possible to create a program that doesn't need history data...
Sure, here it is -
CODE:
Please log in to see this code.
If you don't want to use historical data, what is your basis for technical analysis and decision making?
Size:
Color:
Question 1) Why don't the above programs work and only get these strategy monitor errors: updating continuously, updates returned, or sometimes I'm successful with the run strategy now right click, but it will try selling the inverse ETF twice (like during real time in the market)?
Overall Goal:
Question 2) Can you help me with my ETF (Primary/Inverse) program? The retardedness of the strategy does not require historical data (and hopefully this will make things easier from the above error problems). It only looks at the current market and current ETF position held. If the trailing stop loss (%) threshold is met, it sells all shares and then instantly buys the inverse ETF until the (%) threshold is met, then sells all shares and repeats the process with the primary....Indefinite process. Linear iteration/ surface area maximization.
Size:
Color:
QUOTE:
Why don't the above programs work
The above strategy #2 works (forget about #1 - it's flawed and will show inflated/unrealistic results on Daily data), but your question is uninformative.
See here for
How to report a Problem? Basically, we're looking for:
# how do you run it - in single symbol mode or in portfolio backtest mode? (see the User Guide for a definition)
# Position Sizing Control and Data Loading Control settings
# Symbol(s)
Size:
Color:
Since the symbols (DIA/DOG) are already in the programming. I only select DIA from the data set DIA & DOG. Scale: minutes. Data Range: Recent Week. Position size, 50% equity for 200,000. 2 symbols are in the dataset (DIA & DOG).
Size:
Color:
I run it in single symbol mode (selecting DIA in the DIA/DOG data set/ folder).
Size:
Color:
Any thoughts?
Size:
Color:
No thoughts so far.
Pardon my sluggishness. Currently, I'm half-way through updating Strategies.ActiveTrader, Community Indicators/Components/Visualizers/ScoreCard for the upcoming 2010.02 release. When it's finished, it will probably be our PosSizer library's turn to be packed with more money management stuff.
In Strategy window using daily data, the code works for me. If you can explain what "Updating continuously" and "updates returned" means, maybe we'll have more hints. btw, try a different data scale in Strategy Monitor e.g. 60-min or Daily - does the error persist?
Size:
Color:
Wow, the 2010.02 release sounds impressive!
The program seems to handle a lot better outside of the minutes scale, thanks again for all your help!!
Size:
Color: