I have some indicators I built for another trading platform and I am trying to learn how to port them over to work on NT8.
Test scenario:
Chart set to 60 min aggregation
Secondary data series set to daily aggregation
Check if any given high from the secondary time frame is a higher high than one day to the left and one day to the right
(very similar to the Swing indicator included with NT8)
Goal:
When this pattern is identified on a specific bar the code needs to place the plot over the entire day in which this condition is true. (Just like the Swing indicator does but it only works on the primary series time frame). I have included a screenshot which is very important for describing exactly what this code does and the behavior I am trying to enforce.
Here is a section of code I have built to test this out and try to find a solution:
First, there are two data series that are initialized using the BarsArray[1]. They are listed in the "State.DataLoaded" of the "State.Confige" sections of the indicator class. As follows:
timeFrameOne = new Series<double>(BarsArray[1]); swingHigh = new Series<bool>(BarsArray[1]);
if (BarsInProgress == 1)
{
// This works, except it does not shift the plots two days to the left.
if (High[0] < High[1] & High[1] > High[2])
{
timeFrameOne[0] = High[1];
swingHigh[0] = true;
}
else
{
timeFrameOne[0] = Close[0];
swingHigh[0] = false;
}
}
if (BarsInProgress == 0)
{
if (timeFrameOne[0] != 0)
{
Value[0] = timeFrameOne[0];
}
else
{
Value[0] = Value[1];
}
}
I would expect that when you adjust the following line...
timeFrameOne[2] = High[1];
I have tried just about every combination of code elements In can imagine. This is just the version that demonstrates what I am trying to accomplish in the clearest terms.
Now I know you can simply change the index value to 14 hours to the left using an index value of [14]. But when you switch the chart to a 15 min or 5 min time frame these plot do not adapt and the plots are not centered where I intended.
FYI. I really need to have a solution that works with a plot statement. I cannot use a drawing object placed at the desired location unless I can use that drawing object as an anchor point from which to adjust my plot values.
Hope that makes sense. Thanks in advance for any assistance or suggestions you have.

Comment