I am developing a strategy, and the display is based on 1-minute chart. I want to display the 5-minute EMA and SMA on the 1-minute chart when the strategy is enabled.
This is what I have so far.
Declared the Indicators.
private EMA goldLine5m = null;
private SMA redLine5m = null;
In OnStateChange, I have the following code added.
When State == State.Configure
AddDataSeries(BarsPeriodType.Minute, 5);
When State == State.DataLoaded
goldLine5m = EMA(Closes[1], 9);
goldLine5m.Plots[0].Brush = Brushes.Yellow;
goldLine5m.Plots[0].DashStyleHelper = DashStyleHelper.DashDot;
goldLine5m.Plots[0].Width = 3;
goldLine5m.PaintPriceMarkers = false;
goldLine5m.Panel = 0;
AddChartIndicator(goldLine5m);
redLine5m = SMA(Closes[1], 21);
redLine5m.Plots[0].Brush = Brushes.Red;
redLine5m.Plots[0].DashStyleHelper = DashStyleHelper.DashDot;
redLine5m.Plots[0].Width = 3;
redLine5m.PaintPriceMarkers = false;
redLine5m.Panel = 0;
AddChartIndicator(redLine5m);
I thought that adding the .Panel = 0 would cause it to display in the main window. In fact, I do see "SMA(RTY 12-23 (5 minute),21)" at the top of the chart, just no lines.
If I change "Closes[1]" to "Closes[0]" the line shows up ok, but of course, it is displaying the wrong series data.
I saw another post that said to use EMASecondarySeries instead of EMA, but I don't see that indicator available anywhere.
I do see the bullet item in the AddChartIndicator() documentation that states:
Is this talking about the EMASecondarySeries? Do I need to create my own indicator for this to work?
Comment