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.
if( CurrentSample >= 100 )
{
// Add to the queue
ValuesQueue.Enqueue( CurrentPrice );
// sum the price
SumAvg = SumAvg + CurrentPrice;
// deduct the oldest element inserted in the queue
decimal dequeue = ValuesQueue.Dequeue();
SumAvg = SumAvg - dequeue;
}
else
{
ValuesQueue.Enqueue( CurrentPrice );
SumAvg = SumAvg + CurrentPrice;
}
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.
public override void OnTick(Dictionary ticks)
{
try
{
/*
* The dictionary have the securities that you select in Initialize() function
* and you can select them using the string of their respective symbol.
* ticks[" Symbol "]
*/
}
catch (Exception err)
{
Error("This is an error handler." + err.Message);
}
}
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.
Dictionary archive = new Dictionary();
public OnTradeBar(Dictionary data) {
archive.Add(data["EURUSD"].Time, data["EURUSD"].Close);
decimal last9min = (from time in archive
where time.Key > Time.AddMinutes(-10) && time.Key < Time.AddMinute(-1)
select time.Values.Close).Average();
decimal floatingAvg = 0.1m * data["EURUSD"].Close + 0.9 * last9min;
//Trim Array length:
archive = (from kvp in archive
where kvp.Key > Time.AddMinutes(-11)
select kvp).ToDictionary();
}
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.
public override void OnTradeBar(Dictionary data) {
/*
* Your Code
*/
}
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.
// Inline method for capturing tick into minute or second bars:
public class Aggregator {
public DateTime Time;
public TimeSpan SpanOfBar;
public string Symbol = "";
public decimal Open = -1;
public decimal High = 0;
public decimal Low = 0;
public decimal Close = 0;
public long Volume = 0;
public int Count = 0;
public Aggregator(DateTime newCandleTime, TimeSpan timeframe, string symbol) {
Time = newCandleTime;
SpanOfBar = timeframe;
Symbol = symbol;
}
public bool HasData {
get {
return (Count > 0);
}
}
//Add the tick, return false if out of time allocation:
public bool AddTick(decimal price, DateTime newTickTime, long size) {
if (newTickTime > (Time + SpanOfBar)) return true;
//Add the data
Count++;
Volume += size;
if (Open == -1) Open = price;
if (price > High || High == 0) High = price;
if (price < Low || Low == 0) Low = price;
Close = price;
return false;
}
//Return the current tradebar:
public TradeBar GetBar() {
return new TradeBar(Time, Symbol, Open, High, Low, Close, Volume);
}
} // End of Aggregator
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.
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.
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.
if (newTickTime > (Time + SpanOfBar)) return true;
if (newTickTime > (Time + SpanOfBar)) return false;
return true;
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.
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!