The Initialize method is called first. Override this method to instantiate indicators or other objects you will need during your model's processing.
The Execute method is called once for each bar of data in the history. Override this method to implement your model's trading logic. You are passed the current index into the historical data in the idx parameter.
Stolen from Larry Connors Book "Buy The Fear, Sell The Greed – 7 Behavioral Quant Strategies for Traders". Here's a short description:
With VXX the goal is to get short at the proper time, climb aboard as it declines, and stay aboard as long as possible. We also want to exit early if there’s a change in trend because if there is we can safely be in cash. How do we do this? It’s fairly simple: with moving average crossovers. A moving average crossover simply takes two different period moving averages. When the shorter period crosses below the longer period moving average, you go short VXX. When it crosses above its longer-term moving average you exit and go into cash.
The rules are simple for the VXX Trend Strategy and the test results are solid, especially for a trend-following methodology.
I have extend the System with a 15% Stop-Loss. Instead of shortening VXX, you can also go Long on SVXY or ZIV. I prefer VXX because the ETF has enough liquidity.
You will need to Sign In in order to save your Models.
When saving a Model, provide a short and descriptive name that summarizes its spirit.
Also, provide a brief description that explains the logic of your Model, and any other interesting background material you'd like to include.
When you're ready, please Publish your Model so other members of the Quantacula community can review and learn from it.
Remember, in the free membership, you can save only 3 non-published Models. Publish a Model to open up one of your free Model slots. Premium members can save an unlimited number of private Models.
The settings here control what data is used when you backtest your Model, as well as the position sizing. Settings information is saved when you save your Model.
|Maximum Drawdown %|
|Maximum Drawdown Date|
|Interest and Commission||Model||Benchmark|
|Cash Interest Earned|
|Margin Interest Paid|
|Number of Positions|
|Number of NSF Positions (not taken)|
|Average Profit %|
|Average Hold Time (Bars)|
|Number of Winners|
|Winners Avg Profit|
|Winners Avg Profit %|
|Winners Avg Hold Time (Bars)|
|Number of Losers|
|Losers Avg Loss|
|Losers Avg Loss %|
|Losers Avg Hold Time (Bars)|
|Position||Symbol||Quantity||Entry Date||Entry Price||Last Price||Profit||Profit %|
|Position||Symbol||Quantity||Entry Date||Entry Price||Exit Date||Exit Price||Profit||Profit %|