Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

remove repeated signals

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      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);
      }

      Comment


        #4
        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([COLOR=red][B]"ArrowUp"[/B][/COLOR], true, 0, Low[0] - (TickSize*ArrowDisplacement), UpColor);
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          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 Files

          Comment


            #6
            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

            Comment


              #7
              RyanM thanks a lot, works great.

              Comment


                #8
                Glad to hear, bogey20. Thanks for the update.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RideMe, 04-07-2024, 04:54 PM
                5 responses
                28 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by f.saeidi, Today, 08:13 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by DavidHP, Today, 07:56 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by kujista, Today, 06:23 AM
                3 responses
                9 views
                0 likes
                Last Post kujista
                by kujista
                 
                Started by Mindset, Yesterday, 02:04 AM
                2 responses
                18 views
                0 likes
                Last Post NinjaTrader_RyanS  
                Working...
                X