Back

Developing strategy to trade on 30min bar

my strategy is simple, just check if the 30min bar closing price is above or below both the short and long MA and enter trade accordingly. After the backtest I realize there are two problem:

1) From the backtest log, I see that the trades are not entered on 00min or 30min. So I wonder I have set this up correctly.

2) The backtest stopped since Nov 7, but my backtest test is setup to run to current time.

Thanks everyone for your help.

Update Backtest








In your algorithm, the logics resides on OnData event handler that fires every minute. There, we are comparing the price thar changes every minute against the indicators that change every 30 minutes, if the conditions are met, a trade is placed.
In order to fix that, we need to move the logics into a event handler that fires every 30 minutes. Please checkout the attached project.

By default, forex data comes from FXCM. It is outdated, but we are working on updating it this week. Please use Oanda data instead:

Symbol symbol = QuantConnect.Symbol
.Create("USDJPY", SecurityType.Forex, Market.Oanda);
AddForex(symbol, Resolution.Minute);

 

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.


Please use this pattern for selecting the market:

var forex = AddForex("USDJPY", Resolution.Minute, Market.Oanda);
symbol = forex.Symbol;

instead of Symbol.Create method, since it can create the wrong Symbol object for securities with complex mappings. It is not the case for forex, but we should prefer patterns that are safer across all security types.

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