Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw dots

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

    Draw dots

    I modeled from MacdColorBars in this forum publication and want to make a change. Instead of painting the bars, I want to draw a green dot below the price bar when MACD value is above 0. And draw a red dot above the price bar when MACD value is below 0.

    So I replace

    if (Value[0] >= 0)
    BarColor = Color.Blue;
    else
    BarColor = Color.Red;

    with the following coding:
    if (Value[0] >= 0 && Value[1] < 0)
    {DrawDot("tag"+CurrentBar, true, Time[0], Low[0], Color.Lime);}
    else if (Value[0] <= 0 && Value[1] > 0)
    {DrawDot("tag"+CurrentBar, true, Time[0], High[0], Color.Red);}
    else
    {RemoveDrawObject("tag"+CurrentBar);}


    It does not draw the dots and the plot of MACD is not displayed.

    What went wrong? Could someone help?

    Thank you.

    #2
    Hi Benluk, is there any error noted in NT's log tab in the Control Center as you apply this changed study to your chart? Does you have included a check for enough CurrentBars as well to account for referencing one bar back now for your comparison?

    Comment


      #3
      Hi Bertrand,

      I am not familiar with OOP coding, but I am able to follow your hints to fix it. It is working. Thank you.

      I want to make another change. Since I need the dot or arrow up on the chart only, I do not need to plot MACD on the bottom. Want to save space on the chart. So I comment out the following coding:

      protected override void Initialize()
      {
      // Add(new Plot(Color.Yellow, "Macd"));
      // Add(new Plot(Color.Cyan, "Avg"));
      // Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "Diff"));
      // Add(new Line(Color.DarkGray, 0, "Zero line"));

      When I run, I did not get the desired results and got errors on the log.

      Call to Junk DLL failed.
      Error on calling ÖnBarUpdate'method for indicator on bar 1: Index was outside the bounds of the array.
      Failed to call method Ïnitialize for indicator 'FantailVMA3: 'BarsArray'property can't be accessed from within Ínitialize' method

      And a couple more similar messages.

      Is there an easy way to fix it at coding level? Please direct me if there are references.

      Thank you.

      Comment


        #4
        Benluk, would you mind attaching us the study or sending in to support at ninjatrader dot com. You probably have not commented out the associated properties of the plots.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X