Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to account for candle open and close being equal

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

    How to account for candle open and close being equal

    Hi folks,
    I am working on an indicator that calculates wick size in relation to candle body size.

    Example is:

    top wick = 3 ticks
    candle body = 8 ticks
    bottom wick = 2 ticks

    The indicator weights the wicks against the candle averages out the top/bottom wick and plots it on a graph.

    The problem I am facing is when Open and Close are the same. Basically there is nothing for the wicks to be weighted against and the graph show is empty for that bar, even though the wicks might be quite large.

    My question is, how would I go about taking into account that a candle body may not exist (when difference between Open and Close price == 0)

    Any ideas?

    #2
    Hello Mountain_cast,

    That really depends on how you want to handle that. You could add a condition to check if the math used to get the ticks is 0 and supply a default value.

    Comment


      #3
      You are right. Your suggestion is actually what I had in mind. I think it's because I am not well enough versed in C# to know how to do that.


      double open0 = Open[0];
      double close0 = Close[0];​
      double candleRange0 = Math.Abs(open0 - close0);

      if (candleRange0 == 0)




      AND this is where i am stuck. How do something like

      if (candleRange0 == 0)
      double candleRangeAdjusted = candleRange0 + 1;



      EDIT: I figured it out
      Last edited by Mountain_cast; 12-12-2024, 09:03 PM.

      Comment

      Latest Posts

      Collapse

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