![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2011
Posts: 182
Thanks: 16
Thanked 0 times in 0 posts
|
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 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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 |
|
|
|
|
|
#3 |
|
Senior Member
|
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? |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DrawDot | ScottB | Indicator Development | 2 | 02-13-2011 12:49 PM |
| DrawDot help | upsndowns | Indicator Development | 1 | 05-19-2010 07:34 AM |
| DrawDot... | Mark- | General Programming | 29 | 03-03-2009 08:32 PM |
| DrawDot | rurimoon | General Programming | 5 | 01-24-2009 08:35 AM |
| DrawDot() | NinjaTrader_Josh | Indicator Development | 9 | 03-26-2008 07:51 AM |