Hi everyone,
I am new to Quantconnect, I used to code with NinjaTrader that is also in C# but is not exactly the same syntax.
Could you please help me to translate this very basic strategy from NT to QuantConnect ?
if (Close[0] && (Close[0]/Open[0]-1)>-0.01)
{
EnterLong(100, "");
}
if (Close[0]>Open[0]
&& (Close[0]/Open[0]-1)>0.01)
{
EnterShort(100, "");
}
// Exit conditions
if(Position.MarketPosition==MarketPosition.Long
&& GetCurrentAsk() {
ExitLong();
}
if(Position.MarketPosition==MarketPosition.Short
&& GetCurrentAsk()>High[1])
{
ExitShort();
}
Thank you in advance.
Chris
Tadas Talaikis
//before init RollingWindow _window = new RollingWindow(2);
//OnData
_window.Add(data[_symbol]);
if(!_window.IsReady) return;
if(!Portfolio.HoldStock && (_window[0].Close / _window[0].Open-1) > -0.01)
{
Order(_symbol, 100);
}
if(!Portfolio.HoldStock && _window[0].Close > _window[0].Open && (_window[0].Close / _window[0].Open-1) > 0.01)
{
Order(_symbol, -100);
}
// Exit conditions
if(Portfolio[_symbol].IsLong)
{
Liquidate();;
}
if(Portfolio[_symbol].IsShort && _window[0].Close > _window[1].High)
{
Liquidate();
}
Chris D
Tadas Talaikis
Damien Peck
Chris D
Tadas Talaikis
Stefano Raggi
// in Initialize AddSecurity(SecurityType.Forex, symbol, Resolution.Tick) var consolidator = new TickConsolidator(TimeSpan.FromMinutes(5)) consolidator.DataConsolidated += (sender, consolidated) => { // entry logic on bar close } // in OnData(Ticks) { // exit logic on each tick }
Michael Handschuh
Michael Mehrle
Chris D
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!