Show description
Candlestick Pattern Dojo // ARCHITECT_BUILD_v1.0
Candlestick Pattern Dojo // ARCHITECT_BUILD_v1.0
Candlestick Pattern Dojo
LIVE SIMULATION ENVIRONMENT
Select a Pattern
...
Historical Reversal %
--%
Occurrence Rarity
--
Select a candlestick pattern from the sidebar to visualize its structure, understand the market psychology behind it, and view statistical reversal probabilities.
// Logic will appear here
Candlestick Pattern Dojo // ARCHITECT_BUILD_v1.0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Candlestick Pattern Dojo // ARCHITECT_BUILD_v1.0</title>
<style>
:root {
--bg-core: #050505;
--bg-panel: rgba(20, 20, 30, 0.6);
--text-primary: #e0e0e0;
--text-secondary: #94a3b8;
--accent-bull: #00ff9d; /* Neon Green */
--accent-bear: #ff0055; /* Neon Red */
--accent-neutral: #00d9ff; /* Cyan */
--grid-line: rgba(255, 255, 255, 0.05);
--glass-border: 1px solid rgba(255, 255, 255, 0.1);
--font-ui: 'Inter', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background-color: var(--bg-core);
color: var(--text-primary);
font-family: var(--font-ui);
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* UI Layout */
header {
padding: 1rem 2rem;
border-bottom: var(--glass-border);
display: flex;
justify-content: space-between;
align-items: center;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
}
h1 {
font-size: 1.2rem;
text-transform: uppercase;
letter-spacing: 2px;
color: var(--accent-neutral);
}
.badge {
font-family: var(--font-mono);
font-size: 0.75rem;
padding: 4px 8px;
border: 1px solid var(--accent-neutral);
border-radius: 4px;
color: var(--accent-neutral);
}
.main-container {
display: grid;
grid-template-columns: 300px 1fr 350px;
flex: 1;
height: calc(100vh - 60px);
}
/* Sidebar: Pattern Selector */
.sidebar {
border-right: var(--glass-border);
padding: 1rem;
overflow-y: auto;
background: var(--bg-panel);
}
.pattern-btn {
display: block;
width: 100%;
padding: 1rem;
margin-bottom: 0.5rem;
background: rgba(255, 255, 255, 0.03);
border: 1px solid transparent;
color: var(--text-secondary);
text-align: left;
cursor: pointer;
transition: all 0.2s;
font-family: var(--font-mono);
font-size: 0.9rem;
border-radius: 6px;
}
.pattern-btn:hover {
background: rgba(255, 255, 255, 0.08);
border-color: var(--accent-neutral);
color: white;
}
.pattern-btn.active {
background: rgba(0, 217, 255, 0.1);
border-color: var(--accent-neutral);
color: var(--accent-neutral);
box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
}
/* Main Stage: Canvas */
.stage {
position: relative;
background-image:
linear-gradient(var(--grid-line) 1px, transparent 1px),
linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
background-size: 40px 40px;
display: flex;
justify-content: center;
align-items: center;
}
canvas {
box-shadow: 0 0 50px rgba(0,0,0,0.5);
border: var(--glass-border);
background: rgba(0,0,0,0.3);
border-radius: 8px;
}
/* Right Panel: Data */
.info-panel {
border-left: var(--glass-border);
padding: 2rem;
background: var(--bg-panel);
display: flex;
flex-direction: column;
gap: 2rem;
overflow-y: auto;
}
.info-card h2 {
font-size: 1.5rem;
margin-bottom: 0.5rem;
color: white;
}
.info-card .subtitle {
color: var(--text-secondary);
font-size: 0.9rem;
margin-bottom: 1.5rem;
display: block;
}
.stat-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-bottom: 1.5rem;
}
.stat-box {
background: rgba(0,0,0,0.4);
padding: 1rem;
border-radius: 6px;
border: 1px solid rgba(255,255,255,0.05);
}
.stat-label {
font-size: 0.7rem;
text-transform: uppercase;
color: var(--text-secondary);
margin-bottom: 0.5rem;
display: block;
}
.stat-value {
font-family: var(--font-mono);
font-size: 1.2rem;
font-weight: bold;
}
.bullish { color: var(--accent-bull); }
.bearish { color: var(--accent-bear); }
.neutral { color: var(--text-primary); }
.description {
font-size: 0.95rem;
line-height: 1.6;
color: #ccc;
padding: 1rem;
background: rgba(255,255,255,0.05);
border-radius: 6px;
border-left: 3px solid var(--accent-neutral);
}
.formula {
margin-top: 1rem;
font-family: var(--font-mono);
font-size: 0.8rem;
background: #000;
padding: 1rem;
border-radius: 4px;
color: var(--accent-neutral);
}
/* Responsive */
@media (max-width: 900px) {
.main-container {
grid-template-columns: 1fr;
grid-template-rows: auto 400px auto;
overflow-y: auto;
}
.sidebar { border-right: none; border-bottom: var(--glass-border); display: flex; overflow-x: auto; white-space: nowrap; }
.pattern-btn { width: auto; display: inline-block; margin-bottom: 0; margin-right: 0.5rem; }
}
</style>
</head>
<body>
<header>
<h1>Candlestick Pattern Dojo</h1>
<div class="badge">LIVE SIMULATION ENVIRONMENT</div>
</header>
<div class="main-container">
<div class="sidebar" id="patternList">
</div>
<div class="stage">
<canvas id="chartCanvas" width="600" height="400"></canvas>
</div>
<div class="info-panel" id="infoPanel">
<div class="info-card">
<h2 id="patternTitle">Select a Pattern</h2>
<span class="subtitle" id="patternSentiment">...</span>
<div class="stat-grid">
<div class="stat-box">
<span class="stat-label">Historical Reversal %</span>
<div class="stat-value" id="winRate">--%</div>
</div>
<div class="stat-box">
<span class="stat-label">Occurrence Rarity</span>
<div class="stat-value" id="rarity">--</div>
</div>
</div>
<div class="description" id="description">
Select a candlestick pattern from the sidebar to visualize its structure, understand the market psychology behind it, and view statistical reversal probabilities.
</div>
<div class="formula" id="logic">
// Logic will appear here
</div>
</div>
</div>
</div>
<script>
// --- DATA & LOGIC ---
const patterns = [
{
id: 'hammer',
name: 'Hammer',
sentiment: 'Bullish Reversal',
type: 'bullish',
winRate: '60%',
rarity: 'Medium',
desc: 'A small body near the top of the range with a long lower shadow. It indicates that sellers pushed prices down, but buyers rejected the lows and pushed price back up near the open.',
logic: 'LowerShadow > (2 * Body) && UpperShadow < (0.1 * Range)',
generator: (ctx, w, h) => {
// Draw downtrend context
drawCandle(ctx, w/4, h/3, 20, 'bearish', 1.2);
drawCandle(ctx, w/2.5, h/2, 20, 'bearish', 1.0);
// Draw The Hammer (Green)
// Open high, Close higher, Low very low
const cx = w/2 + 20;
const cy = h/2 + 40;
const bodySize = 20;
const wickLen = 80;
// Dynamic Hammer
drawProceduralCandle(ctx, cx, cy, 25, {
bodyH: bodySize,
wickTop: 2,
wickBot: wickLen,
isBullish: true
}, true);
}
},
{
id: 'shooting_star',
name: 'Shooting Star',
sentiment: 'Bearish Reversal',
type: 'bearish',
winRate: '59%',
rarity: 'Medium',
desc: 'The inverted version of the Hammer. Occurs after an uptrend. Buyers tried to push higher, but sellers took control and forced the close near the open.',
logic: 'UpperShadow > (2 * Body) && LowerShadow < (0.1 * Range)',
generator: (ctx, w, h) => {
// Uptrend context
drawCandle(ctx, w/4, h/1.5, 20, 'bullish', 1.2);
drawCandle(ctx, w/2.5, h/2.5, 20, 'bullish', 1.0);
// Draw Shooting Star (Red)
const cx = w/2 + 20;
const cy = h/3; // Higher up
drawProceduralCandle(ctx, cx, cy, 25, {
bodyH: 20,
wickTop: 80,
wickBot: 2,
isBullish: false
}, true);
}
},
{
id: 'bullish_engulfing',
name: 'Bullish Engulfing',
sentiment: 'Strong Bullish',
type: 'bullish',
winRate: '63%',
rarity: 'High',
desc: 'A two-candle pattern. The first is a small red candle. The second is a large green candle that completely "engulfs" the body of the previous one. Shows a massive shift in momentum.',
logic: 'Curr.Open < Prev.Close && Curr.Close > Prev.Open',
generator: (ctx, w, h) => {
const cx = w/2;
const cy = h/2;
// Candle 1: Small Bearish
drawProceduralCandle(ctx, cx - 40, cy, 20, {
bodyH: 30, wickTop: 10, wickBot: 10, isBullish: false
}, false);
// Candle 2: Large Bullish (Engulfing)
drawProceduralCandle(ctx, cx + 10, cy, 25, {
bodyH: 70, wickTop: 15, wickBot: 15, isBullish: true
}, true);
}
},
{
id: 'doji',
name: 'Doji',
sentiment: 'Neutral / Indecision',
type: 'neutral',
winRate: '50%',
rarity: 'High',
desc: 'Open and Close are virtually the same. Represents a tug-of-war between buyers and sellers where neither side won. Often precedes a reversal.',
logic: 'Math.abs(Open - Close) < (0.05 * Range)',
generator: (ctx, w, h) => {
drawCandle(ctx, w/4, h/2 + 50, 20, 'bullish', 1.5);
const cx = w/2;
const cy = h/2 - 20;
// The Doji
drawProceduralCandle(ctx, cx, cy, 20, {
bodyH: 2, wickTop: 60, wickBot: 60, isBullish: true
}, true);
}
},
{
id: 'morning_star',
name: 'Morning Star',
sentiment: 'Bullish Reversal',
type: 'bullish',
winRate: '70%',
rarity: 'Low',
desc: 'A 3-candle pattern: 1. Long Red, 2. Small/Doji gap down, 3. Long Green gap up. A powerful reversal signal.',
logic: 'Bearish Candle -> Gap Down Doji -> Bullish Candle',
generator: (ctx, w, h) => {
const cx = w/2;
const cy = h/2;
// 1. Long Red
drawProceduralCandle(ctx, cx - 60, cy - 30, 20, {
bodyH: 80, wickTop: 10, wickBot: 10, isBullish: false
}, false);
// 2. Small Star (lower)
drawProceduralCandle(ctx, cx, cy + 40, 20, {
bodyH: 15, wickTop: 10, wickBot: 10, isBullish: true
}, false);
// 3. Long Green
drawProceduralCandle(ctx, cx + 60, cy - 20, 20, {
bodyH: 70, wickTop: 10, wickBot: 10, isBullish: true
}, true);
}
}
];
// --- UI ENGINE ---
const canvas = document.getElementById('chartCanvas');
const ctx = canvas.getContext('2d');
let activePattern = patterns[0];
function init() {
const list = document.getElementById('patternList');
patterns.forEach(p => {
const btn = document.createElement('button');
btn.className = 'pattern-btn';
btn.innerText = p.name;
btn.onclick = () => loadPattern(p, btn);
list.appendChild(btn);
if(p.id === 'hammer') btn.classList.add('active');
});
loadPattern(patterns[0], list.children[0]);
animate();
}
function loadPattern(pattern, btnElement) {
activePattern = pattern;
// Update Active UI
document.querySelectorAll('.pattern-btn').forEach(b => b.classList.remove('active'));
if(btnElement) btnElement.classList.add('active');
// Update Info Panel
const title = document.getElementById('patternTitle');
title.innerText = pattern.name;
const sentiment = document.getElementById('patternSentiment');
sentiment.innerText = pattern.sentiment;
sentiment.className = 'subtitle ' + pattern.type;
document.getElementById('winRate').innerText = pattern.winRate;
document.getElementById('winRate').className = 'stat-value ' + pattern.type;
document.getElementById('rarity').innerText = pattern.rarity;
document.getElementById('description').innerText = pattern.desc;
document.getElementById('logic').innerText = pattern.logic;
// Trigger Redraw
drawScene();
}
// --- RENDERING ENGINE ---
function drawScene() {
// Clear Screen
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw Grid/Axes (Subtle)
ctx.strokeStyle = 'rgba(255,255,255,0.05)';
ctx.lineWidth = 1;
ctx.beginPath();
for(let i=0; i<canvas.width; i+=40) { ctx.moveTo(i,0); ctx.lineTo(i,canvas.height); }
for(let i=0; i<canvas.height; i+=40) { ctx.moveTo(0,i); ctx.lineTo(canvas.width,i); }
ctx.stroke();
// Execute Specific Generator
if (activePattern) {
activePattern.generator(ctx, canvas.width, canvas.height);
}
}
// Helper: Draw Simple Static Candle (for context)
function drawCandle(ctx, x, y, w, type, scale) {
const color = type === 'bullish' ? '#00ff9d' : '#ff0055';
const h = 40 * scale;
ctx.fillStyle = color;
ctx.strokeStyle = color;
// Body
ctx.fillRect(x - w/2, y - h/2, w, h);
// Wicks
ctx.beginPath();
ctx.moveTo(x, y - h/2);
ctx.lineTo(x, y - h/2 - (15 * scale));
ctx.moveTo(x, y + h/2);
ctx.lineTo(x, y + h/2 + (15 * scale));
ctx.stroke();
}
// Helper: Draw Procedural Candle with Glow
function drawProceduralCandle(ctx, x, y, width, params, isFocus) {
const { bodyH, wickTop, wickBot, isBullish } = params;
const color = isBullish ? '#00ff9d' : '#ff0055';
ctx.save();
if(isFocus) {
ctx.shadowColor = color;
ctx.shadowBlur = 20;
}
ctx.strokeStyle = color;
ctx.fillStyle = isBullish ? 'rgba(0, 255, 157, 0.2)' : 'rgba(255, 0, 85, 0.2)'; // Glassy fill
ctx.lineWidth = 2;
// Draw Wicks
ctx.beginPath();
// Top Wick
ctx.moveTo(x, y - bodyH/2);
ctx.lineTo(x, y - bodyH/2 - wickTop);
// Bottom Wick
ctx.moveTo(x, y + bodyH/2);
ctx.lineTo(x, y + bodyH/2 + wickBot);
ctx.stroke();
// Draw Body
ctx.fillRect(x - width/2, y - bodyH/2, width, bodyH);
ctx.strokeRect(x - width/2, y - bodyH/2, width, bodyH);
// Fill solid if Bearish (classic style) or translucent if Bullish
if (!isBullish) {
ctx.fillStyle = color;
ctx.fillRect(x - width/2, y - bodyH/2, width, bodyH);
}
ctx.restore();
// Add labels if focus
if (isFocus) {
ctx.font = "10px JetBrains Mono";
ctx.fillStyle = "#fff";
ctx.textAlign = "center";
ctx.fillText(isBullish ? "CLOSE" : "OPEN", x + 40, y - bodyH/2 + 4);
ctx.fillText(isBullish ? "OPEN" : "CLOSE", x + 40, y + bodyH/2 + 4);
}
}
// Animation Loop for "Live" feel
let tick = 0;
function animate() {
tick++;
// Subtle bobbing effect for the "Live" badge or background
// We don't want to redraw the canvas every frame unless interacting to save battery,
// but we can add a subtle noise effect if desired.
requestAnimationFrame(animate);
}
// Initialize
window.onload = init;
</script>
</body>
</html>