Skip to content

Instantly share code, notes, and snippets.

@aktowns
Created February 8, 2018 13:39
Show Gist options
  • Save aktowns/b12fc5ed0a2e1b844bc06c9fcbb8dc28 to your computer and use it in GitHub Desktop.
Save aktowns/b12fc5ed0a2e1b844bc06c9fcbb8dc28 to your computer and use it in GitHub Desktop.
renderCandleAt :: CandleStick -> Candle -> Double -> String
renderCandleAt candlestick candle heightUnit =
if ((fromIntegral $ ceiling ts) >= heightUnit) && heightUnit >= (fromIntegral $ floor bc) then
if (tc - heightUnit) > 0.75 then symbolCandle
else if (tc - heightUnit) > 0.25 then
if (ts - heightUnit) > 0.75 then symbolHalfTop
else symbolHalfCandleTop
else
if (ts - heightUnit) > 0.75 then symbolStick
else if (ts - heightUnit) > 0.25 then symbolHalfStickTop
else symbolNothing
else if (fromIntegral $ floor tc) >= heightUnit && heightUnit >= (fromIntegral $ ceiling bc) then symbolCandle
else if (fromIntegral $ ceiling bc) >= heightUnit && heightUnit >= (fromIntegral $ floor bs) then
if (bc - heightUnit) < 0.25 then symbolCandle
else if (bc - heightUnit) < 0.75 then
if (bs - heightUnit) < 0.25 then symbolHalfBottom
else symbolHalfCandleBottom
else
if (bs - heightUnit) < 0.25 then symbolStick
else if (bs - heightUnit) < 0.75 then symbolHalfStickBottom
else symbolNothing
else symbolNothing
where
ts = toHeightUnits candlestick $ topStick candle
tc = toHeightUnits candlestick $ topCandle candle
bs = toHeightUnits candlestick $ bottomStick candle
bc = toHeightUnits candlestick $ bottomCandle candle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment