I am sure I am missing something obvious, but it's stumped me, so if you could put me on the right track, I'd appreciate it...
I'm trying to develop a milti time frame indicator. So, for example, say we want to see if price is over the MA on the 1 minute, 5 minute, 5 range timeframes.
What I did is this
New indicator with this added
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 1);
AddDataSeries(Data.BarsPeriodType.Minute, 5);
AddDataSeries(Data.BarsPeriodType.Range, 5);
}else if (State == State.DataLoaded)
{
pjsKeltner1 = pjsKeltner(Closes[3],2,10,false,"");
}
The pjsKeltner is for this example the indicator I want to check on the 5 range series.
I setup a new chart with a single data series on it and add the indicator.
Now, as a test, all I've tried to do is change the plot colour when a threshold is reached. So I have this in onbarupdate
if (BarsInProgress == 3 && Bars.Count>1 && CurrentBar > 1)
{
if (Closes[3][0] <= pjsKeltner1.Lower1[0])
{
PlotBrushes[0][0] = Brushes.Green;
}
else if (Closes[3][0] >= pjsKeltner1.Upper1[0]) {
PlotBrushes[0][0] = Brushes.Red;
}
else {
PlotBrushes[0][0] = Brushes.DimGray;
}
I am simply setting the plot[0] to a value of 10 in onbarupdate and if (barsinprogress == 0) so there is a plot set for every interval that is shown on the chart.
If I set the chart period to something low, like 10 seconds, there are obviously periods where the above triggers and the plot should change colour, but it does not. If I change the data series on the chart to 5 range, it works. If I set the chart timeframe to anything else, even short periods which would obviously be inclusive of the time period the threshold was triggered, it does not.
I have tried with tick replay on also, thinking perhaps the 5 range data series ONLY has bar final closes in it? With tick replay on, does this affect only the main data series, or any seperate data series too? My thought was that Closes[3] might be just that, the bar closes ONLY, rather than updated tick by tick? If that is correct, it is possible to add dataseries, yet have them play their data through indicators with tick replay on also?
I hope this makes sense.
Thanks.
Comment