![]() |
|
|
#1 |
|
Junior Member
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
How to make DrawDot works with CalculateOnBarClose=false ?
Let say I add these 2 line at the end of MACD code in OnBarUpdate() if (Diff[0] > 0) DrawDot("dot" + CurrentBar, false, 0, 0, Color.Blue); else if (Diff[0] < 0) DrawDot("dot" + CurrentBar, false, 0, 0, Color.Red); It just draw a blue/red dot on the zeroline when cross. It works fine with CalculateOnBarClose=True, but everything stop working when set to false. I think it is because it try to redraw the dot on the same place that is causing the problem. How do I fix it. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Please elaborate more on what you mean by "stop working".
Your code does not generate unique string IDs for your objects when you have CalculateOnBarClose = false. It will just keep moving the original dot around. Only at the beginning of a new bar will a new dot be drawn.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
Here is the image. I use ZeroLagMACD instead since I don't want to mess around with @MACD indicator. But they are basically same thing. I only add 3 lines of code.
Inside Initialize() DrawOnPricePanel = false; Inside OnBarUpdate() if (Diff[0] > 0) DrawDot("dot" + CurrentBar, false, 0, 0, Color.Blue); else if (Diff[0] < 0) DrawDot("dot" + CurrentBar, false, 0, 0, Color.Red); Notice the top MACD has CalculateOnBarClose set to false at 1:44pm ![]()
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
It suggests to me your code is not working anymore. Please take a look at the MACD lines. They flat line. This looks like a potential bug on your ZeroLagMACD as a whole. You will want to check the Control Center logs for errors and will have to debug the ZeroLagMACD as it uses CalculateOnBarClose = false settings.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
Great! It took me an hour to find out that the DrawDot is not casuing the problem. Then another hour to find out that the ZeroLagMACD is not the problem neither and it is actually ZeroLagEMA that cause the problem. Then it took me another hour to find out what's wrong with ZeroLagEMA. And it was merely this statement: CalculateOnBarClose = true;
Yes, ZeroLagEMA hardcoded the default to true. It has to do with nesting I guess. Calling indicator of an indicator while one is set to true while one is set to false produced wired result. My problem go away when I deleted this line from ZerolagEMA. I think this bug need to be fix. The CalculateOnBarClose setting for the calling indicator should override the setting for the called indicator. |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Right. It is a known bug with nested CalculateOnBarCloses.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DrawDot() | NinjaTrader_Josh | Indicator Development | 9 | 03-26-2008 07:51 AM |
| DrawDot Or DrawTriangleUp etc... only outputting on last bar | scriabinop23 | Indicator Development | 2 | 01-22-2008 03:52 PM |