Hello,
I'd like to know if it's possible (and how) to backtest a strategy I have found that requires:
1) To set the daily bar close to a certain GMT+NN time zone. NN is a number that is not any of NY close, London open and so on. It's just a very custom number.
2) Create buy/sell stop orders 3 pips above a certain bar pattern depending on the daily bar close price (point 1).
Thanks in advance
Damien Peck
int desiredZone = 0; var myTime = Time.AddHours(desiredZone + 5); if (myTime.TimeOfDay.TotalHours > 14.5) // 13:30 is market open in GMT.
Your second question yes its possible; the stop orders can be issued with StopMarketOrder(string symbol, int quantity, decimal stopPrice, string tag = "")Dario Fumagalli
Damien Peck
class CustomConsolidator : DataConsolidator
{
private TradeBar _consolidatedBar;
public override Type OutputType
{
get { return typeof (TradeBar); }
}
public override void Update(TradeBar data)
{
if (data.Time.TimeOfDay.TotalHours > 14)
{
OnDataConsolidated(_consolidatedBar);
_consolidatedBar = new TradeBar()
{
Time = data.Time
};
}
else
{
_consolidatedBar.Update(_consolidatedBar.Close, _consolidatedBar.Close, _consolidatedBar.Close, _consolidatedBar.Volume);
}
}
}
var custom = new CustomConsolidator();
custom.DataConsolidated += (sender, consolidated) =>
{
// Handle your bar.
};
SubscriptionManager.AddConsolidator("EURUSD", custom);
Dario Fumagalli
Damien Peck
Dario Fumagalli
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!