![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
|
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); } |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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);
}
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Nov 2008
Posts: 12
Thanks: 0
Thanked 0 times in 0 posts
|
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); } |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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;
}
}
}
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |