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

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 bc24fl, 08-30-2019, 01:58 PM
              3 responses
              253 views
              0 likes
              Last Post PaulMohn  
              Started by tradingnasdaqprueba, 04-09-2024, 09:52 AM
              6 responses
              26 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by PaulMohn, Today, 02:06 AM
              1 response
              3 views
              0 likes
              Last Post PaulMohn  
              Started by Mindset, Today, 01:27 AM
              0 responses
              5 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by EB Worx, 03-07-2023, 05:05 AM
              4 responses
              99 views
              1 like
              Last Post cls71
              by cls71
               
              Working...
              X