I am quite new to ninja script and am building an indicator that will need to use the last 5 zig zag high and low points.
I have written the code below with a loop to find the last 5 Zig Zag lows and highs and store them in an array for each.....
I want to check to make sure the loop is correct so i have put a drawtext function on to see the values printed on the chart... but nothing happens.... the indicator compiles successfully and when i load it onto the chart i cant see the text.... can anyone tell me why please?
Any help greatly appreciated.
protected override void OnBarUpdate()
{
//------------------ If Zig Zag changed, update Zig Zag array --------------
zzL = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagLow[0];
zzH = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagHigh[0];
if (zzH != zzHigh[0] || zzL != zzLow[0])
{
double zzLastLowFound =0;
int LFound = 0;
double zzLastHighFound =0;
int HFound = 0;
for (int x = 0; x < 500; x++)
{
zzL = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagLow[x];
if (zzL != zzLastLowFound && LFound < 5)
{
zzLastLowFound = zzL;
zzLow[LFound] = zzL;
LFound = LFound + 1;
}
zzH = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagHigh[x];
if (zzH != zzLastHighFound && HFound < 5)
{
zzLastHighFound = zzH;
zzHigh[HFound] = zzL;
HFound = HFound + 1;
}
if (HFound >= 5 && LFound >= 5)break;
}
}
DrawText("DownCxnText" , "ZZH0 = "+zzHigh[0]+"ZZH1 = "+zzHigh[1]+"ZZH2 = "+zzHigh[2]+"ZZH3 = "+zzHigh[3]+"ZZH4 = "+zzHigh[4]+"", 1,zzHigh[1], Color.Black);
//Print ("ZZH0 = "+zzHigh[0]+"ZZH1 = "+zzHigh[1]+"ZZH2 = "+zzHigh[2]+"ZZH3 = "+zzHigh[3]+"ZZH4 = "+zzHigh[4]+"");
//---------------- If Zig Zag changed, update Zig Zag array END --------------
}
Comment