dixitramjendra commited on
Commit
08740d2
·
1 Parent(s): e77f782

Update: Refined signal management, display, and visitor tracking

Browse files
forex_macd_dashboard.html CHANGED
@@ -380,7 +380,7 @@
380
  <div class="subtitle">Multi-Timeframe Analysis: Trend • Momentum • Entry (Varies by Category)</div>
381
  <div id="visitorCounter"
382
  style="margin-top: 0.5rem; font-size: 0.9rem; color: var(--accent); font-weight: 600;">
383
- 👥 Unique Visitors: <span id="visitorCount">...</span>
384
  </div>
385
  </header>
386
 
@@ -414,8 +414,21 @@
414
  </section>
415
  </div>
416
 
 
 
 
 
417
  <script>
 
 
 
 
 
 
 
 
418
  function formatPrice(price, instrument) {
 
419
  if (instrument.includes('JPY')) {
420
  return price.toFixed(3);
421
  } else if (instrument.includes('Oil') || instrument.includes('Gold') || instrument.includes('Bitcoin') || instrument.includes('Ethereum') || instrument.includes('Nifty') || instrument.includes('Sensex')) {
@@ -439,27 +452,37 @@
439
  return `${day}/${month}/${year}, ${hours}:${minutes}:${seconds}`;
440
  }
441
 
442
- let currentCategory = 'Active';
443
  let cachedData = null;
444
 
445
  async function fetchData() {
 
446
  try {
447
  // Fetch signals
448
  const signalsRes = await fetch('forex_macd_signals.json');
449
  if (signalsRes.ok) {
450
  cachedData = await signalsRes.json();
 
 
451
  }
452
 
453
  // Fetch visitor count
454
- const visitorRes = await fetch('/api/visitor-count');
455
- if (visitorRes.ok) {
456
- const visitorData = await visitorRes.json();
457
- document.getElementById('visitorCount').textContent = visitorData.count;
 
 
 
 
 
458
  }
459
 
460
  renderDashboard();
461
  } catch (error) {
462
  console.error('Error fetching data:', error);
 
 
463
  }
464
  }
465
 
@@ -491,145 +514,224 @@
491
  }
492
 
493
  function renderDashboard() {
494
- if (!cachedData) return;
495
- const data = cachedData;
496
- const container = document.getElementById('dashboard');
497
- const lastUpdated = document.getElementById('lastUpdated');
498
-
499
- container.innerHTML = '';
500
- container.className = 'grid'; // Ensure grid layout
501
- lastUpdated.textContent = `Last Updated: ${new Date(data.last_updated).toLocaleString()}`;
502
-
503
- // Filter by category
504
- let filteredData = data.data;
505
- if (currentCategory === 'Active') {
506
- filteredData = data.data.filter(inst => inst.signal !== null);
507
- } else if (currentCategory !== 'All') {
508
- filteredData = data.data.filter(inst => inst.category === currentCategory);
509
- }
 
510
 
511
- // Sort: Signals first, then active status, then others
512
- filteredData.sort((a, b) => {
513
- const getPriority = (inst) => {
514
- if (inst.signal) return 2;
515
- if (inst.overall_status.includes('BUY') || inst.overall_status.includes('SELL')) return 1;
516
- return 0;
517
- };
518
- return getPriority(b) - getPriority(a);
519
- });
520
 
521
- filteredData.forEach(inst => {
522
- const card = document.createElement('div');
523
- card.className = 'card';
524
-
525
- let statusClass = 'status-waiting';
526
- if (inst.overall_status.includes('BUY')) statusClass = 'status-buy';
527
- if (inst.overall_status.includes('SELL')) statusClass = 'status-sell';
528
-
529
- const getTfClass = (bias) => {
530
- if (bias.includes('BULLISH')) return 'bullish';
531
- if (bias.includes('BEARISH')) return 'bearish';
532
- return 'neutral';
533
- };
534
-
535
- const getBorderClass = (bias) => {
536
- if (bias.includes('BULLISH')) return 'border-bullish';
537
- if (bias.includes('BEARISH')) return 'border-bearish';
538
- return 'border-neutral';
539
- };
540
-
541
- let signalHtml = '';
542
- if (inst.signal) {
543
- const typeClass = inst.signal.type === 'BUY' ? 'buy' : 'sell';
544
- const typeColor = inst.signal.type === 'BUY' ? 'bullish' : 'bearish';
545
- const entryPrice = inst.signal.entry_price || inst.signal.price;
546
- const isActive = inst.overall_status.includes('ACTIVE');
547
-
548
- signalHtml = `
549
- <div class="signal-panel ${typeClass}">
550
- <div class="signal-row" style="margin-bottom: 1rem; border-bottom: 1px solid #334155; padding-bottom: 0.5rem;">
551
- <span class="signal-label">${isActive ? '🔴 ACTIVE SIGNAL' : 'SIGNAL TRIGGERED'}</span>
552
- <span class="signal-val ${typeColor}" style="font-size: 1.2rem;">${inst.signal.type}</span>
553
- </div>
554
- <div class="signal-row">
555
- <span class="signal-label">Entry Price</span>
556
- <span class="signal-val">${formatPrice(entryPrice, inst.instrument)}</span>
557
- </div>
558
- <div class="signal-row">
559
- <span class="signal-label">Current LTP</span>
560
- <span class="signal-val" style="color: var(--accent)">${formatPrice(inst.ltp, inst.instrument)}</span>
561
- </div>
562
- <div class="signal-row">
563
- <span class="signal-label">Stop Loss ${inst.signal.current_sl !== inst.signal.sl ? '(Trailing)' : ''} ${inst.signal.sl_hit ? '<span style="color: var(--bearish); font-weight: bold; margin-left: 5px;">✗</span>' : ''}</span>
564
- <span class="signal-val" style="color: var(--bearish)">${formatPrice(inst.signal.current_sl || inst.signal.sl, inst.instrument)}</span>
565
- </div>
566
-
567
- <div style="margin-top: 0.5rem; border-top: 1px dashed #334155; padding-top: 0.5rem;">
568
- <div class="signal-row">
569
- <span class="signal-label">TP 1 (1.5x) ${inst.signal.tp_hits && inst.signal.tp_hits[0] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
570
- <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp1 || inst.signal.tp, inst.instrument)}</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  </div>
572
- <div class="signal-row">
573
- <span class="signal-label">TP 2 (3.0x) ${inst.signal.tp_hits && inst.signal.tp_hits[1] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
574
- <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp2 || 0, inst.instrument)}</span>
 
 
575
  </div>
576
- <div class="signal-row">
577
- <span class="signal-label">TP 3 (5.0x) ${inst.signal.tp_hits && inst.signal.tp_hits[2] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
578
- <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp3 || 0, inst.instrument)}</span>
 
 
 
 
 
 
579
  </div>
 
580
  </div>
581
- <div class="signal-row" style="margin-top: 0.5rem; border-top: 1px solid #334155; padding-top: 0.5rem;">
582
- <span class="signal-label">Signal Time</span>
583
- <span class="signal-val" style="color: var(--text-secondary); font-size: 0.85rem;">${formatDate(inst.signal.time)}</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  </div>
585
- </div>
586
- `;
587
- } else {
588
- signalHtml = `
589
- <div style="text-align: center; padding: 2rem; color: var(--text-secondary); border: 1px dashed #334155; border-radius: 0.5rem; margin-top: 1rem;">
590
- Waiting for signal conditions...
591
- </div>
592
- `;
593
- }
594
 
595
- card.innerHTML = `
596
- <div class="card-header">
597
- <div>
598
- <div style="font-size: 2.5rem; margin-bottom: 0.25rem;">${inst.flag || ''}</div>
599
- <div class="instrument-name">${inst.instrument}</div>
600
- <div class="current-price">LTP: ${formatPrice(inst.ltp, inst.instrument)}</div>
601
- </div>
602
- <div class="status-badge ${statusClass}">${inst.overall_status.replace(/_/g, ' ')}</div>
603
- </div>
604
-
605
- <div class="analysis-grid">
606
- <div class="tf-box ${getBorderClass(inst.daily.bias)}">
607
- <div class="tf-label">${inst.daily.label || 'Daily'}</div>
608
- <div class="tf-value ${getTfClass(inst.daily.bias)}">${inst.daily.bias}</div>
609
- </div>
610
-
611
- <div class="tf-box ${getBorderClass(inst.h4.bias)}">
612
- <div class="tf-label">${inst.h4.label || '4H MOM'}</div>
613
- <div class="tf-value ${getTfClass(inst.h4.bias)}">${inst.h4.bias}</div>
614
- </div>
615
-
616
- <div class="tf-box ${getBorderClass(inst.h1.status)}">
617
- <div class="tf-label">${inst.h1.label || '1H Entry'}</div>
618
- <div class="tf-value ${getTfClass(inst.h1.status)}">${inst.h1.status.replace(/_/g, ' ')}</div>
619
- </div>
620
- </div>
621
-
622
- ${signalHtml}
623
- `;
624
-
625
- container.appendChild(card);
626
- });
627
  }
628
 
629
  async function renderHistory() {
630
  const container = document.getElementById('dashboard');
631
  container.innerHTML = '<div style="grid-column: 1/-1; text-align: center; padding: 4rem;">Loading history...</div>';
632
- container.className = 'history-mode'; // Change layout if needed
633
 
634
  try {
635
  const res = await fetch('signal_history.json');
@@ -641,54 +743,176 @@
641
  return;
642
  }
643
 
644
- // Sort by time descending
645
- history.sort((a, b) => new Date(b.time) - new Date(a.time));
646
-
647
- let html = `
648
- <div class="history-table-container" style="grid-column: 1/-1;">
649
- <table class="history-table">
650
- <thead>
651
- <tr>
652
- <th>Time (IST)</th>
653
- <th>Instrument</th>
654
- <th>Event</th>
655
- <th>Price</th>
656
- <th>Type</th>
657
- </tr>
658
- </thead>
659
- <tbody>
660
- `;
661
-
662
- history.forEach(item => {
663
- let eventClass = 'event-entry';
664
- if (item.event.includes('TP')) eventClass = 'event-tp';
665
- if (item.event.includes('SL')) eventClass = 'event-sl';
666
-
667
- html += `
668
- <tr>
669
- <td style="color: var(--text-secondary); font-size: 0.9rem;">${item.time}</td>
670
- <td style="font-weight: 700;">${item.instrument}</td>
671
- <td><span class="event-badge ${eventClass}">${item.event.replace('_', ' ')}</span></td>
672
- <td style="font-family: monospace; font-weight: 600;">${formatPrice(item.price, item.instrument)}</td>
673
- <td class="${item.type === 'BUY' ? 'bullish' : 'bearish'}" style="font-weight: 700;">${item.type}</td>
674
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  `;
676
- });
677
 
678
- html += `
679
- </tbody>
680
- </table>
681
- </div>
682
- `;
683
- container.innerHTML = html;
 
 
 
 
 
 
 
 
 
 
 
 
 
684
  } catch (error) {
685
  container.innerHTML = `<div style="grid-column: 1/-1; text-align: center; padding: 4rem; color: var(--bearish);">Error loading history: ${error.message}</div>`;
686
  }
687
  }
688
 
689
 
 
 
 
 
 
 
 
 
690
  fetchData();
691
  setInterval(fetchData, 30000);
 
692
 
693
  // Feedback Submission
694
  document.getElementById('feedbackForm').addEventListener('submit', async (e) => {
 
380
  <div class="subtitle">Multi-Timeframe Analysis: Trend • Momentum • Entry (Varies by Category)</div>
381
  <div id="visitorCounter"
382
  style="margin-top: 0.5rem; font-size: 0.9rem; color: var(--accent); font-weight: 600;">
383
+ 👥 Visitors: <span id="activeCount">...</span> Active • <span id="visitorCount">...</span> Total
384
  </div>
385
  </header>
386
 
 
414
  </section>
415
  </div>
416
 
417
+ <div id="debugInfo"
418
+ style="display: none; background: #450a0a; color: #fecaca; padding: 1rem; margin: 1rem; border-radius: 0.5rem; border: 1px solid #991b1b; font-family: monospace; font-size: 0.8rem; white-space: pre-wrap;">
419
+ </div>
420
+
421
  <script>
422
+ // Global error handler
423
+ window.onerror = function (msg, url, lineNo, columnNo, error) {
424
+ const debug = document.getElementById('debugInfo');
425
+ debug.style.display = 'block';
426
+ debug.textContent += `ERROR: ${msg}\nLine: ${lineNo}\nCol: ${columnNo}\n\n`;
427
+ return false;
428
+ };
429
+
430
  function formatPrice(price, instrument) {
431
+ if (price === null || price === undefined || isNaN(price)) return '---';
432
  if (instrument.includes('JPY')) {
433
  return price.toFixed(3);
434
  } else if (instrument.includes('Oil') || instrument.includes('Gold') || instrument.includes('Bitcoin') || instrument.includes('Ethereum') || instrument.includes('Nifty') || instrument.includes('Sensex')) {
 
452
  return `${day}/${month}/${year}, ${hours}:${minutes}:${seconds}`;
453
  }
454
 
455
+ let currentCategory = 'All';
456
  let cachedData = null;
457
 
458
  async function fetchData() {
459
+ const debug = document.getElementById('debugInfo');
460
  try {
461
  // Fetch signals
462
  const signalsRes = await fetch('forex_macd_signals.json');
463
  if (signalsRes.ok) {
464
  cachedData = await signalsRes.json();
465
+ } else {
466
+ throw new Error(`Failed to fetch signals: ${signalsRes.status}`);
467
  }
468
 
469
  // Fetch visitor count
470
+ try {
471
+ const visitorRes = await fetch('/api/visitor-count');
472
+ if (visitorRes.ok) {
473
+ const stats = await visitorRes.json();
474
+ document.getElementById('visitorCount').textContent = stats.unique;
475
+ document.getElementById('activeCount').textContent = stats.active;
476
+ }
477
+ } catch (vErr) {
478
+ console.error('Visitor fetch error:', vErr);
479
  }
480
 
481
  renderDashboard();
482
  } catch (error) {
483
  console.error('Error fetching data:', error);
484
+ debug.style.display = 'block';
485
+ debug.textContent += `Fetch Error: ${error.message}\n`;
486
  }
487
  }
488
 
 
514
  }
515
 
516
  function renderDashboard() {
517
+ try {
518
+ if (!cachedData) return;
519
+ const data = cachedData;
520
+ const container = document.getElementById('dashboard');
521
+ const lastUpdated = document.getElementById('lastUpdated');
522
+
523
+ container.innerHTML = '';
524
+ container.className = 'grid'; // Ensure grid layout
525
+ lastUpdated.textContent = `Last Updated: ${new Date(data.last_updated).toLocaleString()}`;
526
+
527
+ // Filter by category
528
+ let filteredData = data.data;
529
+ if (currentCategory === 'Active') {
530
+ filteredData = data.data.filter(inst => inst.signal !== null);
531
+ } else if (currentCategory !== 'All') {
532
+ filteredData = data.data.filter(inst => inst.category === currentCategory);
533
+ }
534
 
535
+ // Environment detection: Local vs Hugging Face
536
+ const isLocal = window.location.hostname === 'localhost' ||
537
+ window.location.hostname === '127.0.0.1' ||
538
+ window.location.protocol === 'file:';
 
 
 
 
 
539
 
540
+ if (isLocal) {
541
+ // Local Sort: Prioritize signals, then sort everything by recency (signal time or analysis timestamp)
542
+ filteredData.sort((a, b) => {
543
+ const getPriority = (inst) => {
544
+ if (inst.signal) return 2;
545
+ if (inst.overall_status.includes('BUY') || inst.overall_status.includes('SELL')) return 1;
546
+ return 0;
547
+ };
548
+
549
+ const pA = getPriority(a);
550
+ const pB = getPriority(b);
551
+
552
+ if (pA !== pB) return pB - pA;
553
+
554
+ // Within same priority, sort by recency
555
+ const timeA = a.signal ? new Date(a.signal.time).getTime() : new Date(a.timestamp).getTime();
556
+ const timeB = b.signal ? new Date(b.signal.time).getTime() : new Date(b.timestamp).getTime();
557
+
558
+ if (isNaN(timeA)) return 1;
559
+ if (isNaN(timeB)) return -1;
560
+
561
+ return timeB - timeA;
562
+ });
563
+ } else {
564
+ // Original Sort: Signals first (by time descending), then active status, then others
565
+ filteredData.sort((a, b) => {
566
+ const getPriority = (inst) => {
567
+ if (inst.signal) return 2;
568
+ if (inst.overall_status.includes('BUY') || inst.overall_status.includes('SELL')) return 1;
569
+ return 0;
570
+ };
571
+
572
+ const priorityA = getPriority(a);
573
+ const priorityB = getPriority(b);
574
+
575
+ if (priorityA !== priorityB) {
576
+ return priorityB - priorityA;
577
+ }
578
+
579
+ // If both have signals, sort by signal time descending
580
+ if (a.signal && b.signal) {
581
+ const tA = new Date(a.signal.time).getTime();
582
+ const tB = new Date(b.signal.time).getTime();
583
+ if (isNaN(tA)) return 1;
584
+ if (isNaN(tB)) return -1;
585
+ return tB - tA;
586
+ }
587
+
588
+ return 0;
589
+ });
590
+ }
591
+
592
+ filteredData.forEach(inst => {
593
+ try {
594
+ const card = document.createElement('div');
595
+ card.className = 'card';
596
+
597
+ let statusClass = 'status-waiting';
598
+ if (inst.overall_status.includes('BUY')) statusClass = 'status-buy';
599
+ if (inst.overall_status.includes('SELL')) statusClass = 'status-sell';
600
+
601
+ const getTfClass = (bias) => {
602
+ if (!bias) return 'neutral';
603
+ if (bias.includes('BULLISH')) return 'bullish';
604
+ if (bias.includes('BEARISH')) return 'bearish';
605
+ return 'neutral';
606
+ };
607
+
608
+ const getBorderClass = (bias) => {
609
+ if (!bias) return 'border-neutral';
610
+ if (bias.includes('BULLISH')) return 'border-bullish';
611
+ if (bias.includes('BEARISH')) return 'border-bearish';
612
+ return 'border-neutral';
613
+ };
614
+
615
+ let signalHtml = '';
616
+ if (inst.signal) {
617
+ const typeClass = inst.signal.type === 'BUY' ? 'buy' : 'sell';
618
+ const typeColor = inst.signal.type === 'BUY' ? 'bullish' : 'bearish';
619
+ const entryPrice = inst.signal.entry_price || inst.signal.price;
620
+ const isTrailing = inst.signal.current_sl && inst.signal.current_sl !== inst.signal.sl;
621
+
622
+ signalHtml = `
623
+ <div class="signal-panel ${typeClass}">
624
+ <div class="signal-row" style="margin-bottom: 1rem; border-bottom: 1px solid #334155; padding-bottom: 0.5rem;">
625
+ <span class="signal-label">${isActive ? '🔴 ACTIVE SIGNAL' : 'SIGNAL TRIGGERED'}</span>
626
+ <span class="signal-val ${typeColor}" style="font-size: 1.2rem;">${inst.signal.type}</span>
627
+ </div>
628
+ <div class="signal-row">
629
+ <span class="signal-label">Entry Price</span>
630
+ <span class="signal-val">${formatPrice(entryPrice, inst.instrument)}</span>
631
+ </div>
632
+ <div class="signal-row">
633
+ <span class="signal-label">Current LTP</span>
634
+ <span class="signal-val" style="color: var(--accent)">${formatPrice(inst.ltp, inst.instrument)}</span>
635
+ </div>
636
+ <div class="signal-row" style="${isTrailing ? 'opacity: 0.6; font-size: 0.85rem;' : ''}">
637
+ <span class="signal-label">Initial SL</span>
638
+ <span class="signal-val" style="color: var(--bearish)">${formatPrice(inst.signal.sl, inst.instrument)}</span>
639
+ </div>
640
+ ${isTrailing ? `
641
+ <div class="signal-row">
642
+ <span class="signal-label">Trailing SL 🛡️</span>
643
+ <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.current_sl, inst.instrument)}</span>
644
+ </div>` : ''}
645
+
646
+ <div style="margin-top: 0.5rem; border-top: 1px dashed #334155; padding-top: 0.5rem;">
647
+ <div class="signal-row">
648
+ <span class="signal-label">TP 1 (1.5x) ${inst.signal.tp_hits && inst.signal.tp_hits[0] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
649
+ <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp1 || inst.signal.tp, inst.instrument)}</span>
650
+ </div>
651
+ <div class="signal-row">
652
+ <span class="signal-label">TP 2 (3.0x) ${inst.signal.tp_hits && inst.signal.tp_hits[1] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
653
+ <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp2 || 0, inst.instrument)}</span>
654
+ </div>
655
+ <div class="signal-row">
656
+ <span class="signal-label">TP 3 (5.0x) ${inst.signal.tp_hits && inst.signal.tp_hits[2] ? '<span style="color: var(--bullish); font-weight: bold; margin-left: 5px;">✓</span>' : ''}</span>
657
+ <span class="signal-val" style="color: var(--bullish)">${formatPrice(inst.signal.tp3 || 0, inst.instrument)}</span>
658
+ </div>
659
+ </div>
660
+ <div class="signal-row" style="margin-top: 0.5rem; border-top: 1px solid #334155; padding-top: 0.5rem;">
661
+ <span class="signal-label">Signal Time</span>
662
+ <span class="signal-val" style="color: var(--text-secondary); font-size: 0.85rem;">${formatDate(inst.signal.time)}</span>
663
+ </div>
664
  </div>
665
+ `;
666
+ } else {
667
+ signalHtml = `
668
+ <div style="text-align: center; padding: 2rem; color: var(--text-secondary); border: 1px dashed #334155; border-radius: 0.5rem; margin-top: 1rem;">
669
+ Waiting for signal conditions...
670
  </div>
671
+ `;
672
+ }
673
+
674
+ card.innerHTML = `
675
+ <div class="card-header">
676
+ <div>
677
+ <div style="font-size: 2.5rem; margin-bottom: 0.25rem;">${inst.flag || ''}</div>
678
+ <div class="instrument-name">${inst.instrument}</div>
679
+ <div class="current-price">LTP: ${formatPrice(inst.ltp, inst.instrument)}</div>
680
  </div>
681
+ <div class="status-badge ${statusClass}">${inst.overall_status.replace(/_/g, ' ')}</div>
682
  </div>
683
+
684
+ <div class="analysis-grid">
685
+ <div class="tf-box ${getBorderClass(inst.daily.bias)}">
686
+ <div class="tf-label">${inst.daily.label || 'Daily'}</div>
687
+ <div class="tf-value ${getTfClass(inst.daily.bias)}">${inst.daily.bias}</div>
688
+ </div>
689
+
690
+ <div class="tf-box ${getBorderClass(inst.h4.bias)}">
691
+ <div class="tf-label">${inst.h4.label || '4H MOM'}</div>
692
+ <div class="tf-value ${getTfClass(inst.h4.bias)}">${inst.h4.bias}</div>
693
+ </div>
694
+
695
+ <div class="tf-box ${getBorderClass(inst.h1.status)}">
696
+ <div class="tf-label">${inst.h1.label || '1H Entry'}</div>
697
+ <div class="tf-value ${getTfClass(inst.h1.status)}">${inst.h1.status.replace(/_/g, ' ')}</div>
698
+ </div>
699
  </div>
 
 
 
 
 
 
 
 
 
700
 
701
+ ${signalHtml}
702
+ `;
703
+
704
+ container.appendChild(card);
705
+ } catch (cardErr) {
706
+ console.error('Error rendering card:', cardErr, inst);
707
+ }
708
+ });
709
+ } catch (err) {
710
+ console.error('Render error:', err);
711
+ const debug = document.getElementById('debugInfo');
712
+ debug.style.display = 'block';
713
+ debug.textContent += `Render Error: ${err.message}\n`;
714
+ }
715
+ }
716
+
717
+ function getPipSize(instrument) {
718
+ if (instrument.includes('JPY')) return 0.01;
719
+ if (instrument.includes('US Oil') || instrument.includes('Brent') || instrument.includes('Crude Oil')) return 0.01;
720
+ if (instrument.includes('Natural Gas')) return instrument.includes('MCX') ? 0.1 : 0.001;
721
+ if (instrument.includes('Copper')) return 0.05;
722
+ if (instrument.includes('Gold')) return 0.1;
723
+ if (instrument.includes('Silver')) return 0.005;
724
+ if (instrument.includes('Platinum') || instrument.includes('Palladium')) return 0.1;
725
+ if (instrument.includes('Bitcoin')) return 1.0;
726
+ if (instrument.includes('Ethereum')) return 0.1;
727
+ if (instrument.includes('Nifty') || instrument.includes('Sensex')) return 0.05;
728
+ return 0.0001; // Default for Forex
 
 
 
 
729
  }
730
 
731
  async function renderHistory() {
732
  const container = document.getElementById('dashboard');
733
  container.innerHTML = '<div style="grid-column: 1/-1; text-align: center; padding: 4rem;">Loading history...</div>';
734
+ container.className = 'history-mode';
735
 
736
  try {
737
  const res = await fetch('signal_history.json');
 
743
  return;
744
  }
745
 
746
+ const isLocal = window.location.hostname === 'localhost' ||
747
+ window.location.hostname === '127.0.0.1' ||
748
+ window.location.protocol === 'file:';
749
+
750
+ if (isLocal) {
751
+ // Group by instrument and entry_time to show single line for closed trades
752
+ const trades = {};
753
+ history.forEach(item => {
754
+ const key = `${item.instrument}_${item.entry_time}`;
755
+ if (!trades[key]) {
756
+ trades[key] = {
757
+ instrument: item.instrument,
758
+ type: item.type,
759
+ entry_time: item.entry_time,
760
+ entry_price: item.entry_price || item.price,
761
+ exit_time: null,
762
+ exit_price: null,
763
+ event: item.event,
764
+ pips: 0,
765
+ last_update: new Date(item.time),
766
+ initial_sl: item.initial_sl
767
+ };
768
+ }
769
+
770
+ const itemTime = new Date(item.time);
771
+ if (itemTime > trades[key].last_update) {
772
+ trades[key].last_update = itemTime;
773
+ trades[key].event = item.event;
774
+ }
775
+
776
+ if (item.event.includes('TP') || item.event.includes('SL')) {
777
+ trades[key].exit_time = item.time;
778
+ trades[key].exit_price = item.price;
779
+
780
+ if (!trades[key].tp_progress) trades[key].tp_progress = new Set();
781
+ if (item.event.includes('TP')) {
782
+ trades[key].tp_progress.add(item.event);
783
+ }
784
+
785
+ const pipSize = getPipSize(item.instrument);
786
+ const diff = item.type === 'BUY' ? (item.price - trades[key].entry_price) : (trades[key].entry_price - item.price);
787
+ trades[key].pips = diff / pipSize;
788
+ }
789
+ });
790
+
791
+ const sortedTrades = Object.values(trades).sort((a, b) => b.last_update - a.last_update);
792
+
793
+ let html = `
794
+ <div class="history-table-container" style="grid-column: 1/-1;">
795
+ <table class="history-table">
796
+ <thead>
797
+ <tr>
798
+ <th>Instrument</th>
799
+ <th>Type</th>
800
+ <th>Entry Time</th>
801
+ <th>Exit Time</th>
802
+ <th>Entry</th>
803
+ <th>Exit</th>
804
+ <th>Result</th>
805
+ </tr>
806
+ </thead>
807
+ <tbody>
808
+ `;
809
+
810
+ sortedTrades.forEach(trade => {
811
+ let eventClass = 'event-entry';
812
+ if (trade.event.includes('TP')) eventClass = 'event-tp';
813
+ if (trade.event.includes('SL')) eventClass = 'event-sl';
814
+
815
+ const pipsFixed = trade.pips.toFixed(1);
816
+ const pipsClass = trade.pips >= 0 ? 'bullish' : 'bearish';
817
+
818
+ const tpIcons = Array.from(trade.tp_progress || []).sort().map(tp => {
819
+ const num = tp.match(/\d/);
820
+ return `<span title="${tp}" style="color: var(--bullish); font-weight: bold; margin-right: 4px; background: rgba(16, 185, 129, 0.1); padding: 2px 4px; border-radius: 4px; font-size: 0.65rem;">TP${num}✓</span>`;
821
+ }).join('');
822
+
823
+ let displayEvent = trade.event.replace('_', ' ');
824
+ let slDetails = '';
825
+ if (displayEvent.includes('SL HIT')) {
826
+ const isTrailing = trade.event === 'TRAIL_SL_HIT' || trade.event === 'TRAILING_SL_HIT' || (trade.tp_progress && trade.tp_progress.size > 0);
827
+ if (isTrailing) {
828
+ displayEvent = 'TRAIL SL HIT';
829
+ slDetails = `<div style="font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px;">
830
+ Init SL: ${formatPrice(trade.initial_sl, trade.instrument)}<br>
831
+ Exit: ${formatPrice(trade.exit_price, trade.instrument)}
832
+ </div>`;
833
+ } else {
834
+ slDetails = `<div style="font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px;">
835
+ SL: ${formatPrice(trade.initial_sl, trade.instrument)}
836
+ </div>`;
837
+ }
838
+ }
839
+
840
+ html += `
841
+ <tr>
842
+ <td style="font-weight: 700;">${trade.instrument}</td>
843
+ <td class="${trade.type === 'BUY' ? 'bullish' : 'bearish'}" style="font-weight: 700;">${trade.type}</td>
844
+ <td style="color: var(--text-secondary); font-size: 0.85rem;">${formatDate(trade.entry_time)}</td>
845
+ <td style="color: var(--text-secondary); font-size: 0.85rem;">${trade.exit_time ? formatDate(trade.exit_time) : '---'}</td>
846
+ <td style="font-family: monospace;">${formatPrice(trade.entry_price, trade.instrument)}</td>
847
+ <td style="font-family: monospace;">${trade.exit_price ? formatPrice(trade.exit_price, trade.instrument) : '---'}</td>
848
+ <td>
849
+ <div style="display: flex; flex-direction: column; gap: 4px;">
850
+ <span class="event-badge ${eventClass}">${displayEvent}</span>
851
+ ${slDetails}
852
+ <div style="display: flex; flex-wrap: wrap; gap: 2px;">${tpIcons}</div>
853
+ </div>
854
+ </td>
855
+ </tr>
856
+ `;
857
+ });
858
+
859
+ html += `</tbody></table></div>`;
860
+ container.innerHTML = html;
861
+ } else {
862
+ // Original multi-line history for non-local
863
+ history.sort((a, b) => new Date(b.time) - new Date(a.time));
864
+
865
+ let html = `
866
+ <div class="history-table-container" style="grid-column: 1/-1;">
867
+ <table class="history-table">
868
+ <thead>
869
+ <tr>
870
+ <th>Time (IST)</th>
871
+ <th>Instrument</th>
872
+ <th>Event</th>
873
+ <th>Price</th>
874
+ <th>Type</th>
875
+ </tr>
876
+ </thead>
877
+ <tbody>
878
  `;
 
879
 
880
+ history.forEach(item => {
881
+ let eventClass = 'event-entry';
882
+ if (item.event.includes('TP')) eventClass = 'event-tp';
883
+ if (item.event.includes('SL')) eventClass = 'event-sl';
884
+
885
+ html += `
886
+ <tr>
887
+ <td style="color: var(--text-secondary); font-size: 0.9rem;">${item.time}</td>
888
+ <td style="font-weight: 700;">${item.instrument}</td>
889
+ <td><span class="event-badge ${eventClass}">${item.event.replace('_', ' ')}</span></td>
890
+ <td style="font-family: monospace; font-weight: 600;">${formatPrice(item.price, item.instrument)}</td>
891
+ <td class="${item.type === 'BUY' ? 'bullish' : 'bearish'}" style="font-weight: 700;">${item.type}</td>
892
+ </tr>
893
+ `;
894
+ });
895
+
896
+ html += `</tbody></table></div>`;
897
+ container.innerHTML = html;
898
+ }
899
  } catch (error) {
900
  container.innerHTML = `<div style="grid-column: 1/-1; text-align: center; padding: 4rem; color: var(--bearish);">Error loading history: ${error.message}</div>`;
901
  }
902
  }
903
 
904
 
905
+ async function sendHeartbeat() {
906
+ try {
907
+ await fetch('/api/heartbeat');
908
+ } catch (error) {
909
+ console.error('Heartbeat failed:', error);
910
+ }
911
+ }
912
+
913
  fetchData();
914
  setInterval(fetchData, 30000);
915
+ setInterval(sendHeartbeat, 30000); // Send heartbeat every 30 seconds
916
 
917
  // Feedback Submission
918
  document.getElementById('feedbackForm').addEventListener('submit', async (e) => {
forex_macd_signals.json CHANGED
@@ -1,518 +1,1019 @@
1
  {
2
- "last_updated": "2025-12-21T21:00:07.110951",
3
  "data": [
4
  {
5
  "instrument": "US Oil (WTI)",
6
  "flag": "\ud83d\udee2\ufe0f",
7
- "ltp": 56.52000045776367,
8
  "daily": {
9
- "macd_line": -0.921370485909712,
10
  "bias": "BEARISH",
11
  "label": "Daily"
12
  },
13
  "h4": {
14
- "histogram": 0.11812595556808214,
15
  "bias": "BULLISH",
16
  "label": "4H MOM"
17
  },
18
  "h1": {
19
- "histogram": 0.05952792903421146,
20
  "status": "BULLISH_MOM",
21
- "close": 56.560001373291016,
22
  "label": "1H Entry",
23
- "ema_200": null,
24
- "rsi": null
25
  },
26
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
27
  "signal": null,
28
  "category": "Metals/Energy",
29
- "timestamp": "2025-12-21T20:59:58.688715"
30
  },
31
  {
32
  "instrument": "MCX Crude Oil",
33
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83d\udee2\ufe0f",
34
- "ltp": 5101.257763483794,
35
  "daily": {
36
- "macd_line": -0.921370485909712,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  "bias": "BEARISH",
38
- "label": "Daily"
39
  },
40
  "h4": {
41
- "histogram": 0.11812595556808214,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  "bias": "BULLISH",
43
- "label": "4H MOM"
 
 
 
 
 
44
  },
45
  "h1": {
46
- "histogram": 0.05952792903421146,
47
  "status": "BULLISH_MOM",
48
- "close": 56.560001373291016,
49
- "label": "1H Entry",
50
- "ema_200": null,
51
- "rsi": null
52
  },
53
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
54
  "signal": null,
55
- "category": "Metals/Energy",
56
- "timestamp": "2025-12-21T20:59:59.143408"
57
  },
58
  {
59
  "instrument": "Gold",
60
  "flag": "\ud83e\udd47",
61
- "ltp": 4387.2998046875,
62
  "daily": {
63
- "macd_line": 65.46457996455501,
64
  "bias": "BULLISH",
65
  "label": "Daily"
66
  },
67
  "h4": {
68
- "histogram": -1.0306511432297825,
69
- "bias": "BEARISH",
70
  "label": "4H MOM"
71
  },
72
  "h1": {
73
- "histogram": 1.897835679582358,
74
  "status": "BULLISH_MOM",
75
- "close": 4370.2998046875,
76
  "label": "1H Entry",
77
- "ema_200": null,
78
- "rsi": null
79
  },
80
- "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
81
  "signal": null,
82
  "category": "Metals/Energy",
83
- "timestamp": "2025-12-21T20:59:59.559569"
84
  },
85
  {
86
  "instrument": "Silver",
87
  "flag": "\ud83e\udd48",
88
- "ltp": 67.48899841308594,
89
  "daily": {
90
- "macd_line": 3.632932654766371,
91
  "bias": "BULLISH",
92
  "label": "Daily"
93
  },
94
  "h4": {
95
- "histogram": -0.0021148327071845996,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  "bias": "BEARISH",
 
 
 
 
 
97
  "label": "4H MOM"
98
  },
99
  "h1": {
100
- "histogram": 0.17755443575563368,
101
  "status": "BULLISH_MOM",
102
- "close": 67.42500305175781,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  "label": "1H Entry",
104
- "ema_200": null,
105
- "rsi": null
106
  },
107
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
108
  "signal": null,
109
  "category": "Metals/Energy",
110
- "timestamp": "2025-12-21T20:59:59.932070"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  },
112
  {
113
  "instrument": "EUR/USD",
114
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddfa\ud83c\uddf8",
115
- "ltp": 1.1715089082717896,
116
  "daily": {
117
- "macd_line": 0.004053079873403975,
118
  "bias": "BULLISH",
119
  "label": "Daily"
120
  },
121
  "h4": {
122
- "histogram": -0.00034210268859049685,
123
- "bias": "BEARISH",
124
  "label": "4H MOM"
125
  },
126
  "h1": {
127
- "histogram": 1.327879082113658e-05,
128
  "status": "BULLISH_MOM",
129
- "close": 1.1712344884872437,
130
  "label": "1H Entry",
131
- "ema_200": null,
132
- "rsi": null
133
  },
134
- "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
135
  "signal": null,
136
  "category": "Forex",
137
- "timestamp": "2025-12-21T21:00:00.392128"
138
  },
139
  {
140
  "instrument": "GBP/USD",
141
  "flag": "\ud83c\uddec\ud83c\udde7\ud83c\uddfa\ud83c\uddf8",
142
- "ltp": 1.3380253314971924,
143
  "daily": {
144
- "macd_line": 0.004922686709441404,
145
  "bias": "BULLISH",
146
  "label": "Daily"
147
  },
148
  "h4": {
149
- "histogram": -8.724157137204251e-05,
150
- "bias": "BEARISH",
151
  "label": "4H MOM"
152
  },
153
  "h1": {
154
- "histogram": 5.477673049422084e-05,
155
  "status": "BULLISH_MOM",
156
- "close": 1.3375420570373535,
157
  "label": "1H Entry",
158
- "ema_200": null,
159
- "rsi": null
160
  },
161
- "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
162
  "signal": null,
163
  "category": "Forex",
164
- "timestamp": "2025-12-21T21:00:00.864056"
165
  },
166
  {
167
  "instrument": "USD/JPY",
168
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\uddef\ud83c\uddf5",
169
- "ltp": 157.75,
170
  "daily": {
171
- "macd_line": 0.2675408441672289,
172
  "bias": "BULLISH",
173
  "label": "Daily"
174
  },
175
  "h4": {
176
- "histogram": 0.23724214795129295,
177
- "bias": "BULLISH",
178
  "label": "4H MOM"
179
  },
180
  "h1": {
181
- "histogram": 0.027470278853412133,
182
- "status": "BULLISH_MOM",
183
- "close": 157.73399353027344,
184
  "label": "1H Entry",
185
- "ema_200": null,
186
- "rsi": null
187
  },
188
- "overall_status": "LOOKING_FOR_BUY",
189
  "signal": null,
190
  "category": "Forex",
191
- "timestamp": "2025-12-21T21:00:01.264226"
192
  },
193
  {
194
  "instrument": "AUD/USD",
195
  "flag": "\ud83c\udde6\ud83c\uddfa\ud83c\uddfa\ud83c\uddf8",
196
- "ltp": 0.6614194512367249,
197
  "daily": {
198
- "macd_line": 0.0028103988113608036,
199
  "bias": "BULLISH",
200
  "label": "Daily"
201
  },
202
  "h4": {
203
- "histogram": 0.00012949863961539388,
204
  "bias": "BULLISH",
205
  "label": "4H MOM"
206
  },
207
  "h1": {
208
- "histogram": 3.9533165334320334e-05,
209
  "status": "BULLISH_MOM",
210
- "close": 0.6613319516181946,
211
  "label": "1H Entry",
212
- "ema_200": null,
213
- "rsi": null
214
  },
215
  "overall_status": "LOOKING_FOR_BUY",
216
  "signal": null,
217
  "category": "Forex",
218
- "timestamp": "2025-12-21T21:00:01.903503"
219
  },
220
  {
221
  "instrument": "USD/CHF",
222
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\udde8\ud83c\udded",
223
- "ltp": 0.7948600053787231,
224
  "daily": {
225
- "macd_line": -0.001578707536308177,
226
  "bias": "BEARISH",
227
  "label": "Daily"
228
  },
229
  "h4": {
230
- "histogram": 0.00016069035412736774,
231
- "bias": "BULLISH",
232
  "label": "4H MOM"
233
  },
234
  "h1": {
235
- "histogram": -9.26052462190354e-06,
236
  "status": "BEARISH_MOM",
237
- "close": 0.79544997215271,
238
  "label": "1H Entry",
239
- "ema_200": null,
240
- "rsi": null
241
  },
242
- "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
243
  "signal": null,
244
  "category": "Forex",
245
- "timestamp": "2025-12-21T21:00:02.499339"
246
  },
247
  {
248
  "instrument": "NZD/USD",
249
  "flag": "\ud83c\uddf3\ud83c\uddff\ud83c\uddfa\ud83c\uddf8",
250
- "ltp": 0.5758046507835388,
251
  "daily": {
252
- "macd_line": 0.002467036276907031,
253
- "bias": "BULLISH",
254
  "label": "Daily"
255
  },
256
  "h4": {
257
- "histogram": -0.00012551366013951104,
258
- "bias": "BEARISH",
259
  "label": "4H MOM"
260
  },
261
  "h1": {
262
- "histogram": 0.00014031991303617701,
263
  "status": "BULLISH_MOM",
264
- "close": 0.5758046507835388,
265
  "label": "1H Entry",
266
- "ema_200": null,
267
- "rsi": null
268
  },
269
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
270
  "signal": null,
271
  "category": "Forex",
272
- "timestamp": "2025-12-21T21:00:02.941646"
273
  },
274
  {
275
  "instrument": "USD/CAD",
276
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\udde8\ud83c\udde6",
277
- "ltp": 1.3798999786376953,
278
  "daily": {
279
- "macd_line": -0.006753778294513291,
280
  "bias": "BEARISH",
281
  "label": "Daily"
282
  },
283
  "h4": {
284
- "histogram": 0.0001632710385942814,
285
- "bias": "BULLISH",
286
  "label": "4H MOM"
287
  },
288
  "h1": {
289
- "histogram": 0.00011799008488566772,
290
- "status": "BULLISH_MOM",
291
- "close": 1.3799999952316284,
292
  "label": "1H Entry",
293
- "ema_200": null,
294
- "rsi": null
295
  },
296
- "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
297
  "signal": null,
298
  "category": "Forex",
299
- "timestamp": "2025-12-21T21:00:03.341737"
300
  },
301
  {
302
  "instrument": "EUR/GBP",
303
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddec\ud83c\udde7",
304
- "ltp": 0.8753600120544434,
305
  "daily": {
306
- "macd_line": -0.00022569070550482184,
307
- "bias": "BEARISH",
308
  "label": "Daily"
309
  },
310
  "h4": {
311
- "histogram": -0.00019459295801397056,
312
- "bias": "BEARISH",
313
  "label": "4H MOM"
314
  },
315
  "h1": {
316
- "histogram": -5.631180450727178e-05,
317
- "status": "BEARISH_MOM",
318
- "close": 0.8748900294303894,
319
  "label": "1H Entry",
320
- "ema_200": null,
321
- "rsi": null
322
  },
323
- "overall_status": "LOOKING_FOR_SELL",
324
  "signal": null,
325
  "category": "Forex",
326
- "timestamp": "2025-12-21T21:00:03.739162"
327
  },
328
  {
329
  "instrument": "EUR/JPY",
330
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddef\ud83c\uddf5",
331
- "ltp": 184.76600646972656,
332
  "daily": {
333
- "macd_line": 0.9606312446892673,
334
  "bias": "BULLISH",
335
  "label": "Daily"
336
  },
337
  "h4": {
338
- "histogram": 0.22462706552126183,
339
- "bias": "BULLISH",
340
  "label": "4H MOM"
341
  },
342
  "h1": {
343
- "histogram": 0.030303625108307253,
344
- "status": "BULLISH_MOM",
345
- "close": 184.63499450683594,
346
  "label": "1H Entry",
347
- "ema_200": null,
348
- "rsi": null
349
  },
350
- "overall_status": "LOOKING_FOR_BUY",
351
  "signal": null,
352
  "category": "Forex",
353
- "timestamp": "2025-12-21T21:00:04.204626"
354
  },
355
  {
356
  "instrument": "GBP/JPY",
357
  "flag": "\ud83c\uddec\ud83c\udde7\ud83c\uddef\ud83c\uddf5",
358
- "ltp": 211.06500244140625,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  "daily": {
360
- "macd_line": 1.1230835582284158,
361
  "bias": "BULLISH",
362
  "label": "Daily"
363
  },
364
  "h4": {
365
- "histogram": 0.3042210603670874,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  "bias": "BULLISH",
367
  "label": "4H MOM"
368
  },
369
  "h1": {
370
- "histogram": 0.045202377520346726,
371
  "status": "BULLISH_MOM",
372
- "close": 210.9709930419922,
373
  "label": "1H Entry",
374
- "ema_200": null,
375
- "rsi": null
376
  },
377
- "overall_status": "LOOKING_FOR_BUY",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  "signal": null,
379
  "category": "Forex",
380
- "timestamp": "2025-12-21T21:00:04.650209"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  },
382
  {
383
  "instrument": "Bitcoin",
384
  "flag": "\u20bf",
385
- "ltp": 87844.3359375,
386
  "daily": {
387
- "macd_line": 185.5052688493306,
388
  "bias": "BULLISH",
389
  "label": "4H Trend"
390
  },
391
  "h4": {
392
- "histogram": -41.20851294914915,
393
- "bias": "BEARISH",
394
  "label": "1H MOM"
395
  },
396
  "h1": {
397
- "histogram": -64.94550216764277,
398
  "status": "BEARISH_MOM",
399
- "close": 87991.171875,
400
  "label": "15m Entry",
401
- "ema_200": 88040.35603243101,
402
- "rsi": 33.353819441459876
403
  },
404
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
405
  "signal": null,
406
- "category": "Cryptos",
407
- "timestamp": "2025-12-21T21:00:05.388711"
408
  },
409
  {
410
  "instrument": "Ethereum",
411
  "flag": "\u039e",
412
- "ltp": 2964.192138671875,
413
  "daily": {
414
- "macd_line": 7.462150142112932,
415
  "bias": "BULLISH",
416
  "label": "4H Trend"
417
  },
418
  "h4": {
419
- "histogram": -2.140901807613732,
420
- "bias": "BEARISH",
421
  "label": "1H MOM"
422
  },
423
  "h1": {
424
- "histogram": -2.093561241216557,
425
  "status": "BEARISH_MOM",
426
- "close": 2968.083740234375,
427
  "label": "15m Entry",
428
- "ema_200": 2967.8526343872177,
429
- "rsi": 33.07236844042316
430
  },
431
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
432
  "signal": null,
433
- "category": "Cryptos",
434
- "timestamp": "2025-12-21T21:00:05.830158"
435
  },
436
  {
437
- "instrument": "Nifty 50",
438
- "flag": "\ud83c\uddee\ud83c\uddf3",
439
- "ltp": 25961.400390625,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  "daily": {
441
- "macd_line": -35.49459686571208,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  "bias": "BEARISH",
443
  "label": "4H Trend"
444
  },
445
  "h4": {
446
- "histogram": 19.088422835688057,
447
  "bias": "BULLISH",
448
  "label": "1H MOM"
449
  },
450
  "h1": {
451
- "histogram": -1.8679582795188487,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  "status": "BEARISH_MOM",
453
- "close": 25969.849609375,
454
  "label": "15m Entry",
455
- "ema_200": 25913.20842516446,
456
- "rsi": 66.50071935874305
457
  },
458
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
459
  "signal": null,
460
  "category": "Intraday IndianMarket",
461
- "timestamp": "2025-12-21T21:00:06.167642"
462
  },
463
  {
464
  "instrument": "Bank Nifty",
465
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83c\udfe6",
466
- "ltp": 59046.80078125,
467
  "daily": {
468
- "macd_line": -57.55989884478913,
469
- "bias": "BEARISH",
470
  "label": "4H Trend"
471
  },
472
  "h4": {
473
- "histogram": 18.40373357400933,
474
- "bias": "BULLISH",
475
  "label": "1H MOM"
476
  },
477
  "h1": {
478
- "histogram": 8.435588936110236,
479
- "status": "BULLISH_MOM",
480
- "close": 59080.0,
481
  "label": "15m Entry",
482
- "ema_200": 59125.27261303664,
483
- "rsi": 64.12515014585597
484
  },
485
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
486
  "signal": null,
487
  "category": "Intraday IndianMarket",
488
- "timestamp": "2025-12-21T21:00:06.635478"
489
  },
490
  {
491
  "instrument": "Sensex",
492
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83d\udcc8",
493
- "ltp": 84929.421875,
494
  "daily": {
495
- "macd_line": -110.41960058339464,
496
- "bias": "BEARISH",
497
  "label": "4H Trend"
498
  },
499
  "h4": {
500
- "histogram": 55.13300615232581,
501
- "bias": "BULLISH",
502
  "label": "1H MOM"
503
  },
504
  "h1": {
505
- "histogram": -7.550559205249968,
506
  "status": "BEARISH_MOM",
507
- "close": 84939.0625,
508
  "label": "15m Entry",
509
- "ema_200": 84835.96058809933,
510
- "rsi": 59.14613567330409
511
  },
512
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
513
  "signal": null,
514
  "category": "Intraday IndianMarket",
515
- "timestamp": "2025-12-21T21:00:07.110893"
516
  }
517
  ]
518
  }
 
1
  {
2
+ "last_updated": "2025-12-22T22:54:55.313061",
3
  "data": [
4
  {
5
  "instrument": "US Oil (WTI)",
6
  "flag": "\ud83d\udee2\ufe0f",
7
+ "ltp": 57.88999938964844,
8
  "daily": {
9
+ "macd_line": -0.9133803656579147,
10
  "bias": "BEARISH",
11
  "label": "Daily"
12
  },
13
  "h4": {
14
+ "histogram": 0.23380374484009533,
15
  "bias": "BULLISH",
16
  "label": "4H MOM"
17
  },
18
  "h1": {
19
+ "histogram": 0.038329144246467994,
20
  "status": "BULLISH_MOM",
21
+ "close": 57.810001373291016,
22
  "label": "1H Entry",
23
+ "ema_200": 57.015335036935326,
24
+ "rsi": 70.91828790745109
25
  },
26
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
27
  "signal": null,
28
  "category": "Metals/Energy",
29
+ "timestamp": "2025-12-22T22:54:37.849540"
30
  },
31
  {
32
  "instrument": "MCX Crude Oil",
33
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83d\udee2\ufe0f",
34
+ "ltp": 5183.354881950072,
35
  "daily": {
36
+ "macd_line": 0.1923985854553294,
37
+ "bias": "NEUTRAL",
38
+ "label": "4H Trend"
39
+ },
40
+ "h4": {
41
+ "histogram": 0.038329144246467994,
42
+ "bias": "NEUTRAL",
43
+ "label": "1H MOM"
44
+ },
45
+ "h1": {
46
+ "histogram": -0.03675118708906967,
47
+ "status": "BEARISH_MOM",
48
+ "close": 57.810001373291016,
49
+ "label": "15m Entry",
50
+ "ema_200": 56.78483431555293,
51
+ "rsi": 50.84747406499834
52
+ },
53
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
54
+ "signal": null,
55
+ "category": "Intraday IndianMarket",
56
+ "timestamp": "2025-12-22T22:54:38.173427"
57
+ },
58
+ {
59
+ "instrument": "MCX Natural Gas",
60
+ "flag": "\ud83c\uddee\ud83c\uddf3\ud83d\udd25",
61
+ "ltp": 346.7806734326132,
62
+ "daily": {
63
+ "macd_line": -0.028044327140253067,
64
  "bias": "BEARISH",
65
+ "label": "4H Trend"
66
  },
67
  "h4": {
68
+ "histogram": -0.030471815031868,
69
+ "bias": "BEARISH",
70
+ "label": "1H MOM"
71
+ },
72
+ "h1": {
73
+ "histogram": -0.0013190409794527208,
74
+ "status": "BEARISH_MOM",
75
+ "close": 3.874000072479248,
76
+ "label": "15m Entry",
77
+ "ema_200": 4.001600112237355,
78
+ "rsi": 22.327094479499053
79
+ },
80
+ "overall_status": "LOOKING_FOR_SELL",
81
+ "signal": null,
82
+ "category": "Intraday IndianMarket",
83
+ "timestamp": "2025-12-22T22:54:38.646344"
84
+ },
85
+ {
86
+ "instrument": "MCX Copper",
87
+ "flag": "\ud83c\uddee\ud83c\uddf3\ud83e\uddf1",
88
+ "ltp": 1115.2291898782807,
89
+ "daily": {
90
+ "macd_line": 0.029413881398823172,
91
  "bias": "BULLISH",
92
+ "label": "4H Trend"
93
+ },
94
+ "h4": {
95
+ "histogram": -0.0045558854852075815,
96
+ "bias": "NEUTRAL",
97
+ "label": "1H MOM"
98
  },
99
  "h1": {
100
+ "histogram": 0.0010070254883969313,
101
  "status": "BULLISH_MOM",
102
+ "close": 5.505000114440918,
103
+ "label": "15m Entry",
104
+ "ema_200": 5.487830857801455,
105
+ "rsi": 49.18052436018365
106
  },
107
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
108
  "signal": null,
109
+ "category": "Intraday IndianMarket",
110
+ "timestamp": "2025-12-22T22:54:39.229393"
111
  },
112
  {
113
  "instrument": "Gold",
114
  "flag": "\ud83e\udd47",
115
+ "ltp": 4476.2001953125,
116
  "daily": {
117
+ "macd_line": 69.3898586004716,
118
  "bias": "BULLISH",
119
  "label": "Daily"
120
  },
121
  "h4": {
122
+ "histogram": 8.947282184218338,
123
+ "bias": "BULLISH",
124
  "label": "4H MOM"
125
  },
126
  "h1": {
127
+ "histogram": 1.9046787489640877,
128
  "status": "BULLISH_MOM",
129
+ "close": 4474.0,
130
  "label": "1H Entry",
131
+ "ema_200": 4341.34566623906,
132
+ "rsi": 81.40296121493549
133
  },
134
+ "overall_status": "LOOKING_FOR_BUY",
135
  "signal": null,
136
  "category": "Metals/Energy",
137
+ "timestamp": "2025-12-22T22:54:39.763428"
138
  },
139
  {
140
  "instrument": "Silver",
141
  "flag": "\ud83e\udd48",
142
+ "ltp": 68.66500091552734,
143
  "daily": {
144
+ "macd_line": 3.8276361786943625,
145
  "bias": "BULLISH",
146
  "label": "Daily"
147
  },
148
  "h4": {
149
+ "histogram": 0.16068711322599039,
150
+ "bias": "NEUTRAL",
151
+ "label": "4H MOM"
152
+ },
153
+ "h1": {
154
+ "histogram": -0.11472256187741237,
155
+ "status": "BEARISH_MOM",
156
+ "close": 68.7300033569336,
157
+ "label": "1H Entry",
158
+ "ema_200": 64.54522780902155,
159
+ "rsi": 45.16135717746051
160
+ },
161
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
162
+ "signal": null,
163
+ "category": "Metals/Energy",
164
+ "timestamp": "2025-12-22T22:54:40.302619"
165
+ },
166
+ {
167
+ "instrument": "Brent Crude Oil",
168
+ "flag": "\ud83c\uddec\ud83c\udde7\ud83d\udee2\ufe0f",
169
+ "ltp": 61.91999816894531,
170
+ "daily": {
171
+ "macd_line": -1.0181880219831143,
172
  "bias": "BEARISH",
173
+ "label": "Daily"
174
+ },
175
+ "h4": {
176
+ "histogram": 0.24816392557534356,
177
+ "bias": "BULLISH",
178
  "label": "4H MOM"
179
  },
180
  "h1": {
181
+ "histogram": 0.039503401442592234,
182
  "status": "BULLISH_MOM",
183
+ "close": 61.86000061035156,
184
+ "label": "1H Entry",
185
+ "ema_200": 60.821201704569084,
186
+ "rsi": 72.50003814697266
187
+ },
188
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
189
+ "signal": null,
190
+ "category": "Metals/Energy",
191
+ "timestamp": "2025-12-22T22:54:40.723207"
192
+ },
193
+ {
194
+ "instrument": "Natural Gas",
195
+ "flag": "\ud83d\udd25",
196
+ "ltp": 3.872999906539917,
197
+ "daily": {
198
+ "macd_line": -0.0805475301393841,
199
+ "bias": "NEUTRAL",
200
+ "label": "Daily"
201
+ },
202
+ "h4": {
203
+ "histogram": 0.012851115477583476,
204
+ "bias": "NEUTRAL",
205
+ "label": "4H MOM"
206
+ },
207
+ "h1": {
208
+ "histogram": -0.030471815031868,
209
+ "status": "BEARISH_MOM",
210
+ "close": 3.874000072479248,
211
  "label": "1H Entry",
212
+ "ema_200": 4.166474399538803,
213
+ "rsi": 31.968850415628324
214
  },
215
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
216
  "signal": null,
217
  "category": "Metals/Energy",
218
+ "timestamp": "2025-12-22T22:54:40.970284"
219
+ },
220
+ {
221
+ "instrument": "Platinum",
222
+ "flag": "\ud83d\udc8d",
223
+ "ltp": 2100.89990234375,
224
+ "daily": {
225
+ "macd_line": 93.84412434535443,
226
+ "bias": "BULLISH",
227
+ "label": "Daily"
228
+ },
229
+ "h4": {
230
+ "histogram": 7.5334666183685925,
231
+ "bias": "NEUTRAL",
232
+ "label": "4H MOM"
233
+ },
234
+ "h1": {
235
+ "histogram": -2.8669319945815914,
236
+ "status": "BEARISH_MOM",
237
+ "close": 2106.60009765625,
238
+ "label": "1H Entry",
239
+ "ema_200": 1888.595115657333,
240
+ "rsi": 54.89618650207193
241
+ },
242
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
243
+ "signal": null,
244
+ "category": "Metals/Energy",
245
+ "timestamp": "2025-12-22T22:54:41.352482"
246
+ },
247
+ {
248
+ "instrument": "Palladium",
249
+ "flag": "\ud83d\udc8e",
250
+ "ltp": 1833.5,
251
+ "daily": {
252
+ "macd_line": 70.62526826594285,
253
+ "bias": "BULLISH",
254
+ "label": "Daily"
255
+ },
256
+ "h4": {
257
+ "histogram": 0.6885049333278559,
258
+ "bias": "NEUTRAL",
259
+ "label": "4H MOM"
260
+ },
261
+ "h1": {
262
+ "histogram": -6.8251465663618625,
263
+ "status": "BEARISH_MOM",
264
+ "close": 1834.0,
265
+ "label": "1H Entry",
266
+ "ema_200": 1686.7493334605265,
267
+ "rsi": 31.152647975077883
268
+ },
269
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
270
+ "signal": null,
271
+ "category": "Metals/Energy",
272
+ "timestamp": "2025-12-22T22:54:41.741187"
273
  },
274
  {
275
  "instrument": "EUR/USD",
276
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddfa\ud83c\uddf8",
277
+ "ltp": 1.1757789850234985,
278
  "daily": {
279
+ "macd_line": 0.004008202222379742,
280
  "bias": "BULLISH",
281
  "label": "Daily"
282
  },
283
  "h4": {
284
+ "histogram": 0.0002462430927338669,
285
+ "bias": "BULLISH",
286
  "label": "4H MOM"
287
  },
288
  "h1": {
289
+ "histogram": 0.00038653794623938606,
290
  "status": "BULLISH_MOM",
291
+ "close": 1.175364375114441,
292
  "label": "1H Entry",
293
+ "ema_200": 1.172027145565991,
294
+ "rsi": 69.97939748447607
295
  },
296
+ "overall_status": "LOOKING_FOR_BUY",
297
  "signal": null,
298
  "category": "Forex",
299
+ "timestamp": "2025-12-22T22:54:42.239228"
300
  },
301
  {
302
  "instrument": "GBP/USD",
303
  "flag": "\ud83c\uddec\ud83c\udde7\ud83c\uddfa\ud83c\uddf8",
304
+ "ltp": 1.3465473651885986,
305
  "daily": {
306
+ "macd_line": 0.004882504734861071,
307
  "bias": "BULLISH",
308
  "label": "Daily"
309
  },
310
  "h4": {
311
+ "histogram": 0.0007444111658373074,
312
+ "bias": "BULLISH",
313
  "label": "4H MOM"
314
  },
315
  "h1": {
316
+ "histogram": 0.00045502237315788287,
317
  "status": "BULLISH_MOM",
318
+ "close": 1.3456052541732788,
319
  "label": "1H Entry",
320
+ "ema_200": 1.3373477911460816,
321
+ "rsi": 90.13036798150205
322
  },
323
+ "overall_status": "LOOKING_FOR_BUY",
324
  "signal": null,
325
  "category": "Forex",
326
+ "timestamp": "2025-12-22T22:54:42.755644"
327
  },
328
  {
329
  "instrument": "USD/JPY",
330
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\uddef\ud83c\uddf5",
331
+ "ltp": 156.86300659179688,
332
  "daily": {
333
+ "macd_line": 0.27184673302775764,
334
  "bias": "BULLISH",
335
  "label": "Daily"
336
  },
337
  "h4": {
338
+ "histogram": 0.09228329891381504,
339
+ "bias": "NEUTRAL",
340
  "label": "4H MOM"
341
  },
342
  "h1": {
343
+ "histogram": -0.10857389204809065,
344
+ "status": "BEARISH_MOM",
345
+ "close": 156.927001953125,
346
  "label": "1H Entry",
347
+ "ema_200": 156.0507918652679,
348
+ "rsi": 25.9767545820295
349
  },
350
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
351
  "signal": null,
352
  "category": "Forex",
353
+ "timestamp": "2025-12-22T22:54:43.251104"
354
  },
355
  {
356
  "instrument": "AUD/USD",
357
  "flag": "\ud83c\udde6\ud83c\uddfa\ud83c\uddfa\ud83c\uddf8",
358
+ "ltp": 0.6657789945602417,
359
  "daily": {
360
+ "macd_line": 0.002817797259040855,
361
  "bias": "BULLISH",
362
  "label": "Daily"
363
  },
364
  "h4": {
365
+ "histogram": 0.0006085378901517686,
366
  "bias": "BULLISH",
367
  "label": "4H MOM"
368
  },
369
  "h1": {
370
+ "histogram": 0.00022616067014397904,
371
  "status": "BULLISH_MOM",
372
+ "close": 0.6658676266670227,
373
  "label": "1H Entry",
374
+ "ema_200": 0.6625923427746863,
375
+ "rsi": 88.1401761572029
376
  },
377
  "overall_status": "LOOKING_FOR_BUY",
378
  "signal": null,
379
  "category": "Forex",
380
+ "timestamp": "2025-12-22T22:54:43.865216"
381
  },
382
  {
383
  "instrument": "USD/CHF",
384
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\udde8\ud83c\udded",
385
+ "ltp": 0.7922000288963318,
386
  "daily": {
387
+ "macd_line": -0.001873022393426238,
388
  "bias": "BEARISH",
389
  "label": "Daily"
390
  },
391
  "h4": {
392
+ "histogram": -0.00012040092895689697,
393
+ "bias": "BEARISH",
394
  "label": "4H MOM"
395
  },
396
  "h1": {
397
+ "histogram": -0.00020406363227754894,
398
  "status": "BEARISH_MOM",
399
+ "close": 0.7924900054931641,
400
  "label": "1H Entry",
401
+ "ema_200": 0.7965586434091356,
402
+ "rsi": 18.47289917200071
403
  },
404
+ "overall_status": "LOOKING_FOR_SELL",
405
  "signal": null,
406
  "category": "Forex",
407
+ "timestamp": "2025-12-22T22:54:44.385025"
408
  },
409
  {
410
  "instrument": "NZD/USD",
411
  "flag": "\ud83c\uddf3\ud83c\uddff\ud83c\uddfa\ud83c\uddf8",
412
+ "ltp": 0.5798109769821167,
413
  "daily": {
414
+ "macd_line": 0.0024187736324120523,
415
+ "bias": "NEUTRAL",
416
  "label": "Daily"
417
  },
418
  "h4": {
419
+ "histogram": 0.0004224256455298964,
420
+ "bias": "BULLISH",
421
  "label": "4H MOM"
422
  },
423
  "h1": {
424
+ "histogram": 0.0002268394240992136,
425
  "status": "BULLISH_MOM",
426
+ "close": 0.57984459400177,
427
  "label": "1H Entry",
428
+ "ema_200": 0.5776024950886334,
429
+ "rsi": 81.42282658264583
430
  },
431
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
432
  "signal": null,
433
  "category": "Forex",
434
+ "timestamp": "2025-12-22T22:54:44.903855"
435
  },
436
  {
437
  "instrument": "USD/CAD",
438
  "flag": "\ud83c\uddfa\ud83c\uddf8\ud83c\udde8\ud83c\udde6",
439
+ "ltp": 1.3740999698638916,
440
  "daily": {
441
+ "macd_line": -0.006761972015389528,
442
  "bias": "BEARISH",
443
  "label": "Daily"
444
  },
445
  "h4": {
446
+ "histogram": -0.0002487518052565418,
447
+ "bias": "BEARISH",
448
  "label": "4H MOM"
449
  },
450
  "h1": {
451
+ "histogram": -0.0004998491338921142,
452
+ "status": "BEARISH_MOM",
453
+ "close": 1.3745100498199463,
454
  "label": "1H Entry",
455
+ "ema_200": 1.3796935472749356,
456
+ "rsi": 12.426818085631652
457
  },
458
+ "overall_status": "LOOKING_FOR_SELL",
459
  "signal": null,
460
  "category": "Forex",
461
+ "timestamp": "2025-12-22T22:54:45.427145"
462
  },
463
  {
464
  "instrument": "EUR/GBP",
465
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddec\ud83c\udde7",
466
+ "ltp": 0.8729000091552734,
467
  "daily": {
468
+ "macd_line": -0.0002160461284840265,
469
+ "bias": "NEUTRAL",
470
  "label": "Daily"
471
  },
472
  "h4": {
473
+ "histogram": -0.00030529554072032965,
474
+ "bias": "NEUTRAL",
475
  "label": "4H MOM"
476
  },
477
  "h1": {
478
+ "histogram": -9.606107323094316e-06,
479
+ "status": "SELL_CROSS",
480
+ "close": 0.873170018196106,
481
  "label": "1H Entry",
482
+ "ema_200": 0.8760972514591604,
483
+ "rsi": 33.99613693727855
484
  },
485
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
486
  "signal": null,
487
  "category": "Forex",
488
+ "timestamp": "2025-12-22T22:54:45.868738"
489
  },
490
  {
491
  "instrument": "EUR/JPY",
492
  "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\uddef\ud83c\uddf5",
493
+ "ltp": 184.38600158691406,
494
  "daily": {
495
+ "macd_line": 0.9398220832711104,
496
  "bias": "BULLISH",
497
  "label": "Daily"
498
  },
499
  "h4": {
500
+ "histogram": 0.1480892444260018,
501
+ "bias": "NEUTRAL",
502
  "label": "4H MOM"
503
  },
504
  "h1": {
505
+ "histogram": -0.06685293673663728,
506
+ "status": "BEARISH_MOM",
507
+ "close": 184.38900756835938,
508
  "label": "1H Entry",
509
+ "ema_200": 182.8399418521692,
510
+ "rsi": 48.36352146126168
511
  },
512
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
513
  "signal": null,
514
  "category": "Forex",
515
+ "timestamp": "2025-12-22T22:54:46.398873"
516
  },
517
  {
518
  "instrument": "GBP/JPY",
519
  "flag": "\ud83c\uddec\ud83c\udde7\ud83c\uddef\ud83c\uddf5",
520
+ "ltp": 211.21800231933594,
521
+ "daily": {
522
+ "macd_line": 1.1229723121745678,
523
+ "bias": "BULLISH",
524
+ "label": "Daily"
525
+ },
526
+ "h4": {
527
+ "histogram": 0.24300668060588548,
528
+ "bias": "NEUTRAL",
529
+ "label": "4H MOM"
530
+ },
531
+ "h1": {
532
+ "histogram": -0.07407859580618903,
533
+ "status": "BEARISH_MOM",
534
+ "close": 211.16299438476562,
535
+ "label": "1H Entry",
536
+ "ema_200": 208.68484068841047,
537
+ "rsi": 60.96903524649189
538
+ },
539
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
540
+ "signal": null,
541
+ "category": "Forex",
542
+ "timestamp": "2025-12-22T22:54:46.959277"
543
+ },
544
+ {
545
+ "instrument": "AUD/JPY",
546
+ "flag": "\ud83c\udde6\ud83c\uddfa\ud83c\uddef\ud83c\uddf5",
547
+ "ltp": 104.4020004272461,
548
+ "daily": {
549
+ "macd_line": 0.6155301264199409,
550
+ "bias": "BULLISH",
551
+ "label": "Daily"
552
+ },
553
+ "h4": {
554
+ "histogram": 0.15658328641631958,
555
+ "bias": "NEUTRAL",
556
+ "label": "4H MOM"
557
+ },
558
+ "h1": {
559
+ "histogram": -0.03593209616720666,
560
+ "status": "BEARISH_MOM",
561
+ "close": 104.4520034790039,
562
+ "label": "1H Entry",
563
+ "ema_200": 103.36121250530309,
564
+ "rsi": 60.47008213968422
565
+ },
566
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
567
+ "signal": null,
568
+ "category": "Forex",
569
+ "timestamp": "2025-12-22T22:54:47.419399"
570
+ },
571
+ {
572
+ "instrument": "NZD/JPY",
573
+ "flag": "\ud83c\uddf3\ud83c\uddff\ud83c\uddef\ud83c\uddf5",
574
+ "ltp": 90.9260025024414,
575
  "daily": {
576
+ "macd_line": 0.531585566674849,
577
  "bias": "BULLISH",
578
  "label": "Daily"
579
  },
580
  "h4": {
581
+ "histogram": 0.11880205086950596,
582
+ "bias": "NEUTRAL",
583
+ "label": "4H MOM"
584
+ },
585
+ "h1": {
586
+ "histogram": -0.027164488084680444,
587
+ "status": "BEARISH_MOM",
588
+ "close": 90.95700073242188,
589
+ "label": "1H Entry",
590
+ "ema_200": 90.10203611756123,
591
+ "rsi": 57.44229938740584
592
+ },
593
+ "overall_status": "ACTIVE_BUY",
594
+ "signal": {
595
+ "type": "BUY",
596
+ "entry_price": 91.08000183105469,
597
+ "sl": 90.86239324297223,
598
+ "current_sl": 90.86239324297223,
599
+ "tp1": 91.40641471317836,
600
+ "tp2": 91.73282759530204,
601
+ "tp3": 92.16804477146694,
602
+ "tp_hits": [
603
+ false,
604
+ false,
605
+ false
606
+ ],
607
+ "time": "2025-12-22T08:00:00+00:00",
608
+ "category": "Forex"
609
+ },
610
+ "category": "Forex",
611
+ "timestamp": "2025-12-22T22:54:47.933363"
612
+ },
613
+ {
614
+ "instrument": "GBP/CHF",
615
+ "flag": "\ud83c\uddec\ud83c\udde7\ud83c\udde8\ud83c\udded",
616
+ "ltp": 1.0666799545288086,
617
+ "daily": {
618
+ "macd_line": 0.001394726445295369,
619
+ "bias": "NEUTRAL",
620
+ "label": "Daily"
621
+ },
622
+ "h4": {
623
+ "histogram": 0.00044674749811247113,
624
  "bias": "BULLISH",
625
  "label": "4H MOM"
626
  },
627
  "h1": {
628
+ "histogram": 7.635342934206573e-05,
629
  "status": "BULLISH_MOM",
630
+ "close": 1.0663000345230103,
631
  "label": "1H Entry",
632
+ "ema_200": 1.0651332032780805,
633
+ "rsi": 63.786567327709
634
  },
635
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
636
+ "signal": null,
637
+ "category": "Forex",
638
+ "timestamp": "2025-12-22T22:54:48.475967"
639
+ },
640
+ {
641
+ "instrument": "EUR/CAD",
642
+ "flag": "\ud83c\uddea\ud83c\uddfa\ud83c\udde8\ud83c\udde6",
643
+ "ltp": 1.615440011024475,
644
+ "daily": {
645
+ "macd_line": -0.0022950953941736074,
646
+ "bias": "NEUTRAL",
647
+ "label": "Daily"
648
+ },
649
+ "h4": {
650
+ "histogram": 5.9575771676177844e-05,
651
+ "bias": "BULLISH",
652
+ "label": "4H MOM"
653
+ },
654
+ "h1": {
655
+ "histogram": -5.958099834476628e-05,
656
+ "status": "SELL_CROSS",
657
+ "close": 1.6149100065231323,
658
+ "label": "1H Entry",
659
+ "ema_200": 1.6164249860151783,
660
+ "rsi": 40.08752735229759
661
+ },
662
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
663
+ "signal": null,
664
+ "category": "Forex",
665
+ "timestamp": "2025-12-22T22:54:49.008476"
666
+ },
667
+ {
668
+ "instrument": "AUD/CAD",
669
+ "flag": "\ud83c\udde6\ud83c\uddfa\ud83c\udde8\ud83c\udde6",
670
+ "ltp": 0.9147300124168396,
671
+ "daily": {
672
+ "macd_line": -0.0005230819026987854,
673
+ "bias": "NEUTRAL",
674
+ "label": "Daily"
675
+ },
676
+ "h4": {
677
+ "histogram": 0.0006797775567101615,
678
+ "bias": "BULLISH",
679
+ "label": "4H MOM"
680
+ },
681
+ "h1": {
682
+ "histogram": -1.559611069956398e-05,
683
+ "status": "BEARISH_MOM",
684
+ "close": 0.9148100018501282,
685
+ "label": "1H Entry",
686
+ "ema_200": 0.9137421388684653,
687
+ "rsi": 61.931747626519766
688
+ },
689
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
690
+ "signal": null,
691
+ "category": "Forex",
692
+ "timestamp": "2025-12-22T22:54:49.585102"
693
+ },
694
+ {
695
+ "instrument": "CAD/JPY",
696
+ "flag": "\ud83c\udde8\ud83c\udde6\ud83c\uddef\ud83c\uddf5",
697
+ "ltp": 114.12799835205078,
698
+ "daily": {
699
+ "macd_line": 0.7389090224640427,
700
+ "bias": "BULLISH",
701
+ "label": "Daily"
702
+ },
703
+ "h4": {
704
+ "histogram": 0.08758024282769444,
705
+ "bias": "NEUTRAL",
706
+ "label": "4H MOM"
707
+ },
708
+ "h1": {
709
+ "histogram": -0.03685271665196513,
710
+ "status": "BEARISH_MOM",
711
+ "close": 114.16799926757812,
712
+ "label": "1H Entry",
713
+ "ema_200": 113.1008843844426,
714
+ "rsi": 54.57043528946438
715
+ },
716
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
717
  "signal": null,
718
  "category": "Forex",
719
+ "timestamp": "2025-12-22T22:54:50.062431"
720
+ },
721
+ {
722
+ "instrument": "CHF/JPY",
723
+ "flag": "\ud83c\udde8\ud83c\udded\ud83c\uddef\ud83c\uddf5",
724
+ "ltp": 198.00100708007812,
725
+ "daily": {
726
+ "macd_line": 0.796611629220422,
727
+ "bias": "BULLISH",
728
+ "label": "Daily"
729
+ },
730
+ "h4": {
731
+ "histogram": 0.14831078051278146,
732
+ "bias": "NEUTRAL",
733
+ "label": "4H MOM"
734
+ },
735
+ "h1": {
736
+ "histogram": -0.08381347856536736,
737
+ "status": "BEARISH_MOM",
738
+ "close": 197.99899291992188,
739
+ "label": "1H Entry",
740
+ "ema_200": 195.8963545875275,
741
+ "rsi": 51.28170534268754
742
+ },
743
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
744
+ "signal": null,
745
+ "category": "Forex",
746
+ "timestamp": "2025-12-22T22:54:50.519762"
747
  },
748
  {
749
  "instrument": "Bitcoin",
750
  "flag": "\u20bf",
751
+ "ltp": 89286.5078125,
752
  "daily": {
753
+ "macd_line": 448.4834996328718,
754
  "bias": "BULLISH",
755
  "label": "4H Trend"
756
  },
757
  "h4": {
758
+ "histogram": 36.618234871983475,
759
+ "bias": "BULLISH",
760
  "label": "1H MOM"
761
  },
762
  "h1": {
763
+ "histogram": -72.96633425663632,
764
  "status": "BEARISH_MOM",
765
+ "close": 89247.0078125,
766
  "label": "15m Entry",
767
+ "ema_200": 88759.0128104486,
768
+ "rsi": 42.33943175332116
769
  },
770
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
771
  "signal": null,
772
+ "category": "Crypto Scalping",
773
+ "timestamp": "2025-12-22T22:54:51.075599"
774
  },
775
  {
776
  "instrument": "Ethereum",
777
  "flag": "\u039e",
778
+ "ltp": 3032.156982421875,
779
  "daily": {
780
+ "macd_line": 21.30328117748695,
781
  "bias": "BULLISH",
782
  "label": "4H Trend"
783
  },
784
  "h4": {
785
+ "histogram": 0.5859214931032817,
786
+ "bias": "BULLISH",
787
  "label": "1H MOM"
788
  },
789
  "h1": {
790
+ "histogram": -2.3653425936192365,
791
  "status": "BEARISH_MOM",
792
+ "close": 3031.267333984375,
793
  "label": "15m Entry",
794
+ "ema_200": 3005.4165119621757,
795
+ "rsi": 41.28278296165576
796
  },
797
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
798
  "signal": null,
799
+ "category": "Crypto Scalping",
800
+ "timestamp": "2025-12-22T22:54:51.680050"
801
  },
802
  {
803
+ "instrument": "Solana",
804
+ "flag": "\u2600\ufe0f",
805
+ "ltp": 126.80659484863281,
806
+ "daily": {
807
+ "macd_line": 0.1783423636045569,
808
+ "bias": "NEUTRAL",
809
+ "label": "4H Trend"
810
+ },
811
+ "h4": {
812
+ "histogram": 0.1391627111499097,
813
+ "bias": "NEUTRAL",
814
+ "label": "1H MOM"
815
+ },
816
+ "h1": {
817
+ "histogram": -0.06829379804763464,
818
+ "status": "BEARISH_MOM",
819
+ "close": 126.73048400878906,
820
+ "label": "15m Entry",
821
+ "ema_200": 126.01144597208992,
822
+ "rsi": 51.592165229448305
823
+ },
824
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
825
+ "signal": null,
826
+ "category": "Crypto Scalping",
827
+ "timestamp": "2025-12-22T22:54:52.209801"
828
+ },
829
+ {
830
+ "instrument": "Ripple",
831
+ "flag": "\ud83d\udca7",
832
+ "ltp": 1.9259839057922363,
833
  "daily": {
834
+ "macd_line": 0.006111068485924909,
835
+ "bias": "NEUTRAL",
836
+ "label": "4H Trend"
837
+ },
838
+ "h4": {
839
+ "histogram": 0.0015419324770768496,
840
+ "bias": "NEUTRAL",
841
+ "label": "1H MOM"
842
+ },
843
+ "h1": {
844
+ "histogram": -0.0005934979602226875,
845
+ "status": "BEARISH_MOM",
846
+ "close": 1.9282041788101196,
847
+ "label": "15m Entry",
848
+ "ema_200": 1.920461549647164,
849
+ "rsi": 49.50533119757412
850
+ },
851
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
852
+ "signal": null,
853
+ "category": "Crypto Scalping",
854
+ "timestamp": "2025-12-22T22:54:52.664921"
855
+ },
856
+ {
857
+ "instrument": "Cardano",
858
+ "flag": "\u20b3",
859
+ "ltp": 0.3772410750389099,
860
+ "daily": {
861
+ "macd_line": -0.0017564179686709314,
862
  "bias": "BEARISH",
863
  "label": "4H Trend"
864
  },
865
  "h4": {
866
+ "histogram": 0.001425122342140982,
867
  "bias": "BULLISH",
868
  "label": "1H MOM"
869
  },
870
  "h1": {
871
+ "histogram": -2.314854316664552e-05,
872
+ "status": "SELL_CROSS",
873
+ "close": 0.3770405352115631,
874
+ "label": "15m Entry",
875
+ "ema_200": 0.3698015957261248,
876
+ "rsi": 59.43436996919991
877
+ },
878
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
879
+ "signal": null,
880
+ "category": "Crypto Scalping",
881
+ "timestamp": "2025-12-22T22:54:53.303417"
882
+ },
883
+ {
884
+ "instrument": "Dogecoin",
885
+ "flag": "\ud83d\udc15",
886
+ "ltp": 0.133680522441864,
887
+ "daily": {
888
+ "macd_line": 0.000642160195688718,
889
+ "bias": "NEUTRAL",
890
+ "label": "4H Trend"
891
+ },
892
+ "h4": {
893
+ "histogram": 0.0002152078753441056,
894
+ "bias": "NEUTRAL",
895
+ "label": "1H MOM"
896
+ },
897
+ "h1": {
898
+ "histogram": -4.0594389330873175e-05,
899
+ "status": "SELL_CROSS",
900
+ "close": 0.13338981568813324,
901
+ "label": "15m Entry",
902
+ "ema_200": 0.13160832886246626,
903
+ "rsi": 54.554590761017614
904
+ },
905
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
906
+ "signal": null,
907
+ "category": "Crypto Scalping",
908
+ "timestamp": "2025-12-22T22:54:53.841286"
909
+ },
910
+ {
911
+ "instrument": "Polkadot",
912
+ "flag": "\u26ab",
913
+ "ltp": 1.82347571849823,
914
+ "daily": {
915
+ "macd_line": -0.012119190357115839,
916
+ "bias": "BEARISH",
917
+ "label": "4H Trend"
918
+ },
919
+ "h4": {
920
+ "histogram": 0.0030904434721423443,
921
+ "bias": "NEUTRAL",
922
+ "label": "1H MOM"
923
+ },
924
+ "h1": {
925
+ "histogram": -0.0008200580629162376,
926
+ "status": "SELL_CROSS",
927
+ "close": 1.8244147300720215,
928
+ "label": "15m Entry",
929
+ "ema_200": 1.815962806820239,
930
+ "rsi": 51.869958145871934
931
+ },
932
+ "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
933
+ "signal": null,
934
+ "category": "Crypto Scalping",
935
+ "timestamp": "2025-12-22T22:54:54.375121"
936
+ },
937
+ {
938
+ "instrument": "Nifty 50",
939
+ "flag": "\ud83c\uddee\ud83c\uddf3",
940
+ "ltp": 26162.75,
941
+ "daily": {
942
+ "macd_line": -7.433457784434722,
943
+ "bias": "NEUTRAL",
944
+ "label": "4H Trend"
945
+ },
946
+ "h4": {
947
+ "histogram": 27.7315851011331,
948
+ "bias": "NEUTRAL",
949
+ "label": "1H MOM"
950
+ },
951
+ "h1": {
952
+ "histogram": -4.244401504264843,
953
  "status": "BEARISH_MOM",
954
+ "close": 26174.80078125,
955
  "label": "15m Entry",
956
+ "ema_200": 25962.05827431938,
957
+ "rsi": 69.43913261422497
958
  },
959
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
960
  "signal": null,
961
  "category": "Intraday IndianMarket",
962
+ "timestamp": "2025-12-22T22:54:54.678716"
963
  },
964
  {
965
  "instrument": "Bank Nifty",
966
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83c\udfe6",
967
+ "ltp": 59284.1015625,
968
  "daily": {
969
+ "macd_line": -38.841678591183154,
970
+ "bias": "NEUTRAL",
971
  "label": "4H Trend"
972
  },
973
  "h4": {
974
+ "histogram": 38.28135664232391,
975
+ "bias": "NEUTRAL",
976
  "label": "1H MOM"
977
  },
978
  "h1": {
979
+ "histogram": -4.856997260985629,
980
+ "status": "BEARISH_MOM",
981
+ "close": 59313.5,
982
  "label": "15m Entry",
983
+ "ema_200": 59158.77174972517,
984
+ "rsi": 57.87667763990884
985
  },
986
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
987
  "signal": null,
988
  "category": "Intraday IndianMarket",
989
+ "timestamp": "2025-12-22T22:54:55.035174"
990
  },
991
  {
992
  "instrument": "Sensex",
993
  "flag": "\ud83c\uddee\ud83c\uddf3\ud83d\udcc8",
994
+ "ltp": 85567.6015625,
995
  "daily": {
996
+ "macd_line": -37.48713087211945,
997
+ "bias": "NEUTRAL",
998
  "label": "4H Trend"
999
  },
1000
  "h4": {
1001
+ "histogram": 84.64022324168364,
1002
+ "bias": "NEUTRAL",
1003
  "label": "1H MOM"
1004
  },
1005
  "h1": {
1006
+ "histogram": -6.542339746737156,
1007
  "status": "BEARISH_MOM",
1008
+ "close": 85581.6015625,
1009
  "label": "15m Entry",
1010
+ "ema_200": 84966.46164069431,
1011
+ "rsi": 74.76491478859083
1012
  },
1013
  "overall_status": "CONFLICT (Trend/MOM/Filter Mismatch)",
1014
  "signal": null,
1015
  "category": "Intraday IndianMarket",
1016
+ "timestamp": "2025-12-22T22:54:55.312964"
1017
  }
1018
  ]
1019
  }
forex_macd_strategy.py CHANGED
@@ -157,6 +157,7 @@ def log_signal_event(instrument, event_type, price, signal_data=None):
157
  event["entry_price"] = signal_data.get('entry_price')
158
  event["entry_time"] = signal_data.get('time')
159
  event["type"] = signal_data.get('type')
 
160
 
161
  history.append(event)
162
 
@@ -370,18 +371,15 @@ def analyze_instrument(instrument: Dict) -> Dict:
370
  if active_signal['type'] == 'BUY':
371
  # Check SL
372
  if current_price <= current_sl:
373
- print(f" 🛑 {name}: BUY signal hit SL @ {current_price}")
374
- log_signal_event(name, "SL_HIT", current_price, active_signal)
 
375
  active_signal['sl_hit'] = True
376
  active_signal['exit_price'] = current_price
377
  active_signal['exit_time'] = datetime.now().isoformat()
378
- # Keep it in ACTIVE_SIGNALS for one more cycle to show on dashboard
379
- # But it will be removed if it was already marked as sl_hit in previous cycle
380
- if active_signal.get('_marked_for_removal'):
381
- ACTIVE_SIGNALS.pop(name, None)
382
- active_signal = None
383
- else:
384
- active_signal['_marked_for_removal'] = True
385
  else:
386
  # Check TPs and Trailing SL
387
  # TP1
@@ -412,16 +410,15 @@ def analyze_instrument(instrument: Dict) -> Dict:
412
  elif active_signal['type'] == 'SELL':
413
  # Check SL
414
  if current_price >= current_sl:
415
- print(f" 🛑 {name}: SELL signal hit SL @ {current_price}")
416
- log_signal_event(name, "SL_HIT", current_price, active_signal)
 
417
  active_signal['sl_hit'] = True
418
  active_signal['exit_price'] = current_price
419
  active_signal['exit_time'] = datetime.now().isoformat()
420
- if active_signal.get('_marked_for_removal'):
421
- ACTIVE_SIGNALS.pop(name, None)
422
- active_signal = None
423
- else:
424
- active_signal['_marked_for_removal'] = True
425
  else:
426
  # Check TPs and Trailing SL
427
  # TP1
 
157
  event["entry_price"] = signal_data.get('entry_price')
158
  event["entry_time"] = signal_data.get('time')
159
  event["type"] = signal_data.get('type')
160
+ event["initial_sl"] = signal_data.get('sl')
161
 
162
  history.append(event)
163
 
 
371
  if active_signal['type'] == 'BUY':
372
  # Check SL
373
  if current_price <= current_sl:
374
+ event_type = "TRAIL_SL_HIT" if active_signal['current_sl'] != active_signal['sl'] else "SL_HIT"
375
+ print(f" 🛑 {name}: BUY signal hit {event_type} @ {current_price}")
376
+ log_signal_event(name, event_type, current_price, active_signal)
377
  active_signal['sl_hit'] = True
378
  active_signal['exit_price'] = current_price
379
  active_signal['exit_time'] = datetime.now().isoformat()
380
+ # Remove immediately from ACTIVE_SIGNALS
381
+ ACTIVE_SIGNALS.pop(name, None)
382
+ active_signal = None
 
 
 
 
383
  else:
384
  # Check TPs and Trailing SL
385
  # TP1
 
410
  elif active_signal['type'] == 'SELL':
411
  # Check SL
412
  if current_price >= current_sl:
413
+ event_type = "TRAIL_SL_HIT" if active_signal['current_sl'] != active_signal['sl'] else "SL_HIT"
414
+ print(f" 🛑 {name}: SELL signal hit {event_type} @ {current_price}")
415
+ log_signal_event(name, event_type, current_price, active_signal)
416
  active_signal['sl_hit'] = True
417
  active_signal['exit_price'] = current_price
418
  active_signal['exit_time'] = datetime.now().isoformat()
419
+ # Remove immediately from ACTIVE_SIGNALS
420
+ ACTIVE_SIGNALS.pop(name, None)
421
+ active_signal = None
 
 
422
  else:
423
  # Check TPs and Trailing SL
424
  # TP1
serve_forex_macd.py CHANGED
@@ -7,6 +7,7 @@ import http.server
7
  import socketserver
8
  import os
9
  import json
 
10
  from pathlib import Path
11
 
12
  # Hugging Face Spaces expects the app to run on port 7860
@@ -15,7 +16,9 @@ BASE_DIR = Path(__file__).parent
15
  VISITORS_FILE = BASE_DIR / "visitors.json"
16
  FEEDBACK_FILE = BASE_DIR / "feedback.json"
17
 
18
- def get_visitor_count(ip_address=None):
 
 
19
  visitors = set()
20
  if VISITORS_FILE.exists():
21
  try:
@@ -24,30 +27,52 @@ def get_visitor_count(ip_address=None):
24
  except:
25
  pass
26
 
 
27
  if ip_address:
28
  visitors.add(ip_address)
 
29
  try:
30
  with open(VISITORS_FILE, 'w') as f:
31
  json.dump(list(visitors), f)
32
  except:
33
  pass
34
 
35
- return len(visitors)
 
 
 
 
 
 
 
 
36
 
37
  class DashboardHandler(http.server.SimpleHTTPRequestHandler):
38
  def do_GET(self):
39
  if self.path == '/':
40
  self.path = '/forex_macd_dashboard.html'
41
- get_visitor_count(self.client_address[0])
42
  elif self.path == '/api/visitor-count':
43
  self.send_response(200)
44
  self.send_header('Content-type', 'application/json')
45
  self.send_header('Access-Control-Allow-Origin', '*')
46
  self.end_headers()
47
- count = get_visitor_count()
48
- self.wfile.write(json.dumps({"count": count}).encode())
 
 
 
 
 
 
 
 
49
  return
50
 
 
 
 
 
51
  return super().do_GET()
52
 
53
  def do_POST(self):
@@ -65,7 +90,7 @@ class DashboardHandler(http.server.SimpleHTTPRequestHandler):
65
  pass
66
 
67
  feedbacks.append({
68
- "time": Path(__file__).stat().st_mtime,
69
  "ip": self.client_address[0],
70
  "feedback": feedback_data.get('feedback')
71
  })
 
7
  import socketserver
8
  import os
9
  import json
10
+ import time
11
  from pathlib import Path
12
 
13
  # Hugging Face Spaces expects the app to run on port 7860
 
16
  VISITORS_FILE = BASE_DIR / "visitors.json"
17
  FEEDBACK_FILE = BASE_DIR / "feedback.json"
18
 
19
+ ACTIVE_USERS = {} # {ip: last_seen_timestamp}
20
+
21
+ def get_visitor_stats(ip_address=None):
22
  visitors = set()
23
  if VISITORS_FILE.exists():
24
  try:
 
27
  except:
28
  pass
29
 
30
+ current_time = time.time()
31
  if ip_address:
32
  visitors.add(ip_address)
33
+ ACTIVE_USERS[ip_address] = current_time
34
  try:
35
  with open(VISITORS_FILE, 'w') as f:
36
  json.dump(list(visitors), f)
37
  except:
38
  pass
39
 
40
+ # Clean up inactive users (older than 2 minutes)
41
+ inactive = [ip for ip, ts in ACTIVE_USERS.items() if current_time - ts > 120]
42
+ for ip in inactive:
43
+ del ACTIVE_USERS[ip]
44
+
45
+ return {
46
+ "unique": len(visitors),
47
+ "active": len(ACTIVE_USERS)
48
+ }
49
 
50
  class DashboardHandler(http.server.SimpleHTTPRequestHandler):
51
  def do_GET(self):
52
  if self.path == '/':
53
  self.path = '/forex_macd_dashboard.html'
54
+ get_visitor_stats(self.client_address[0])
55
  elif self.path == '/api/visitor-count':
56
  self.send_response(200)
57
  self.send_header('Content-type', 'application/json')
58
  self.send_header('Access-Control-Allow-Origin', '*')
59
  self.end_headers()
60
+ stats = get_visitor_stats()
61
+ self.wfile.write(json.dumps(stats).encode())
62
+ return
63
+ elif self.path == '/api/heartbeat':
64
+ self.send_response(200)
65
+ self.send_header('Content-type', 'application/json')
66
+ self.send_header('Access-Control-Allow-Origin', '*')
67
+ self.end_headers()
68
+ get_visitor_stats(self.client_address[0])
69
+ self.wfile.write(json.dumps({"status": "alive"}).encode())
70
  return
71
 
72
+ # Track visitor for main page
73
+ if self.path.endswith('.html'):
74
+ get_visitor_stats(self.client_address[0])
75
+
76
  return super().do_GET()
77
 
78
  def do_POST(self):
 
90
  pass
91
 
92
  feedbacks.append({
93
+ "time": time.time(),
94
  "ip": self.client_address[0],
95
  "feedback": feedback_data.get('feedback')
96
  })
signal_history.json CHANGED
@@ -1 +1,254 @@
1
- []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "instrument": "NZD/JPY",
4
+ "event": "TRAIL_SL_HIT",
5
+ "price": 91.406,
6
+ "time": "2025-12-22 22:45:00",
7
+ "category": "Forex",
8
+ "entry_price": 91.080,
9
+ "entry_time": "2025-12-22T13:30:00+00:00",
10
+ "type": "BUY",
11
+ "initial_sl": 90.862
12
+ },
13
+ {
14
+ "instrument": "EUR/USD",
15
+ "event": "SL_HIT",
16
+ "price": 1.05200,
17
+ "time": "2025-12-22 22:40:00",
18
+ "category": "Forex",
19
+ "entry_price": 1.05500,
20
+ "entry_time": "2025-12-22T12:00:00+00:00",
21
+ "type": "BUY",
22
+ "initial_sl": 1.05300
23
+ },
24
+ {
25
+ "instrument": "MCX Copper",
26
+ "event": "ENTRY",
27
+ "price": 1093.2623333855565,
28
+ "time": "2025-12-22 14:05:18",
29
+ "category": "Metals/Energy",
30
+ "entry_price": 1093.2623333855565,
31
+ "entry_time": "2025-12-22T02:00:00-05:00",
32
+ "type": "BUY"
33
+ },
34
+ {
35
+ "instrument": "Ethereum",
36
+ "event": "ENTRY",
37
+ "price": 3046.839111328125,
38
+ "time": "2025-12-22 14:05:33",
39
+ "category": "Crypto Scalping",
40
+ "entry_price": 3046.839111328125,
41
+ "entry_time": "2025-12-22T08:15:00+00:00",
42
+ "type": "BUY"
43
+ },
44
+ {
45
+ "instrument": "MCX Copper",
46
+ "event": "TP1_HIT",
47
+ "price": 1093.5066354231842,
48
+ "time": "2025-12-22 14:10:49",
49
+ "category": "Metals/Energy",
50
+ "entry_price": 1093.2623333855565,
51
+ "entry_time": "2025-12-22T02:00:00-05:00",
52
+ "type": "BUY"
53
+ },
54
+ {
55
+ "instrument": "MCX Copper",
56
+ "event": "TP2_HIT",
57
+ "price": 1093.5066354231842,
58
+ "time": "2025-12-22 14:10:49",
59
+ "category": "Metals/Energy",
60
+ "entry_price": 1093.2623333855565,
61
+ "entry_time": "2025-12-22T02:00:00-05:00",
62
+ "type": "BUY"
63
+ },
64
+ {
65
+ "instrument": "MCX Copper",
66
+ "event": "TP3_HIT",
67
+ "price": 1093.5066354231842,
68
+ "time": "2025-12-22 14:10:49",
69
+ "category": "Metals/Energy",
70
+ "entry_price": 1093.2623333855565,
71
+ "entry_time": "2025-12-22T02:00:00-05:00",
72
+ "type": "BUY"
73
+ },
74
+ {
75
+ "instrument": "MCX Copper",
76
+ "event": "ENTRY",
77
+ "price": 1093.5066354231842,
78
+ "time": "2025-12-22 14:10:49",
79
+ "category": "Metals/Energy",
80
+ "entry_price": 1093.5066354231842,
81
+ "entry_time": "2025-12-22T02:00:00-05:00",
82
+ "type": "BUY"
83
+ },
84
+ {
85
+ "instrument": "MCX Copper",
86
+ "event": "ENTRY",
87
+ "price": 1111.0312717971747,
88
+ "time": "2025-12-22 14:11:50",
89
+ "category": "Metals/Energy",
90
+ "entry_price": 1111.0312717971747,
91
+ "entry_time": "2025-12-22T02:00:00-05:00",
92
+ "type": "BUY"
93
+ },
94
+ {
95
+ "instrument": "Ethereum",
96
+ "event": "ENTRY",
97
+ "price": 3042.913818359375,
98
+ "time": "2025-12-22 14:12:00",
99
+ "category": "Crypto Scalping",
100
+ "entry_price": 3042.913818359375,
101
+ "entry_time": "2025-12-22T08:15:00+00:00",
102
+ "type": "BUY"
103
+ },
104
+ {
105
+ "instrument": "MCX Copper",
106
+ "event": "SL_HIT",
107
+ "price": 1109.4078042180477,
108
+ "time": "2025-12-22 14:17:09",
109
+ "category": "Metals/Energy",
110
+ "entry_price": 1111.0312717971747,
111
+ "entry_time": "2025-12-22T02:00:00-05:00",
112
+ "type": "BUY"
113
+ },
114
+ {
115
+ "instrument": "MCX Copper",
116
+ "event": "ENTRY",
117
+ "price": 1119.7099009427543,
118
+ "time": "2025-12-22 14:18:16",
119
+ "category": "Metals/Energy",
120
+ "entry_price": 1119.7099009427543,
121
+ "entry_time": "2025-12-22T02:00:00-05:00",
122
+ "type": "BUY"
123
+ },
124
+ {
125
+ "instrument": "MCX Copper",
126
+ "event": "SL_HIT",
127
+ "price": 1119.49236361993,
128
+ "time": "2025-12-22 14:23:44",
129
+ "category": "Metals/Energy",
130
+ "entry_price": 1119.7099009427543,
131
+ "entry_time": "2025-12-22T02:00:00-05:00",
132
+ "type": "BUY"
133
+ },
134
+ {
135
+ "instrument": "MCX Copper",
136
+ "event": "SL_HIT",
137
+ "price": 1116.9680693559144,
138
+ "time": "2025-12-22 14:29:12",
139
+ "category": "Metals/Energy",
140
+ "entry_price": 1119.7099009427543,
141
+ "entry_time": "2025-12-22T02:00:00-05:00",
142
+ "type": "BUY"
143
+ },
144
+ {
145
+ "instrument": "MCX Copper",
146
+ "event": "ENTRY",
147
+ "price": 1116.9680693559144,
148
+ "time": "2025-12-22 14:29:12",
149
+ "category": "Metals/Energy",
150
+ "entry_price": 1116.9680693559144,
151
+ "entry_time": "2025-12-22T02:00:00-05:00",
152
+ "type": "BUY"
153
+ },
154
+ {
155
+ "instrument": "MCX Copper",
156
+ "event": "TP1_HIT",
157
+ "price": 1117.7177241908776,
158
+ "time": "2025-12-22 14:34:31",
159
+ "category": "Metals/Energy",
160
+ "entry_price": 1116.9680693559144,
161
+ "entry_time": "2025-12-22T02:00:00-05:00",
162
+ "type": "BUY"
163
+ },
164
+ {
165
+ "instrument": "MCX Copper",
166
+ "event": "TP2_HIT",
167
+ "price": 1117.7177241908776,
168
+ "time": "2025-12-22 14:34:31",
169
+ "category": "Metals/Energy",
170
+ "entry_price": 1116.9680693559144,
171
+ "entry_time": "2025-12-22T02:00:00-05:00",
172
+ "type": "BUY"
173
+ },
174
+ {
175
+ "instrument": "MCX Copper",
176
+ "event": "TP3_HIT",
177
+ "price": 1117.7177241908776,
178
+ "time": "2025-12-22 14:34:31",
179
+ "category": "Metals/Energy",
180
+ "entry_price": 1116.9680693559144,
181
+ "entry_time": "2025-12-22T02:00:00-05:00",
182
+ "type": "BUY"
183
+ },
184
+ {
185
+ "instrument": "MCX Copper",
186
+ "event": "ENTRY",
187
+ "price": 1117.7177241908776,
188
+ "time": "2025-12-22 14:34:31",
189
+ "category": "Metals/Energy",
190
+ "entry_price": 1117.7177241908776,
191
+ "entry_time": "2025-12-22T02:00:00-05:00",
192
+ "type": "BUY"
193
+ },
194
+ {
195
+ "instrument": "NZD/JPY",
196
+ "event": "ENTRY",
197
+ "price": 91.08899688720703,
198
+ "time": "2025-12-22 14:34:40",
199
+ "category": "Forex",
200
+ "entry_price": 91.08899688720703,
201
+ "entry_time": "2025-12-22T08:00:00+00:00",
202
+ "type": "BUY"
203
+ },
204
+ {
205
+ "instrument": "NZD/JPY",
206
+ "event": "ENTRY",
207
+ "price": 91.08000183105469,
208
+ "time": "2025-12-22 14:35:33",
209
+ "category": "Forex",
210
+ "entry_price": 91.08000183105469,
211
+ "entry_time": "2025-12-22T08:00:00+00:00",
212
+ "type": "BUY"
213
+ },
214
+ {
215
+ "instrument": "MCX Copper",
216
+ "event": "SL_HIT",
217
+ "price": 1117.5214374212658,
218
+ "time": "2025-12-22 14:40:02",
219
+ "category": "Metals/Energy",
220
+ "entry_price": 1117.7177241908776,
221
+ "entry_time": "2025-12-22T02:00:00-05:00",
222
+ "type": "BUY"
223
+ },
224
+ {
225
+ "instrument": "MCX Copper",
226
+ "event": "TP1_HIT",
227
+ "price": 1118.2740388425584,
228
+ "time": "2025-12-22 14:45:23",
229
+ "category": "Metals/Energy",
230
+ "entry_price": 1117.7177241908776,
231
+ "entry_time": "2025-12-22T02:00:00-05:00",
232
+ "type": "BUY"
233
+ },
234
+ {
235
+ "instrument": "MCX Copper",
236
+ "event": "TP2_HIT",
237
+ "price": 1118.2740388425584,
238
+ "time": "2025-12-22 14:45:23",
239
+ "category": "Metals/Energy",
240
+ "entry_price": 1117.7177241908776,
241
+ "entry_time": "2025-12-22T02:00:00-05:00",
242
+ "type": "BUY"
243
+ },
244
+ {
245
+ "instrument": "MCX Copper",
246
+ "event": "TP3_HIT",
247
+ "price": 1118.2740388425584,
248
+ "time": "2025-12-22 14:45:23",
249
+ "category": "Metals/Energy",
250
+ "entry_price": 1117.7177241908776,
251
+ "entry_time": "2025-12-22T02:00:00-05:00",
252
+ "type": "BUY"
253
+ }
254
+ ]