Session Ready
Exercise

Adding an indicator to a chart.Posn() chart

One of the more interesting things you can do with the chart.Posn() function is to superimpose indicators on top of it. This can help show what the strategy has actually been doing and why. However, in order to do this, you will need to recalculate the indicators outside the scope of your strategy. Once this is done, you simply add them to the chart.Posn plot.

In this exercise, you will add the three indicators from your strategy to the chart.Posn plot you just created. The two moving averages (SMA50 and SMA200) will be superimposed on the price series, while the DVO_2_126 will have its own window.

Instructions
100 XP
  • Begin by reproducing your SMA50, SMA200, and DVO_2_126 indicators for SPY outside of the strategy.
  • Recreate the chart from the previous exercise using chart.Posn().
  • Use add_TA() to overlay the SMA50 as a blue line on top of the price plot.
  • Use add_TA() to overlay the SMA200 as a red line on top of the price plot.
  • Use add_TA() to add the DVO_2_126 to your plot as a new window.