Back

Triple Moving Average Cross

Derived straight from the moving average basic example, except a third moving average is added to tighten the sell rule. 20 bull crossover 100 = buy. 20 bear crossover 50 = sell. Performed on QQQ.

Does anyone have code that uses ATR as a sell rule?
Update Backtest








Welcome to QC Drake! Did you mean to post an algorithm? I'd suggest posting your attempt before asking for help would get better responses :). In the university "How to use Indicators" we post an example of how to create an ATR indicator
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Drake I have an algo here that uses ATR for position sizing, and the min/max indicators for buying and selling. Hope this example helps.
0


Thanks for the help. Yesterday was my first attempt at C#
0

Rueben, the Clenow system is exactly what I was looking for. I'm kinda surprised it didn't do better. He's coming out with a new stocks book and I get the feeling it is going to be similar to Antonacci's Dual Momentum Investing just like his futures system is very similar to the Turtle system.
0

Drake, while I used the indicators and trade logic from his book, my backtest has a couple of significant differences. For one, I am using an ETF, not futures (once I figure out how to use Quandl for futures, I hope to remedy that). Secondly, and this is the big difference, I am only using one market; Clenow's strategies were all predicated on being diversified across many markets, 10-50+. The SPY-only strategy is really more of a test of my ability to use the QuantConnect platform (although, like you, i was surprised it did not do better, regardless of all of that).
0

Funny you mention Dual Momentum, that was exactly what I was working on today. My results don't seem to be quite as good as what were published, and i'm not 100% sure why. Some of it may have to do with the SetHoldings method and leverage (whenever i use 100% my backtest has runtime errors and margin calls, still trying to understand how that affects backtest validity, and how that's possible for a long-only strategy that never approaches zero. I'm missing something). When I get around to it, I'll try to find some long-term daily data in a csv file and go back further.
1


@Reuben, @Drake, cool strategies thanks for sharing. Perhaps we can get it closer to what you're expecting :)

Please see "How Do I Import Futures Data?" for the Quandl futures example. We get 100 accesses per day I think, you might need to use your own Quandl access token with the line "Quandl.SetAuthToken()" in the initialize.

Margin calls are modeled after IB -- if you're levered and even go slightly into negative, they'll liquidate part of your account to bring you back to 0. This means you'll get frequent margin calls if you're using all your margin allowance. e.g.

-> $100 cash -> 2x leverage -> Buy $200 Stock (Margin Free: $0) -> 10% dip in market -> New Value $180 (Margin Free: -$20) -> Margin Call $20.

You shouldn't get any calls if you don't use leverage. Default equities leverage is 2x, and FX is 50x. You may want to override this to 0 to avoid margin calls. Securities["SPY"].SetLeverage(1) -- this would allow calling SetHoldings(1) without fear of margin calls. SetHoldings(1); means set to 100% of total "buying power" which includes leverage.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi guys,

The new book is just out. I'm taking a little different tack than Gary since I'm coming from a bit different background. Of course, as you rightly point out, strategies usually tend to be a bit similar. There's not a whole lot of ways to capture trends or momentum and there will always be a high correlation between strategies.

The important thing is to identify the critical components and focus on what matters. The broad strokes are usually the same, but the devil tends to be in the details.

Andreas
2

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed