Back

Operator < cannot be used with Quotebar

Hi,

Getting the above error in my code, in the "if portfolio is not invested" line. any idea how i can solve it?

using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

namespace QuantConnect.Algorithm.CSharp
{
public class TachyonOptimizedChamber : QCAlgorithm
{
public RollingWindow<QuoteBar> Open;
public RollingWindow<QuoteBar> Close;
public RollingWindow<QuoteBar> High;
public RollingWindow<QuoteBar> Low;

public override void Initialize()
{
SetStartDate(2018, 12, 10); //Set Start Date
SetCash(100000); //Set Strategy Cash

var forex = AddForex("EURUSD", Resolution.Hour, Market.Oanda);
//var forex2 = AddForex("AUDUSD", Resolution.Hour, Market.Oanda);
//var forex3 = AddForex("NZDUSD", Resolution.Hour, Market.Oanda);
SetBrokerageModel(BrokerageName.OandaBrokerage);

// AddEquity("SPY", Resolution.Minute);
Open = new RollingWindow<QuoteBar>(8);
Low = new RollingWindow<QuoteBar>(8);
High = new RollingWindow<QuoteBar>(8);
Close = new RollingWindow<QuoteBar>(8);


}

/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// Slice object keyed by symbol containing the stock data
public override void OnData(Slice data)
{
Open.Add(data["EURUSD"].Open);
Low.Add(data["EURUSD"].Low);
High.Add(data["EURUSD"].High);
Close.Add(data["EURUSD"].Close);

var OneBarAgoOpen = Open[1];
var TwoBarAgoOpen = Open[2];

//var currentTick = tickWindow[0].AskPrice;
//var lastTick = tickWindow[1].AskPrice;

if(!Portfolio.Invested && OneBarAgoOpen < TwoBarAgoOpen)
{

}
// if (!Portfolio.Invested)QuoteBar
// {
// SetHoldings(_spy, 1);
// Debug("Purchased Stock");
//}
}

}
}

 

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.


Instead of RollingWindow<QuoteBar>, try RollingWindow<decimal> in the code above. The issue is a quotebar consists of Open, High, Low, Close etc. whereas you're taking out these numbers individually when putting them into the rolling window.

0

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