It seems to me the EMA plots different than some broker say Schwab. See picture. I set the same as 15m bar for 5 and 10 EMA cross over. The project was cloned to run this test. The highlighted from the picture is where trades were executed, however the EMA didn't cross. Anyone please help! Many thanks,
H Huxley Li
see image enclosed
Alexandre Catarino
In this algorithm, the trading signals depend on the EMA cross and three daily indicators (RSI, MACD and Momentum). Since the start and end date are set to have the difference of only one day, the daily indicators will not be ready (in other words, there is not sufficient data to calculate them).
There are two options to fix this:
//In Initialize, e.g.: SetStartDate(2016, 10, 1); public void OnFifteenMinuteData( object sender, TradeBar bar) { // update our indicators Fast.Update(Time, bar.Open); Slow.Update(Time, bar.Close); var isReady = Fast.IsReady && Slow.IsReady && DailyMacd.IsReady && DailyRSI.IsReady && DailyMomentum.IsReady; if(!isReady) return; /* Continue with trading logic */ }
Set warmup with the number of days we need to get the indicators ready (please checkout the docs under the Warming Your Algorithm subsection:
// In Initialize // Warm up 30 days of data. SetWarmup(TimeSpan.FromDays(30));
We should not use the first option for live algorithms, since it would take several days for a deployed algorithm to make its first trade.
H Huxley Li
Thanks for the reply. I adjusted the RSI to minute instead of daily, it still doesn't execute properly. It always moves three bars back from the screenshot enclosed.
H Huxley Li
And I move the date to 1,1,2016, which should be more sufficient, no? Thanks again
Alexandre Catarino
It impossible to ready the values from those images.
You need to compare the input (price data) and output (indicator values) information from both platforms to find the origin of those trading signals difference.
H Huxley Li
Thanks for the reply. If this were to go live, what do I get? Would it be consistent?
Alexandre Catarino
In live mode, we get the same behavior, since the indicator computation does not depend on the mode (live/backtesting). In other words, yes, the indicator outputs would be consistent.
H Huxley Li
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!