Hi. I have a simple snippet code that simply shorts NLY when the 5 SMA is below the 15 SMA. I tried to add a feature that also buys an equal dollar amount of SPY as a hedge when the NLY trades are made. The orders no longer make any sense after adding the modifications. Can anyone see where i went wrong? The moving averages are intended to operate on NLY not SPY. This code is intended to operate on daily close data.
Thanks in advance for any advice.
Rob
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
The moving averages are intended to operate on NLY not SPY.
The moving averages will operate on the clicked symbol, whatever it was - NLY, SPY or GOOG. If you intended to hardcode the DataSeries to operate on NLY, make sure you wrap the code in a SetContext/RestoreContext block.
Size:
Color:
I use the code on a symbol as I always have (i.e., the clicked symbol)
My problem is that i never get consistent trades as I did before adding the SPY short. Did I add the second symbol correctly?
I will add the SetContext/RestoreContext block.
Rob
Size:
Color:
What does it mean "consistent", what did it mean "no longer make any sense"? Be precise. What you showed above is a slightly modified code of the "Pairs Trading" strategy. How are executing the Strategy (all settings, backtest mode) and how does that inconsistency can be reproduced exactly?
Size:
Color:
It ended up being a simple setup problem with the portfolio capital.
Thanks
Size:
Color: