Technique 1: adTrace and Display in Dynamic Values
I use a text editor, this is a simple technique for one or more values, and is quick.
1. create an array to keep the values for each iBar iteration
2. set adTrace[iBar] to value
3. add or modify a component in the Component = new IndicatorComp[]; section
4. run and mouse over bars to see values
This example uses ADX indicator, renamed and with "CustomIndicator = true".
1. create an array to keep the values for each iBar iteration
At the start of Calculate, you should Reading the Parameters, then Calculation. Usually there are some arrays created. In ADX, it looks like:
double[] DIPos = new double[Bars];
double[] DINeg = new double[Bars];
for (int bar = 1; bar < Bars; bar++)
Be sure you add your array before the "for" line. I call my array "adTrace", and any more I add 1, like "adTrace1", "adTrace2", etc. To add:
double[] DIPos = new double[Bars];
double[] DINeg = new double[Bars];
double[] adTrace = new double[Bars];
for (int bar = 1; bar < Bars; bar++)
2. set adTrace[iBar] (or adTrace[bar]) to value
If you have unexpected values, usually one variable at some step is getting an unexpected value. Sometimes it's not set, so it's 0; the sign may be wrong; it's getting the price value from the wrong bar, etc. Many reasons, you just want to check one.
In ADX, I see variable "deltaHigh" is used, but not displayed. I want to check deltaHigh is what I expect.
Find these lines:
if (trueRange < Point)
trueRange = Point;
double deltaHigh = High[bar] - High[bar - 1];
double deltaLow = Low[bar - 1] - Low[bar];
if (deltaHigh > 0 && deltaHigh > deltaLow)
DIPos[bar] = 100 * deltaHigh / trueRange;
Add adTrace[bar]:
if (trueRange < Point)
trueRange = Point;
double deltaHigh = High[bar] - High[bar - 1];
double deltaLow = Low[bar - 1] - Low[bar];
adTrace[bar] = deltaHigh;
if (deltaHigh > 0 && deltaHigh > deltaLow)
DIPos[bar] = 100 * deltaHigh / trueRange;
3. add or modify a component in the Component = new IndicatorComp[]; section
Put adTrace in a Component, then you can see the trace values on the chart, the same as any other indicator value.
Look for this line:
// Saving the components
Component = new IndicatorComp[5];
Increase the number in [] by one:
// Saving the components
Component = new IndicatorComp[6];
Copy and Paste one of the Component blocks. Change the number in [] to previous step - 1 (eg, 6 - 1 = 5)
Component[0] = new IndicatorComp();
Component[0].CompName = "ADX";
Component[0].DataType = IndComponentType.IndicatorValue;
Component[0].ChartType = IndChartType.Line;
Component[0].ChartColor = Color.Blue;
Component[0].FirstBar = firstBar;
Component[0].Value = ADX;
// Copy and Paste Component[0], then change [0] to [5]
Component[5] = new IndicatorComp();
Component[5].CompName = "ADX";
Component[5].DataType = IndComponentType.IndicatorValue;
Component[5].ChartType = IndChartType.Line;
Component[5].ChartColor = Color.Blue;
Component[5].FirstBar = firstBar;
Component[5].Value = ADX;
Change the properties as set CompName to "adTrace", set Value to adTrace, and ChartType to .NoChart:
Component[5] = new IndicatorComp();
Component[5].CompName = "adTrace";
Component[5].DataType = IndComponentType.IndicatorValue;
Component[5].ChartType = IndChartType.NoChart;
Component[5].ChartColor = Color.Blue;
Component[5].FirstBar = firstBar;
Component[5].Value = adTrace;
(if there is "ShowDynamicInfo", be sure it is set to "true")
4. run and mouse over bars to see values
Save your file. Recompile Custom Indcators (Ctrl + I or Tools > Custom Indicators > Reload the Custom Indicators).
Add your indicator to a strategy.
Open the Chart.
Mouse over bars, and review Indicator Values on the right.
(img also attached below)
Now you can be sure deltaHigh is not always 0; manually calculate the bar's high - previous bar's high and verify they match; use common sense it is a reasonable number, like a few pips, not a wild value like 23,342,011.3489348.
Post's attachmentsadTrace.jpg 181.95 kb, file has never been downloaded.
You don't have the permssions to download the attachments of this post.