Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set plot brushes to transparent n bars ago

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

    How to set plot brushes to transparent n bars ago

    Hi,
    I am trying to code a custom indicator to plot fractal highs and lows, i am not able to set the last high bar to transparent using the below code, Please help.

    if(spl == false && sph == true && lasthigh < High[period])
    {

    RemoveDrawObject("high"+lasthighbar);
    PlotBrushes[0][lasthighbar] = Brushes.Transparent;
    Draw.TriangleUp(this,"high"+ (CurrentBar - period),true,period,High[period],Upcolor);

    lasthigh = High[period]; // Save the last High value for next ray drawn
    lasthighbar = CurrentBar - period;

    }

    FYI https://ibb.co/ZGmC7Jz​
    Last edited by Sndeep; 08-23-2023, 05:48 AM.

    #2
    Hello Sndeep,

    Thanks for your post.

    To clarify, are you wanting to set the color of a plot to transparent for a certain historical bar?

    PlotBrushes would be used to set a historical plot value to a specific color, such as transparent.

    PlotBrushes: https://ninjatrader.com/support/help...lotbrushes.htm

    What exactly is not working in the code you shared?

    Are your conditions becoming true for changing the PlotBrush to transparent for the barsAgo value you are passing into PlotBrushes?

    I have attached a simple script to this reply that you could view demonstrating using HighestBar() to get the number of bars ago the highest price value occurred within the last 10 bars and passing that barsAgo value into the PlotBrushes barsAgo argument to color the plot on that bar to transparent.

    Prints should be added to the script to understand exactly how your logic is evaluating in the script. One line above the conditions to change the PlotBrushes to transparent, add prints that print out each value being used in your condition to see how they are calculating and if the condition is becoming true.

    One line above where you are setting PlotBrushes, add prints to the script that print out the barsAgo (lasthighbar) you are passing into PlotBrushes and print out the CurrentBar to see how which bar lasthighbar is referencing.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello Brandon,
      Thanks for the response, I got the solution for my problem from your reply by using the print function. I will upload the indicator in app share.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 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