Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

DrawDot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DrawDot

    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
    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 P.NinjaTrader Customer Service

    Comment


      #3
      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


      Comment


        #4
        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 P.NinjaTrader Customer Service

        Comment


          #5
          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.

          Comment


            #6
            Right. It is a known bug with nested CalculateOnBarCloses.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mattbsea, Today, 05:44 PM
            0 responses
            4 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            31 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            2 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,282 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            20 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Working...
            X