I found the following indicator and have been using it as the base of what I'm trying to create.
https://ninjatraderecosystem.com/use...ad/swingrays2/
I've taken this script and adjusted it to get to where it is now.
So, basically what I'm trying to create here is a "resistance" indicator that will draw a horizontal line across the chart at a specified area and stop the line ONLY when the body of a bar gets in the way of it. However the problem I'm having now is the line is being removed even when the body of the bar is not in the way.
I think I know where the problem is within my code, but the solution that I thought of ends up almost breaking everything.
Currently I have
while ( swingHighRays.Count != 0 && currentBarStatus == bullish && Close[0] > tmpRay.StartAnchor.Price)
{
RemoveDrawObject(tmpRay.Tag);
}
Which will remove the resistance line as soon as any bar closes above the price of when the line was drawn. I thought that if I edited it to the following, it would fix the problem.
while ( swingHighRays.Count != 0 && currentBarStatus == bullish && Close[0] > tmpRay.StartAnchor.Price && Open[0] < tmpRay.StartAnchor.Price)
{
RemoveDrawObject(tmpRay.Tag);
}
Is there something I'm not understanding about the parameters that I'm putting in and that's why everything just breaks?
I think I'm missing some logic to my code to fix every situation but I thought the mentioned above code would at least fix this bit.
I don't even know where the problem lies so I'm not sure where / how to troubleshoot this. It kind of looks like it's working sometimes but for the most part, the lines are not being removed.
I have attached a couple screenshots for clarification and my current code.
The orange lines are supposed to be the removed lines and the blue lines are supposed to be ongoing lines.
Any suggestions to fix or even a completely different solution to the whole thing would be greatly appreciated
Thanks
Comment