for a given stock, what's the best way to tell inside onData, if that ticker price at the moment is the highest price for the day so far?
QUANTCONNECT COMMUNITY
for a given stock, what's the best way to tell inside onData, if that ticker price at the moment is the highest price for the day so far?
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.
SherpaTrader
public void OnData(TradeBars data) { foreach (TradeBar bar in data.Values) { if (Portfolio.Cash < minimumPurchase) { break; } if (!Portfolio[bar.Symbol].HoldStock) { if (bar.High== bar.Close) { // reached the highest for the day } } } }
i think this is how to do it, can anyone confirm?
Shile Wen
Hi SherpaTrader,
This thread provides a great example of how to get the high of the day. Please note you'd probably want to set some threshold for the comparison because the Close of a bar may not be guaranteed to be also the high.
Best,
Shile Wen
SherpaTrader
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!