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 Felix Reichert, 04-26-2024, 02:12 PM
                11 responses
                71 views
                0 likes
                Last Post Felix Reichert  
                Started by junkone, 04-28-2024, 02:19 PM
                7 responses
                78 views
                1 like
                Last Post junkone
                by junkone
                 
                Started by pechtri, 06-22-2023, 02:31 AM
                11 responses
                135 views
                0 likes
                Last Post Nyman
                by Nyman
                 
                Started by ageeholdings, 05-01-2024, 05:22 AM
                4 responses
                27 views
                0 likes
                Last Post ageeholdings  
                Started by hdge4u, 04-29-2024, 12:23 PM
                4 responses
                22 views
                0 likes
                Last Post NinjaTrader_RyanS  
                Working...
                X