trtr

Trading simulator and techanalysis gym
git clone https://git.ea.contact/trtr
Log | Files | Refs | README

commit f8f07f6a390c6c7b1b89698a028a182b19631490
parent 0320520107050d42cf74ce11bab286c53b4439b8
Author: ea <ea@ea.contact>
Date:   Fri, 29 May 2026 10:57:15 +0000

Replace Predict with Rectangle

Diffstat:
Mfrontend/index.html | 63++++++++++++++++++---------------------------------------------
1 file changed, 18 insertions(+), 45 deletions(-)

diff --git a/frontend/index.html b/frontend/index.html @@ -729,7 +729,7 @@ <button class="gym-tool-btn" id="tool-line">Line</button> <button class="gym-tool-btn" id="tool-pencil">Pencil</button> <button class="gym-tool-btn" id="tool-text">Text</button> - <button class="gym-tool-btn" id="tool-predict">Predict</button> + <button class="gym-tool-btn" id="tool-rect">Rectangle</button> </div> <p class="gym-hint" id="tool-hint">Select a tool or pan/zoom freely.</p> </div> @@ -1342,7 +1342,7 @@ let gymIsDrawing = false; let gymCurrentPoints = []; let gymTextPending = null; - let gymHoverPos = null; // {logical, price} for predict hover preview + let gymHoverPos = null; const gymCanvas = document.getElementById('gym-canvas'); const gymCtx = gymCanvas.getContext('2d'); @@ -1418,16 +1418,8 @@ textInputEl.value = ''; textInputEl.focus(); } - } else if (gymActiveTool === 'predict') { - const pt = gymCurrentPoints[0]; - if (pt && Math.round(pt.logical) > gymLastLogical) { - gymPrediction = { - logTarget: Math.round(pt.logical), - entryPrice: currentPrice, - direction: pt.price > currentPrice ? 'long' : 'short', - }; - updatePredictionInfo(); - } + } else if (gymActiveTool === 'rect' && gymCurrentPoints.length >= 2) { + gymDrawings.push({ type: 'rect', points: [...gymCurrentPoints] }); } gymCurrentPoints = []; }); @@ -1589,40 +1581,11 @@ drawPredictionMarker(ctx, cp, cp.profit); } - // In-progress preview (line/pencil drag) - if (gymIsDrawing && gymActiveTool !== 'predict' && gymCurrentPoints.length >= 1) { + // In-progress preview + if (gymIsDrawing && gymCurrentPoints.length >= 1) { renderGymShape(ctx, gymActiveTool, gymCurrentPoints, null, 0.55); } - // Predict hover preview — vertical guide while hovering - if (gymActiveTool === 'predict' && gymHoverPos) { - const { logical, price } = gymHoverPos; - if (logical != null && Math.round(logical) > gymLastLogical) { - const hx = chart.timeScale().logicalToCoordinate(logical); - const ey = candleSeries.priceToCoordinate(currentPrice); - const isLong = price > currentPrice; - const hcol = isLong ? '#26a69a' : '#ef5350'; - if (hx != null) { - ctx.strokeStyle = hcol; - ctx.lineWidth = 1; - ctx.setLineDash([4, 4]); - ctx.globalAlpha = 0.35; - ctx.beginPath(); - ctx.moveTo(hx, 0); - ctx.lineTo(hx, gymCanvas.height); - ctx.stroke(); - if (ey != null) { - ctx.beginPath(); - ctx.moveTo(0, ey); - ctx.lineTo(gymCanvas.width, ey); - ctx.stroke(); - } - ctx.setLineDash([]); - ctx.globalAlpha = 1; - } - } - } - // Saved drawings for (const d of gymDrawings) { renderGymShape(ctx, d.type, d.points, d.text, 1); @@ -1645,6 +1608,16 @@ if (px[i].x != null && px[i].y != null) ctx.lineTo(px[i].x, px[i].y); } ctx.stroke(); + } else if (type === 'rect' && px.length >= 2 && px[1].x != null) { + const x0 = Math.min(px[0].x, px[1].x); + const y0 = Math.min(px[0].y, px[1].y); + const w = Math.abs(px[1].x - px[0].x); + const h = Math.abs(px[1].y - px[0].y); + ctx.strokeStyle = '#f0c040'; + ctx.fillStyle = 'rgba(240,192,64,0.07)'; + ctx.lineWidth = 1.5; + ctx.strokeRect(x0, y0, w, h); + ctx.fillRect(x0, y0, w, h); } else if (type === 'text' && text) { ctx.fillStyle = '#e0d0ff'; ctx.font = '13px "Segoe UI", system-ui, sans-serif'; @@ -1675,14 +1648,14 @@ line: 'Click and drag to draw a straight line.', pencil: 'Click and drag to draw freehand.', text: 'Click to place a text label.', - predict: 'Click a future point — above price = Long, below = Short.', + rect: 'Click and drag to draw a rectangle.', }; document.getElementById('tool-hint').textContent = tool ? hints[tool] : 'Select a tool or pan/zoom freely.'; } // Tool buttons — click active tool to deselect - ['line', 'pencil', 'text', 'predict'].forEach(tool => { + ['line', 'pencil', 'text', 'rect'].forEach(tool => { document.getElementById('tool-' + tool).addEventListener('click', () => { setGymTool(gymActiveTool === tool ? null : tool); });