Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

&& (DMI(14)[0] > 20) wont plot correctly

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

    && (DMI(14)[0] > 20) wont plot correctly

    NT7
    using this code first is for above 20 DMI second is below -20
    && (DMI(14)[0] > 20) and && DMI(14)[0] < -20)
    issue is the code above doesnt reference DMI to plot above or below 20, it plots all the time.
    What is the correct way to code so code only references above or below 20?

    thx in advance

    #2
    Hello Rad4633,

    Thanks for your post.

    I suggest first setting up conditions that focus only on DMI(14)[0] being greater than or less than 20/-20. You may have some other pieces of logic that are used with && operators which would make the whole condition evaluate as false. If this is the case those other conditions will need to be checked using debugging prints to see why the other parts of the condition have not evaluated as true.

    If you try something like the below in an indicator, and then plot this indicator on top of a DMI(14) indicator on a chart, you can visualize where the code detects above and below, and you can also see the output window which tells you when DMI is above/below 20/-20.

    Code:
    if (CurrentBar < 14)
        return;
    
    if (DMI(14)[0] > 20 || DMI(14)[0] < -20)
        Print("DMI is above/below 20/-20 on bar: " + Time[0]);
    
    if (DMI(14)[0] > 20)
        DrawArrowDown("Above"+CurrentBar, true, 0, DMI(14)[0] + 5, Color.Green);
    
    if (DMI(14)[0] < -20)
        DrawArrowUp("Below"+CurrentBar, true, 0, DMI(14)[0] - 5, Color.Red);
    We look forward to assisting.

    Comment


      #3
      Corrected issue +-20, NT DMI uses 0-100 +or- so using .65 +/- now but why is the arrows plotting at 0 price line?

      Current code below no other parameters io code, attachment pic of 0 plotting
      {
      // Condition set 1
      if (CurrentBar < 14)return;

      if (DMI(14)[0] > .65 || DMI(14)[0] < -.65)
      //Print("DMI is above/below .65/-.65 on bar: " + Time[0]);

      if (DMI(14)[0] > .65)
      DrawArrowDown("Above"+CurrentBar, true, 0, DMI(14)[0] + 1, Color.Green);

      if (DMI(14)[0] < -.65)
      DrawArrowUp("Below"+CurrentBar, true, 0, DMI(14)[0] - 1, Color.Red);
      }
      Attached Files

      Comment


        #4
        Hello Rad4633,

        Have a look at the Overlay property and the DrawOnPricePanel property used in your indicator.

        To have that indicator draw on top of the DMI indicator, you will need to have Overlay set to true, DrawOnPricePanel set to false, and the indicator will have to be added to the same panel as the DMI indicator.



        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 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
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X