Back

Charting values at specific dates and resolution of charts?

I'm not quite certain how custom charts work exactly. How does the Plot() function know whether the values I'm charting are for minute, hour, or daily resolution? How does the Plot() function know which minute/hour/day does the value I'm adding to the series corresponds to?

Here is why I'm asking: I am trying to retroactively plot several days into the past. For example, if it is day 5 as far as the algorithm is concerned, I want the algorithm to plot data for days 1-4 on my custom chart. How would I go about achieving that?

Thanks,
Tomer
Update Backtest








Hey Tomer!

You can control the time stamps on the chart points through manually managing the Series object. I've attached an example that manually adds a chart and series, saves off the series object, and then adds chart points directly to the series. Using this method, you can specify the DateTime for the data point.

The example simply plots the price from 15 days ago at market open.
1

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.


Thanks Michael, that helps a lot.

Follow up question: do the charts/series have to be initialized in the Initialize() function, or can it be done later within some other method?
0

You can initialize them from anywhere. Some things in the algorithm get 'locked' after initialization, but charting is not one of them. Check this out:
1

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.


Thanks! Interesting, for some reason initializing them in a different file didn't work. Perhaps it's because it wasn't a partial class?
0

The function AddChart is defined on QCAlgorithm, so you either must be 'inside' an instance of QCAlgorithm or you must call it on an instance of QCAlgorithm:algorithm.AddChart(chart);
Check out this example, I perform the same actions using a separate file/class that accepts your algorithm in the constructor.
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.


Very cool, thank you!
0

I've got another related question: is there a way to control the symbols of a Scatter Series and the color of Scatter/Line Series? Right now they're automatically but randomly differentiated. I'd like to, for example, have "green up triangles" for buy signals and "red down triangles" for sell signals.
0

Ah that's a super cool idea :D but sorry no way currently. I'll make sure its on the list for this week. Its really easy to add. Submitted a github issue.
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.


Interesting.

Is there a way we can display the key trade properties, such as entry price, stoploss position, and targets?

It would be very helpful to have a visual aid to see what the trade entry, stop, and target prices were against a bar chart. If a trade fails, I'd like to know why, and having the visuals on screen would be awesome.

Is that even possible?

0

@Tomer - We now allow setting the color of lines and symbols for custom charts using the Color and ScatterMarkerSymbol property of the series.

@Mark - you can tag orders with text, but on the chart there's currently no way to nicely put the information you're talking about and the charting library we use makes this difficult. You could make a custom series which simply contains information meaningful to you? E.g. Add a series "Stop Price" and each scatter point would be the price for the order.

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.


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