diamond-in commited on
Commit
7b1dc57
·
verified ·
1 Parent(s): eb4c257

Update js/chart.js

Browse files
Files changed (1) hide show
  1. js/chart.js +38 -4
js/chart.js CHANGED
@@ -1,4 +1,3 @@
1
- // Export the chart and series so we can manipulate them
2
  let chart, series;
3
 
4
  export function initChart() {
@@ -6,8 +5,8 @@ export function initChart() {
6
 
7
  chart = LightweightCharts.createChart(chartDiv, {
8
  layout: { background: { color: '#ffffff' }, textColor: '#000', fontFamily: 'Space Mono' },
9
- grid: { vertLines: { visible: false }, horzLines: { color: '#eee' } },
10
- crosshair: { mode: 1 },
11
  timeScale: { borderColor: '#000', timeVisible: true },
12
  rightPriceScale: { borderColor: '#000' },
13
  });
@@ -26,4 +25,39 @@ export function initChart() {
26
  return { chart, series };
27
  }
28
 
29
- export function getSeries() { return series; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  let chart, series;
2
 
3
  export function initChart() {
 
5
 
6
  chart = LightweightCharts.createChart(chartDiv, {
7
  layout: { background: { color: '#ffffff' }, textColor: '#000', fontFamily: 'Space Mono' },
8
+ grid: { vertLines: { visible: false }, horzLines: { color: '#f0f0f0', style: 2 } },
9
+ crosshair: { mode: 1, vertLine: { labelBackgroundColor: '#000' }, horzLine: { labelBackgroundColor: '#000' } },
10
  timeScale: { borderColor: '#000', timeVisible: true },
11
  rightPriceScale: { borderColor: '#000' },
12
  });
 
25
  return { chart, series };
26
  }
27
 
28
+ export function getSeries() { return series; }
29
+
30
+ // --- NEW FEATURE: WHALE BUBBLES ON CANDLES ---
31
+ export function generateSmartMarkers(candles) {
32
+ // 1. Calculate Volatility (High - Low) to determine what a "Large" order looks like
33
+ // In a real app, we would use Volume, but Range is a good visual proxy for Price Action
34
+ const ranges = candles.map(c => c.high - c.low);
35
+ const avgRange = ranges.reduce((a, b) => a + b, 0) / ranges.length;
36
+ const threshold = avgRange * 1.5; // Show bubble if candle is 1.5x larger than average
37
+
38
+ const markers = [];
39
+
40
+ candles.forEach(c => {
41
+ const range = c.high - c.low;
42
+ const isBigMove = range > threshold;
43
+
44
+ // LOGIC:
45
+ // If Candle is RED (Close < Open) and Big -> Sell Whale (Red Bubble Above)
46
+ // If Candle is GREEN (Close > Open) and Big -> Buy Whale (Green Bubble Below)
47
+
48
+ if (isBigMove) {
49
+ const isBearish = c.close < c.open;
50
+
51
+ markers.push({
52
+ time: c.time,
53
+ position: isBearish ? 'aboveBar' : 'belowBar',
54
+ color: isBearish ? '#dc2626' : '#16a34a', // Deep Red or Deep Green
55
+ shape: 'circle',
56
+ text: isBearish ? 'Whale Sell' : 'Whale Buy', // The text inside/near bubble
57
+ size: 2, // Making them noticeable
58
+ });
59
+ }
60
+ });
61
+
62
+ series.setMarkers(markers);
63
+ }