NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-09-2011, 03:43 PM   #1
CaptainAmericaXX
Senior Member
 
Join Date: Jan 2011
Posts: 182
Thanks: 16
Thanked 0 times in 0 posts
Default 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
CaptainAmericaXX is offline  
Reply With Quote
Old 06-09-2011, 05:05 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 06-09-2011, 09:32 PM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

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?
koganam is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 11:12 AM.