NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Charting

Charting Support for NinjaTrader Advanced Charting.

Reply
 
Thread Tools Display Modes
Old 02-09-2008, 07:08 PM   #1
PrTester
Senior Member
 
Join Date: Mar 2007
Posts: 212
Thanks: 0
Thanked 3 times in 3 posts
Default DrawLine Help

I'm trying to Draw a line every time Macd cross 0 , the code is:

protected override void OnBarUpdate()
{

if(MACD(12,26,9)[0] > 0 && MACD(12,26,9)[1] < 0)
{
updotbar=CurrentBar;
updot=High[0];
}

if(MACD(12,26,9)[0] > 0 && MACD(12,26,9)[1] < 0)
{
dndotbar=CurrentBar;
dndot=Low[0];
}

if (updotbar !=0 && updot !=0 && dndotbar!=0 && dndot!=0 )
{
DrawLine("MyLine1"+CurrentBar, updotbar, updot, dndotbar, dndot, Color.Blue);
DrawDiamond("MyDiamond1"+CurrentBar,true,dndotbar, dndot, Color.Red);
DrawDiamond("MyDiamond2"+CurrentBar, true,updotbar, updot, Color.Blue);
}

}

Any Idea of what I'm doing wrong will be appreciated.

Regards
Attached Images
File Type: jpg Macd.jpg (88.2 KB, 22 views)
PrTester is offline  
Reply With Quote
Old 02-09-2008, 08:41 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You never reset your updotbar, updot, dndotbar, dndot variables back to zero so after it evaluates to true once it will stay true for your whole chart. Also, your two if statement conditions are exactly the same. I am not sure if that was what you intended. If so you can merge the two together and maybe even share the same variables.
NinjaTrader_Josh 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
DrawLine into the future? higler General Programming 4 09-10-2008 12:27 PM
Use Indicator plot color in DrawLine() MJT Indicator Development 1 06-01-2007 03:13 PM
DrawText, DrawLine, etc... funk101 Indicator Development 2 05-27-2007 01:13 PM


All times are GMT -6. The time now is 01:36 AM.