Simple Solution...
Use the following code to begin counting bars on the chart. This will give us a running count of the bars as we progress through the chart...
This gives us an ability to use a simple deduction of the current barcount and the bar # of a signal...
For example...
By using...
BarNumber - BarCount
to calculate the proper location of the item to draw, we can continually update and re-draw items as needed. All we need to do is record the barcount and price item.
Hope this helps..
Brad
Use the following code to begin counting bars on the chart. This will give us a running count of the bars as we progress through the chart...
PHP Code:
var nLastRawtime = 0;
var BarCount = 0;
function main() {
if (getValue("rawtime",0) != nLastRawtime) {
BarCount += 1;
nLastRawtime = (getValue("rawtime",0);
{
}
For example...
PHP Code:
var nLastRawtime = 0;
var BarCount = 0;
var LastPeak = null;
var LastPeakPrice = null;
function main() {
if (getValue("rawtime",0) != nLastRawtime) {
BarCount += 1;
nLastRawtime = (getValue("rawtime",0);
{
// record the bar number of a peak
if ((high() < high(-1)) && (high(-2) < high(-1)) ) {
LastPeak = BarCount;
LastPeakPrice = high(-1);
}
// Now for the graphics part...
// We can determine the actual "negative" bar number for drawing graphics by using...
// LastPeak - BarCount = Graphic X Location.
if ((LastPeak != null) && (LastPeakPrice != null)) {
DrawLineRelative((LastPeak - BarCount), LastPeakPrice, 0, high(), PS_SOLID, 1, Color.blue, "PeakLine");
}
}
BarNumber - BarCount
to calculate the proper location of the item to draw, we can continually update and re-draw items as needed. All we need to do is record the barcount and price item.
Hope this helps..
Brad
Comment