[ATTACH]n1306796[/ATTACH]
im using a stochastics fast on ninjatrader and basically have implementing the swing indicator to plot the swings on the D plot. whenever the criteria is matched in order to draw a line, it will draw a line in between the two dots. the rule for lines to be drawn is that the last recent dot [i] has to be connected to the dot before the last recent dot [i-1].
when its playing out in real time, the dots will form a line, but the last dot (arrow pointing to it) will disappear from the line, and move over to the right forming another dot. that then causes a line to form from the first initial dot (far left) to the newly plotted dot (far right). the newly plotted dot should ONLY be looking at the dot that was removed before it (which is the [i-1] logic) to potentially connect a line since it was the one before it.
it has something to do with the logic in "CollectSwingPoints()" There is immediate logic, and original swing logic. The dot that was removed was is the immediate logic, and the dot on the far right is the original swing logic removing the previous immediate logic dot.
i need the logic to not only make the dot stay, but also REGISTER the dot being there so that the [i] and [i-1] logic is being followed correctly.
its been about a week now trying to figure this out and ive had no luck at all. im hoping for someone more intelligent than me to be able to find a fix.
code snippet:
private void CollectSwingPoints()
{
for (int i = Strength; i <= CurrentBar; i++)
{
// Use immediate logic for swing highs above 80
if (i >= Strength && i < CurrentBar)
{
if (D[i] > 80 && D[i] > D[i - Strength] && D[i] > D[i + Strength])
{
swingHighBars.Add(i);
swingHighPrices.Add(D[i]);
}
}
// Use immediate logic for swing lows below 20
if (i >= Strength && i < CurrentBar)
{
if (D[i] < 20 && D[i] < D[i - Strength] && D[i] < D[i + Strength])
{
swingLowBars.Add(i);
swingLowPrices.Add(D[i]);
}
}
// Use original logic for swing highs above 80
int swingHighBar = swing.SwingHighBar(i, 1, int.MaxValue);
if (swingHighBar != -1 && D[swingHighBar] > 80)
{
double swingHighPrice = D[swingHighBar];
swingHighBars.Add(swingHighBar);
swingHighPrices.Add(swingHighPrice);
}
// Use original logic for swing lows below 20
int swingLowBar = swing.SwingLowBar(i, 1, int.MaxValue);
if (swingLowBar != -1 && D[swingLowBar] < 20)
{
double swingLowPrice = D[swingLowBar];
swingLowBars.Add(swingLowBar);
swingLowPrices.Add(swingLowPrice);
}
}
}

Comment