Method: Quant::Ticks::OHLC#compute_doji

Defined in:
lib/quant/ticks/ohlc.rb

#compute_dojiBoolean

Computes a doji candlestick pattern. A doji is a candlestick pattern that occurs when the open and close are the same or very close to the same. The high and low are also very close to the same. The doji pattern is a sign of indecision in the market. It is a sign that the market is not sure which way to go.

Returns:

  • (Boolean)


119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/quant/ticks/ohlc.rb', line 119

def compute_doji
  body_bottom, body_top = [open_price, close_price].sort

  body_length = body_top - body_bottom
  head_length = high_price - [open_price, close_price].max
  tail_length = [open_price, close_price].max - low_price

  body_ratio = 100.0 * (1 - (body_bottom / body_top))
  head_ratio = head_length / body_length
  tail_ratio = tail_length / body_length

  body_ratio < 0.025 && head_ratio > 1.0 && tail_ratio > 1.0
end