NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-30-2010, 09:45 AM   #1
bogey20
Junior Member
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
Default remove repeated signals

Let say I have this for an entry:
if (Signal0[0] > Signal1[0] && High[0] > High[1]
which plots buy arrows every bar. I need just to plot the first arrow if the signal occures, is there a way to remove repeated signals?
bogey20 is offline  
Reply With Quote
Old 06-30-2010, 09:53 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Bogey20,

If these are buy arrows from orders, then they can't selectively be removed.

If you are using DrawArrow commands then you can just use one id for the tag. It will replace previous versions with the same ID.

You can also remove drawing objects through code.
http://www.ninjatrader-support.com/H...rawObject.html
NinjaTrader_RyanM is offline  
Reply With Quote
Old 06-30-2010, 01:30 PM   #3
bogey20
Junior Member
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi RyanM
I use the DrawArrow, if it's not too much trouble would you be able to modify this not to show the repeated arrows, I'm a complete newbie on NinjaTrader, here is the code I have:

if (Signal0[0] > Signal1[0] && High[0] > High[1] )
{
Alert("CrossUp", NinjaTrader.Cbi.Priority.High, "long", "long.wav", 10, Color.Yellow, Color.Black);
if (showArrows) DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - (TickSize*ArrowDisplacement), UpColor);
}
bogey20 is offline  
Reply With Quote
Old 06-30-2010, 02:12 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

bogey20,

Sure, the corrected code is below. You were using a tag that updated dynamically with each bar. The code below uses only one value "ArrowUp". It will be replaced anytime the condition is true, so you will only see the latest (most recent) arrow drawn.

Code:
 
if (Signal0[0] > Signal1[0] && High[0] > High[1] ) 
{ 
Alert("CrossUp", NinjaTrader.Cbi.Priority.High, "long", "long.wav", 10, Color.Yellow, Color.Black);
if (showArrows) DrawArrowUp("ArrowUp", true, 0, Low[0] - (TickSize*ArrowDisplacement), UpColor);
}
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-01-2010, 09:04 AM   #5
bogey20
Junior Member
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
Default

Well maybe I did not explained it clearly, so I'm attaching an image. There you can see all the arows the system is generating, however I only want to see the arrows in circles, those are the very first arrows when the signal is valid. So I'm trying to find a way to remove all the other arrows. Here is the code so far:

if (Signal0[0] > Signal1[0] && High[0] > High[1] )
{
Alert("CrossUp", NinjaTrader.Cbi.Priority.High, "long", "long.wav", 10, Color.Yellow, Color.Black);
if (showArrows) DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - (TickSize*ArrowDisplacement), UpColor);

}



else if (Signal0[0] < Signal1[0] && Low[0] < Low[1] )
{
Alert("CrossDown", NinjaTrader.Cbi.Priority.High, "short", "short.wav", 10, Color.Yellow, Color.Black);
if (showArrows) DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + (TickSize*ArrowDisplacement), DownColor);
}
Attached Images
File Type: png image1.png (9.1 KB, 13 views)
bogey20 is offline  
Reply With Quote
Old 07-01-2010, 09:31 AM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Bogey20,

This scenario requires custom programming. Basically you want to turn off the display of up arrows until the down arrows are drawn and vice versa. You can do this with bool flags.

The following snippet is untested and not supported, but you may be able to adapt to fit your needs.


Code:
 
#region Variables
private bool upDrawn = false;
private bool downDrawn = false;
#endregion
 
 
protected override void OnBarUpdate()
{
if (Signal0[0] > Signal1[0] && High[0] > High[1] && !upDrawn ) 
{ 
Alert("CrossUp", NinjaTrader.Cbi.Priority.High, "long", "long.wav", 10, Color.Yellow, Color.Black);
if (showArrows) 
{
DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - (TickSize*ArrowDisplacement), UpColor);
upDrawn = true;
downDrawn = false;
}
}
 
 
else if (Signal0[0] < Signal1[0] && Low[0] < Low[1] && !downDrawn ) 
{
Alert("CrossDown", NinjaTrader.Cbi.Priority.High, "short", "short.wav", 10, Color.Yellow, Color.Black); 
if (showArrows) 
{
DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + (TickSize*ArrowDisplacement), DownColor);
downDrawn = true;
upDrawn = false;
}
} 
 
 
 
 
 
}
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-01-2010, 12:25 PM   #7
bogey20
Junior Member
 
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
Default

RyanM thanks a lot, works great.
bogey20 is offline  
Reply With Quote
Old 07-01-2010, 01:13 PM   #8
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Glad to hear, bogey20. Thanks for the update.
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Too many repeated lines in a file soyjesus Automated Trading 3 06-15-2009 06:05 AM
Previous day data repeated? heech Charting 19 12-14-2008 11:38 PM
Remove Old Strategy Buy or Sell Signals lawyse Charting 3 09-03-2008 08:11 AM
Data on Chart being repeated TraderStavros Historical NinjaTrader 6.5 Beta Threads 5 04-01-2008 09:28 AM
Repeated Install Failure Sacpokr Installation and Licensing 5 12-12-2006 04:33 PM


All times are GMT -6. The time now is 05:48 AM.