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

Avoiding two consecutive signals in a row

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

    Avoiding two consecutive signals in a row

    Hello,

    I developed an indicator that draws a dot below a candle (for a long signal) if certain conditions are met.
    In case two consecutive candles in a row meet the criteria, I want to avoid that the indicator draws two dots in a row in order to keep my chart clean.
    How can I do that? (It comes down to checking if the conditions were met for the prior bar and if they're met again in the current bar, then no dot should be drawn).

    Thanks

    #2
    Hello laocoon,

    If you only ever want one drawing object to appear, you can re-use the tag name, and this will move the existing object to the current bar instead of generating a new object.


    You could also remove the dot on the previous bar with RemoveDrawObject().


    You could check the condition was not true one bar ago in the condition set that draws the dot.

    For example if the condition is that the Close is greater than the Open.

    if (CurrentBar > 1 && Close[1] <= Open[1] // check the previous bar close is not greater than the open
    && Close[0] > Open[0]) // check the current bars close is greater than the open
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      Thanks for your reply.
      I don't want only one drawing object ever to appear, I want all to appear, just not if there are two (or more) candles in a row that meet my criteria.
      Example:
      -If three consecutive candles meet my criteria, I only want the drawing object to appear above/below the first candle.
      -If the first candle meets my criteria, I want the drawing object to appear, if the second doesn't meet them it obviously won't appear but if the third candle meets them again I want the drawing object to appear again.

      Thanks

      Comment


        #4
        Hello laocoon,

        In your condition you would check bars ago 1 does not have the condition true and bars ago 2 does not have the condition true and bars ago 0 does have the condition true.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        16 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,407 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X