View Full Version : DrawObject Removal
Gumphrie
07-19-2007, 09:01 AM
Is there any way to stop drawobjects you've written into your indicator from being removed when the user manually clears them by clicking "Remove All Draw Objects" from the drop-down menu?
If not, is there a known way to plot dots that have an outline as with DrawDot() , but in a Plot instead ?
Thanks in Advance
Gumphrie
07-19-2007, 10:13 AM
Nevermind about the dots, I guess its case of overiding the Plot class.
Just an 'ignore user input' flag for drawobjects would be good, otherwise you get into overiding the Plot class for a very minor reason.
NinjaTrader_Dierk
07-19-2007, 10:52 AM
We'll put it to our list. Thanks for your suggestion.
Fernando
10-26-2010, 09:20 AM
I did a script to Draw a Triangle Up when RSI is above 65 and a Triangle Down when RSI is below 35 as you can see below.
If RSI goes above 65 the Triangle Up appears but if than the bar close with RSI below 65 the Triangle up stays there. I tried to use RemoveDrawObject for the cases whose RSI is between 35 - 65, but the Triangles stay there.
Could you please tell me how to fix this.
If I use BackColor = Color.DarkSeaGreen; instead DrawTriangleUp it works really good and I don't need to remove it.
Thanks
if (RSI(period,1)[0]>65)
{
DrawTriangleUp("rsi1" +CurrentBar, true, 0, Low[0] - 13*TickSize, Color.Yellow);
}
else if (RSI(period,1)[0]<35)
{
DrawTriangleDown("rsi12" +CurrentBar, true, 0, High[0] + 13*TickSize, Color.White);
}
if(RSI(period,1)[0]>35 || RSI(period,1)[0]<65)
{
RemoveDrawObject("rsi1");
RemoveDrawObject("rsi12");
}
NinjaTrader_RyanM
10-26-2010, 09:33 AM
Hello Fernando,
If RSI goes above 65 the Triangle Up appears but if than the bar close with RSI below 65 the Triangle up stays there
You can set CalculateOnBarClose = true and these conditions will only be evaluated at bar close.
If you want COBC = false, your removal code doesn't include the CurrentBar portion in the tag field.
if(RSI(period,1)[0]>35 || RSI(period,1)[0]<65)
{
RemoveDrawObject("rsi1" + CurrentBar);
RemoveDrawObject("rsi12" + CurrentBar);
}
Fernando
10-26-2010, 09:52 AM
Thanks RyanM
I prefer COBC = false. I tried with RemoveDrawObject("rsi1" + CurrentBar); and all Triangles had gone. I only want the Triangle being remove if the bar closes with RSI below 65 after RSI went above 65 in the some bar, As I sad with BackColor = Color.DarkSeaGreen; instead DrawTriangleUp it works really good and I don't need to remove it.
Thanks
NinjaTrader_RyanM
10-26-2010, 10:01 AM
You can probably fix this by changing the removal if clause to else. It's then only evaluted when the previous two conditions are false.
if (RSI(period,1)[0]>65)
{
DrawTriangleUp("rsi1" + CurrentBar, true, 0, Low[0] - 13*TickSize, Color.Yellow);
}
else if (RSI(period,1)[0]<35)
{
DrawTriangleDown("rsi12" + CurrentBar, true, 0, High[0] + 13*TickSize, Color.White);
}
else
{
RemoveDrawObject("rsi1" + CurrentBar);
RemoveDrawObject("rsi12" + CurrentBar);
}
Fernando
10-26-2010, 10:14 AM
Thanks RyanM
I don't know what you mean. Could you please be more specific
Thanks
NinjaTrader_RyanM
10-26-2010, 10:23 AM
Please try with the code snippet I posted.
Changing if to else so that the removal condition is only evaluated when the previous two conditions are false.
With the way it's structured now, your results are expected. It's removing whenever RSI > 35 which is also true when RSI > 65.
Fernando
10-26-2010, 10:26 AM
Thanks RyanM
I'm sorry only after my post I realized what you meant.
It works like you sad. Really good now.
Thanks
NinjaTrader_RyanM
10-26-2010, 10:33 AM
Glad to hear, Fernando. Thanks for the update.
Fernando
10-27-2010, 08:29 AM
I asked to close NT with one working order, it shows up a Warning saying "You have 1 active order. Do you really want to disconnect? I chose No and canceled all orders but now every time I ask to close comes that warning.
How can I cancel this warning once there are no active orders anymore?
Thanks
NinjaTrader_RyanM
10-27-2010, 08:55 AM
Fernando,
There can be occassions where orders get stuck in a pending state. You can remove these types of orders by resetting the simulated account.
Resetting a simulation account will clear all historical trade data from this account. Please follow the instructions below to reset a simulation account.
From the NinjaTrader Control Center window select the menu Tools > Options
Select the "Simulator" tab
Press the "Reset" button
Fernando
10-27-2010, 09:06 AM
Thanks RyanM
It worked well.