Hi All,
Hoping someone can help me out here.
I'm trying to change my Buy/Sell symbols on a plot to Trianlg e and TriangleDown, but can't find how to implememnt the option.
Currently, my code looks like this:
Chart plotter = new Chart("EMA:" + Symbol);
plotter.AddSeries(new Series(Symbol, SeriesType.Line, index:0));
plotter.AddSeries(new Series("Buy", SeriesType.Scatter, index:0));
plotter.AddSeries(new Series("Sell", SeriesType.Scatter, index:0));
Where/how do I add the
ScatterMarkerSymbol.Triangle
Thanks
Alexandre Catarino
In order to control the market, we need to use the following constructor overload:
public Series( string name, SeriesType type, string unit, Color color, ScatterMarkerSymbol symbol = ScatterMarkerSymbol.None)
Note that we need to include "using System.Drawing;" due to the color parameter.
In practice, the code above will be modified to:
plotter.AddSeries(new Series("Buy", SeriesType.Scatter, string.Empty, Color.Green, ScatterMarkerSymbol.Triangle)); plotter.AddSeries(new Series("Sell", SeriesType.Scatter, string.Empty, Color.Red, ScatterMarkerSymbol.TriangleDown));
If we do not want to control the marker color, we should use Color.Empty and let it be set automatically.
Simon Lloyd
Thank you so much.
Where do I add the constructor overload? I've added it here:
using QuantConnect; using System.Drawing; namespace QuantConnect { public Series (string name, SeriesType type, string unit, Color color, ScatterMarkerSymbol symbol = ScatterMarkerSymbol.None);
and it's telling me that the method must have a return type.
Sorry if this is basic, I'm new to C#
Alexandre Catarino
The constructor is one way to create an instance of a type. When a constructor has overloads, it means it accepts different paramenters. In this case, you can create an intance of Series with two parameters, but you need to use an overload that accepts five.
Breaking it up in steps:
// Creates plotter that is an instance of Chart class Chart plotter = new Chart("Plotter"); // Creates buySeries that is an instance of Series class Series buySeries = new Series("Buy", SeriesType.Scatter, string.Empty, Color.Green, ScatterMarkerSymbol.Triangle); // Adds buySeries into plotter (instance of Chart class) // using Chart.AddSeries method plotter.AddSeries(buySeries);
Please checkout the full working example below.
Simon Lloyd
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!