Back

EMA plots different than mainstream broker

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,

Update Backtest








see image enclosed

0

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:

  1. Set an earlier StartDate and in OnFifteenMinuteData handler, check whether all indicators are ready before use them to make trading decisions://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 */
    }
  2. 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.

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.


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.

0


And I move the date to 1,1,2016, which should be more sufficient, no? Thanks again

0

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.

 

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.


Thanks for the reply.  If this were to go live, what do I get?  Would it be consistent? 

0

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.

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.


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