![]() |
|
|
#1 |
|
Senior Member
Join Date: Mar 2007
Posts: 212
Thanks: 0
Thanked 3 times in 3 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |