I took parts from the Ninja PA indicator and rewrote them to find DTs/DBs. The original finds them only in hindsight (after the completion of the most recent swing) and not all of them (only one swing back).
The code below is supposed to find all of them. Does anybody have an idea, why this is not working?
It should test for DTs from the current bar (working bar) and draw text above that bar.
It should work for live and historical data.
These are my first steps with NT script. I´m coming from MQL and wrote several indicators including PA indis.
if (CurrentBar < 70) return;
double offset = 0.25;
double toffset = 0.50;
double curhigh = High[CurrentBar];
for (int i = 1; i < 70; i++)
{
double prevhigh = 0;
int barsback2 = Swing(1).SwingHighBar(2,i,70);
if (barsback2 == -1) break;
prevhigh = Swing(1).SwingHigh[barsback2];
if (prevhigh > curhigh + offset) break;
if (curhigh <= prevhigh + offset && curhigh >= prevhigh - offset)
{
DrawText("DT"+CurrentBar,"DT",0, High[CurrentBar] + toffset, Color.Peru);
break;
}
}
Comment