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

&& (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.
    JimNinjaTrader Customer Service

    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.



        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Working...
        X