Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

drawdot off a few bars

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

    drawdot off a few bars

    Hello,
    I've got a bit of code that follows an indicator as it crosses a line. When the indicator crosses the line a dot is drawn. I'm finding that the 3rd and 4th dots are off a bar or two. Any suggestions as to why this would happen? Here is the code.
    //"1,2,3,4" Setup
    //This is the "reset" to start the "1"
    if (CrossBelow(DM(10).DiPlus, DM(10).DiMinus, 1)
    && Falling(ADX(10)) == true)
    {
    reset1234 = true;
    }

    // "1"
    dmCrossDown = MRO(delegate {return CrossBelow(DM(10).DiPlus, 25, 1);}, 1, 1);
    if(dmCrossDown > -1 && reset1234 == true && CurrentBar - myConditionBar >=2)
    {
    myConditionBar = CurrentBar;
    dm1stCrossDown = true;
    DrawDot("dm1stCrossDown" + CurrentBar,true,0,Low[0] - 1,Color.Red);
    reset1234 = false;
    }
    // "2"
    dmCrossUp = MRO(delegate {return CrossAbove(DM(10).DiPlus, 25, 1);}, 1, 1);
    if(dmCrossUp > -1 && dm1stCrossDown == true && CurrentBar - myConditionBar >=2)
    {
    myConditionBar = CurrentBar;
    dm1stCrossUp = true;
    DrawDot("dm1stCrossUp" + CurrentBar,true,0,Low[0] - 1,Color.Blue);
    dm1stCrossDown = false;
    }

    // "3"
    dmCrossDown = MRO(delegate {return CrossBelow(DM(10).DiPlus, 25, 1);}, 1, 1);
    if(dmCrossDown > -1 && dm1stCrossUp == true && CurrentBar - myConditionBar >=2)
    {
    myConditionBar = CurrentBar;
    DrawDot("dm2ndCrossDown" + CurrentBar,true,0,Low[0] - 1,Color.DarkRed);
    dm1stCrossUp = false;
    dm2ndCrossDown = true;
    }
    //"4"
    dmCrossUp = MRO(delegate {return CrossAbove(DM(10).DiPlus, 25, 1);}, 1, 1);
    if(dmCrossUp > -1 && dm2ndCrossDown == true && CurrentBar - myConditionBar >=2)
    {

    Also, how do you get those cool boxes that one can put code in that displays better in the post? Thanks

    #2
    Hello CaptainAmericaXX,

    To set as code in forum post: Select text and the click the # button.

    You will have to simplify and debug this. If you're having trouble with a couple of these drawing objects, then strip out anything unnecessary and focus only on those conditions you're having trouble with. Print the values of myConditionBar and CurrentBar since there's likely interaction there with other conditions

    I recall telling you about that technique in a previous post, but in order to integrate it fully, you need to have an understanding of its mechanics. We're happy to help guide in the right direction, but the code workings are ultimately your responsibility.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      According to your code, the dots are being drawn at the bar when the condition evaluates to true, not at the bar of the crossing.

      Are you saying that you expect the dots to be at the bar of the crossing?

      Comment

      Latest Posts

      Collapse

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