I'm running a Ninja Script.
In the script, I have it draw an object when certain conditions are met.
I want the script to delete the object after other conditions are met.
I'm using this code:
if (GetCurrentBid() >= APZ(2, 20).Upper[0]
&& GetCurrentBid() >= Bollinger(2, 14).Upper[0])
{
DrawArrowDown("SellArrow" + CurrentBar, false, 0, GetCurrentBid() + 20 * TickSize, Color.Red);
}
This draws the arrow perfectly.
Now, when the condition changes, I want to delete it. I'm using this code:
if (GetCurrentBid() < APZ(2, 20).Upper[0]
&& GetCurrentBid() < Bollinger(2, 14).Upper[0])
{
RemoveDrawObject("SellArrow");
}
That's what it shows it the help documentation to delete a drawing object.
Nothing happens. The arrow stays there. I open up the arrow object on the chart and it shows the name as something like "SellArrow5817". Another sell arrow might show "SellArrow5816". No wonder its not deleting it, it sees the name as something different than "SellArrow".
Is there any way to prevent Ninja from automatically adding a number to the object so I can delete all past instances of the object when the conditions change?
I don't want to use RemoveDrawObjects() since it deletes everything (that command works) and I only want it to delete objects with a specific name, like BuyArrow or SellArrow.
Thanks,
Joe
Comment