My indicator draws an arrow when the condition for drawing is false and I can't figure it out why, as it produces the following prints:
Swing Low = False | CB = 2617
Swing Low = False | CB = 2618
Swing Low = False | CB = 2619
More confusing, if I put the Print in the statement body after the Draw.Arrow, it doesn't get executed, so again, how does the arrow get drawn?
private void PriceSwingLow() { Print("Swing Low = " + ((Math.Round(Lows[0][0] - MIN(Lows[0], MinSpan)[1], 2) >= TickSize && Math.Round(MIN(Lows[0], MinSpan - 1)[2] - MIN(Lows[0], MinSpan)[1], 2) >= TickSize && CurrentBar - (CurrentBar - LowestBar(Lows[0], MinSpan + 1)) == 1) || (CurrentBar - flatLowPriceBar == 1 && Math.Round(Lows[0][0] - FlatLowPrice[w-1], 2) >= TickSize && Math.Round(Lows[0].GetValueAt(flatLowPriceBar - 1) - FlatLowPrice[w-1], 2) >= TickSize)) + " | CB = " + CurrentBar + "\r\n-"); if ((Math.Round(Lows[0][0] - MIN(Lows[0], MinSpan)[1], 2) >= TickSize && Math.Round(MIN(Lows[0], MinSpan - 1)[2] - MIN(Lows[0], MinSpan)[1], 2) >= TickSize && CurrentBar - (CurrentBar - LowestBar(Lows[0], MinSpan + 1)) == 1) || (CurrentBar - flatLowPriceBar == 1 && Math.Round(Lows[0][0] - FlatLowPrice[w-1], 2) >= TickSize && Math.Round(Lows[0].GetValueAt(flatLowPriceBar - 1) - FlatLowPrice[w-1], 2) >= TickSize)) { Lprice.Add(MIN(Lows[0], MinSpan)[1]); // u LpriceBar.Add(CurrentBar - LowestBar(Lows[0], MinSpan + 1)); // u if (DrawArrows) Draw.ArrowUp(this, "Swing Up" + " | L P = " + LpriceBar[u], true, CurrentBar - LpriceBar[u], Lprice[u] - 3 * TickSize, Brushes.White, true); u++; } }
The code below produces the following prints:
Hprice.Count = 10 | HpriceBar[t-1] = 2619 | HpriceBar[t-2] = 2592 | Bar = 2620
Hprice.Count = 11 | HpriceBar[t-1] = 2625 | HpriceBar[t-2] = 2619 | Bar = 2626
As you can see, the script sees different values for HpriceBar[t-1] and HpriceBar[t-2] on Bar 2626, but when it draws the line, it takes equal values
private void NegativeDivergence() { if (Hprice.Count != listCountH) { if (b > 0 && HpriceBar[t-1] - HSwDMIbar[b-1] <= BarDiff /*&& HpriceBar[t-1] - HSwDMIbar[b-1] >= 0*/) HSwDMIbarHP.Add(HSwDMIbar[b-1]); // f else HSwDMIbarHP.Add(HpriceBar[t-1]); if (t > 1 && f > 0) { // Lower DMI Swing High and Higher Price ND1 = Math.Round(Hprice[t-1] - Hprice[t-2], 2) >= 0 && Math.Round(DMI1.Values[0].GetValueAt(HSwDMIbarHP[f-1]) - DMI1.Values[0].GetValueAt(HSwDMIbarHP[f]), 2) > 0; Print ("Hprice.Count = " + Hprice.Count + " | HpriceBar[t-1] = " + HpriceBar[t-1] + " | HpriceBar[t-2] = " + HpriceBar[t-2] + " | Bar = " + CurrentBar + "\r\n-"); if (!negDiv && ND1) { //PrintNegDiv(); negDiv = true; // NEG DIV = Reversal Down if (ND1) { if (DrawPriceLine) // ###*** Line Start = Line End on 14.02.2020 / 10:50am ***### Draw.Line(this, "Neg Div " + " / P S " + HpriceBar[t-2] + " / P E " + HpriceBar[t-1], true, CurrentBar - HpriceBar[t-2], Hprice[t-2], CurrentBar - HpriceBar[t-1], Hprice[t-1], negDivColour, divDashStyle, 1, true); if (DrawPriceLine) Draw.Line(this, "DMI Neg Div " + " / Dmi S " + HSwDMIbarHP[f-1] + " / Dmi E " + HSwDMIbarHP[f], true, CurrentBar - HSwDMIbarHP[f-1], DMI1.Values[0].GetValueAt(HSwDMIbarHP[f-1]), CurrentBar - HSwDMIbarHP[f], DMI1.Values[0].GetValueAt(HSwDMIbarHP[f]), negDivColour, divDashStyle, 1, false);
Comment