Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

lines touching

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

    lines touching

    Hello,
    Is there a way to draw a dot or color a bar etc. when 2 lines "touched", but don't necessarily cross?

    #2
    Hello CaptainAmericaXX,

    Yes, you can check when one value is equal to another value with ==.


    if (SMA(14)[0] == SMA(7)[0])
    Print("They touch");

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Cool Thanks!

      Comment


        #4
        Ryan,
        The explanation seemed easy enough, but I'm still a rookie. This is what I coded and I'm not getting anything.
        if ((ADX(10)[0]) == DM(10).DiPlus[0])
        {
        DrawDiamond("Lines Touch" + CurrentBar, true, 0, Low[0] - 2, Color.Blue);

        }
        Any suggestions?

        Comment


          #5
          Your code example looks good. Are there any occurrences on your chart where these exactly equal each other? You can pull up a data box (Ctrl + D) to confirm. You can also custom code a little give on each side if you want check if they're near each other but not exactly equal.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            That data box is really cool. I didn't know it existed. I see that during the individual bars the ADX and the DiPlus are never really the same. Certainly they cross, but the concluding numerical values are different. Can you give me an example of that custom code you were referring to when you said, " You can also custom code a little give on each side if you want check if they're near each other but not exactly equal." Thanks

            Comment


              #7
              Instead of:
              Code:
              if ((ADX(10)[0]) == DM(10).DiPlus[0])
              Add tolerance via a tick size nudge factor. You can decide what exactly you want to use as the nudge factor yourself:
              Code:
              if (ADX(10)[0] >= (DM(10).DiPlus[0] - 1 * TickSize) && ADX(10)[0] <= (DM(10).DiPlus[0] + 1 * TickSize))
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              576 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X