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 Graci117, Today, 09:02 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by ETFVoyageur, Today, 07:55 PM
            0 responses
            7 views
            0 likes
            Last Post ETFVoyageur  
            Started by janio973, Today, 07:24 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by aligator, 01-06-2022, 12:14 PM
            4 responses
            246 views
            0 likes
            Last Post john_44573  
            Started by reynoldsn, Today, 05:56 PM
            0 responses
            14 views
            0 likes
            Last Post reynoldsn  
            Working...
            X