Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing rectangles

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

    Drawing rectangles

    Hello,
    I wish to draw a rectangle in the Stochastic panel between 40 and 60.
    Using this command:

    Draw.Rectangle(this, "oo"+CurrentBar.ToString(), true, 1, 60.0, 0, 40.0, Brushes.Blue, Brushes.Blue, 50);

    It gets confused and displays a scale of 0 to 0.24. I have tried both true and false

    What am I doing wrong?

    protected override void OnBarUpdate()
    {
    double min0 = min[0];
    nom[0] = Close[0] - min0;
    den[0] = max[0] - min0;

    if (den[0].ApproxCompare(0) == 0)
    fastK[0] = CurrentBar == 0 ? 50 : fastK[1];
    else
    fastK[0] = Math.Min(100, Math.Max(0, 100 * nom[0] / den[0]));

    // Slow %K == Fast %D
    K[0] = smaFastK[0];
    D[0] = smaK[0];
    Draw.Rectangle(this, "oo"+CurrentBar.ToString(), true, 1, 60.0, 0, 40.0, Brushes.Blue, Brushes.Blue, 50);
    }

    #2
    Hello morrnel,

    Thanks for your post.

    Please make sure that in State.SetDefaults you have (or add if not) DrawOnPricePanel = false; this is what i see when doing that:

    Click image for larger version

Name:	Mornel-1.PNG
Views:	433
Size:	49.1 KB
ID:	1128045

    However, I would strongly advise against drawing 1 bar rectangles as this will lead you to a lot of excessive draw objects in a hurry which will consume your PC resources. If all you want is a shaded region from 40 to 60 I would use Draw.RegionHighLightY() and issue that once when CurrentBar == 0, for example:

    if (CurrentBar == 0)
    {
    Draw.RegionHighlightY(this, "Test", true, 40, 60, Brushes.Blue, Brushes.Blue, 50);
    }


    Here is what that looks like and uses minimal resources:

    Click image for larger version

Name:	morn.PNG
Views:	462
Size:	43.5 KB
ID:	1128044

    Reference: https://ninjatrader.com/support/help...highlighty.htm

    Comment


      #3
      The two changes cause the blue bar to display across the bottom of the candle pane,

      Comment


        #4
        Hello mornel,

        It sounds like you did not set DrawOnPricePanel = false; in State.SetDefaults.

        Can you confirm this has been set?

        Note: After making changes and recompiling you must remove the indicator from the chart and then re-apply.

        Comment


          #5
          It works now just when I was going to show you I did it all as suggested. Perhaps the simulation was practicing a full moon or something.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          578 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X