// Global data and selected timeframe
let allData = [];
let selectedTimeframe = '5m';
// Formatting functions
function formatNum(v) {
if (v == null || isNaN(v)) return '—';
if (Math.abs(v) >= 100) return v.toFixed(2);
return v.toFixed(4);
}
function shortUSDT(v) {
if (v == null) return '—';
const abs = Math.abs(v);
if (abs >= 1e9) return (v / 1e9).toFixed(2) + 'B';
if (abs >= 1e6) return (v / 1e6).toFixed(2) + 'M';
if (abs >= 1e3) return (v / 1e3).toFixed(2) + 'K';
return v.toFixed(2);
}
function timeHHMM(date) {
return date.getHours().toString().padStart(2, '0') + ':' + date.getMinutes().toString().padStart(2, '0');
}
// Constants for different timeframes (example, tweak as needed)
const timeframeConsts = {
'1m': { S: 1.0, M: 1.1, N: 0.9, R: 1.3, Wp: [0.5, 1, 1.5], Wr: [0.3, 0.7, 1] },
'5m': { S: 1.1, M: 1.2, N: 0.9, R: 1.5, Wp: [0.5, 1, 1.5], Wr: [0.3, 0.7, 1] },
'15m': { S: 1.15, M: 1.3, N: 0.85, R: 1.6, Wp: [0.6, 1.1, 1.6], Wr: [0.35, 0.75, 1.1] },
'1h': { S: 1.2, M: 1.4, N: 0.8, R: 1.7, Wp: [0.7, 1.2, 1.7], Wr: [0.4, 0.8, 1.2] },
'4h': { S: 1.25, M: 1.5, N: 0.75, R: 1.8, Wp: [0.8, 1.3, 1.8], Wr: [0.45, 0.85, 1.3] },
'1d': { S: 1.3, M: 1.6, N: 0.7, R: 1.9, Wp: [0.9, 1.4, 1.9], Wr: [0.5, 0.9, 1.4] },
};
function getConstsForTimeframe(tf) {
return timeframeConsts[tf] || timeframeConsts['5m'];
}
// Target and stoploss calculation as per given formula and weights
function calculateTargetsAndStoploss(lastPrice, atr, S, M, N, R, Wp, Wr, direction) {
let targetA = [];
let stoplossA = [];
if (direction === 'long') {
for (let i = 0; i < 3; i++) {
targetA[i] = lastPrice + (atr * S * M * N * Wp[i]);
stoplossA[i] = lastPrice - (atr * R * (2 - M) * (2 - N) * Wr[i]);
}
} else if (direction === 'short') {
for (let i = 0; i < 3; i++) {
targetA[i] = lastPrice - (atr * S * M * N * Wp[i]);
stoplossA[i] = lastPrice + (atr * R * (2 - M) * (2 - N) * Wr[i]);
}
} else {
throw new Error('Invalid direction, use "long" or "short".');
}
return { targetA, stoplossA };
}
// Render table rows with all columns including new target and stoploss columns
function renderTable(data) {
if (!data.length) {
document.getElementById('table-body').innerHTML = 'No data ';
return;
}
let html = '';
data.forEach((d, i) => {
const trend = (d.ema20 !== null && d.ema50 !== null && d.ema200 !== null)
? (d.ema20 > d.ema50 && d.ema50 > d.ema200) ? 'UP' : (d.ema20 < d.ema50 && d.ema50 < d.ema200) ? 'DOWN' : 'MIX'
: '—';
const highlightStyle = d.superRocket ? 'background-color:#fff0e6;' : d.rocketRallyCandidate ? 'background-color:#e6fff2;' : '';
html += `
${i + 1}
${d.symbol}
${formatNum(d.last)}
${d.change != null ? ((d.change > 0 ? '+' : '') + d.change.toFixed(2)) : '—'}
${shortUSDT(d.vol)}
${d.oi != null ? Math.round(d.oi) : '—'}
${shortUSDT(d.oiUsd)}
${d.signalHtml}
${timeHHMM(new Date(d.updated))}
${d.momentum.toFixed(2)}
${d.signalConfidence.toFixed(2)}
${d.rocketRallyCandidate ? '🚀' : '-'}
${d.magicTop ? '💎' : '-'}
${d.superRocket ? '🔥' : '-'}
${d.instFlow}
${d.whalesScore}
${d.macd}
${d.rsi}
${d.stochastic}
${trend}
${d.bbWidth}
${d.atr}
${formatNum(d.vwap)}
${formatNum(d.targetA1)}
${formatNum(d.stoplossA1)}
${formatNum(d.targetA2)}
${formatNum(d.stoplossA2)}
${formatNum(d.targetA3)}
${formatNum(d.stoplossA3)}
${d.exitSignal ? 'EXIT' : ''}
${d.btHit}
${d.btRr}
${d.aiScore.toFixed(2)}
${d.signalProbability != null ? d.signalProbability.toFixed(2) : '—'}
${d.whaleAlert ? 'YES' : 'NO'}
${d.sentiment}
${d.riskRewardRatio}
${d.volatilityState}
${d.stopLossTriggered ? 'YES' : 'NO'}
${d.backtestAccuracy.toFixed(2)}
${d.gc1} ${d.gc2} ${d.gc3}
${d.speedEarning ? '✔' : '-'}
${d.momentum > 3 ? '🔥' : '-'}
${d.isNextTopCoin ? '⭐' : '-'}
${d.profitScore.toFixed(2)}
${d.isNextTopCoin ? '🏅' : ''}
${formatNum(d.strongTrendScore)}
${formatNum(d.highProbTargetsScore)}
${formatNum(d.promiseSurityScore)}
${formatNum(d.marketUncertaintiesScore)}
${formatNum(d.newsSentimentScore)}
${d.globalEventsScore}
${formatNum(d.marketSentimentScore)}
${formatNum(d.unpredictableChangesScore)}
${formatNum(d.priceMovementsProbScore)}
${formatNum(d.targetGuaranteedScore)}
${formatNum(d.riskManagementScore)}
${formatNum(d.stopLossScore)}
${formatNum(d.tradeLossChancesScore)}
${formatNum(d.indicatorsScore)}
${formatNum(d.improvementScore)}
${formatNum(d.momentumTradingScore)}
${formatNum(d.volumeSurgesScore)}
${formatNum(d.riskControlScore)}
${formatNum(d.positionSizingScore)}
${formatNum(d.lossMinimizeScore)}
${formatNum(d.backtestingScore)}
${formatNum(d.successRateScore)}
${formatNum(d.swingTradingScore)}
${formatNum(d.breakoutTradingScore)}
${formatNum(d.surityScore)}
${formatNum(d.tradingSystemScore)}
${d.conceptScore}
${formatNum(d.targetsFrequentHitScore)}
${formatNum(d.highProbabilitySetupsScore)}
${formatNum(d.realisticExpectationsScore)}
${formatNum(d.achievementPredictionScore)}
${formatNum(d.volumeAnalysisScore)}
${formatNum(d.reliableScore)}
${d.exactTimeFrameExecTime}
${formatNum(d.stdDeviation)}
${formatNum(d.trendMomentum)}
${formatNum(d.volumeStrengthFactor)}
${formatNum(d.volatilityFactor)}
${formatNum(d.riskManagement)}
${formatNum(d.stoplossSensitivityFactor)}
${formatNum(d.successRateScore)}
${formatNum(d.strengthCompositeScore)}
${formatNum(d.riskCompositeScore)}
${formatNum(d.targetA1)}
${formatNum(d.stoplossA1)}
${formatNum(d.targetA2)}
${formatNum(d.stoplossA2)}
${formatNum(d.targetA3)}
${formatNum(d.stoplossA3)}
`;
});
document.getElementById('table-body').innerHTML = html;
}
// Your filter functions for all buttons remain unchanged
function filterRocketRally() {
renderTable(allData.filter(d => d.rocketRallyCandidate));
}
function filterMagicMode() {
renderTable(allData.filter(d => d.magicTop));
}
function filterSuperRocket() {
renderTable(allData.filter(d => d.superRocket));
}
function filterTrendingUp() {
renderTable(allData.filter(d => d.ema20 > d.ema50 && d.ema50 > d.ema200));
}
function filterStrongBB() {
renderTable(allData.filter(d => d.bbWidth > 1.6));
}
function filterInstitutionalFlow() {
renderTable(allData.filter(d => parseFloat(d.instFlow) > 50));
}
function filterSmartWhales() {
renderTable(allData.filter(d => d.whalesScore > 2000));
}
function filterAIsignals() {
renderTable(allData.filter(d => d.aiScore > 80));
}
function filterMultiTimeframe() {
renderTable(allData.filter(d => d.ema20 > d.ema50));
}
function filterWhaleAlert() {
renderTable(allData.filter(d => d.whaleAlert));
}
function filterSentiment() {
renderTable(allData.filter(d => d.sentiment === "Bullish"));
}
function filterRiskReward() {
renderTable(allData.filter(d => parseFloat(d.riskRewardRatio) > 2));
}
function filterVolatility() {
renderTable(allData.filter(d => d.volatilityState === "Squeeze"));
}
function filterLossPrevention() {
renderTable(allData.filter(d => d.volatilityState !== "Expanding"));
}
function filterMACD_RSI_Stoch() {
renderTable(allData.filter(d => parseFloat(d.macd) > 0 && parseFloat(d.rsi) > 50 && parseFloat(d.stochastic) > 50));
}
function filterSpeedEarning() {
renderTable(allData.filter(d => d.speedEarning));
}
function filterNextTopGainers() {
renderTable(allData.filter(d => d.momentum > 3));
}
function filterNextTopCoin() {
renderTable(allData.filter(d => d.isNextTopCoin));
}
function filterProfitPredictor() {
const top10 = allData.slice().sort((a,b) => b.profitScore - a.profitScore).slice(0, 10).map(c => c.symbol);
renderTable(allData.filter(d => top10.includes(d.symbol)));
}
function filterSingleNextTop() {
const top = allData.find(d => d.isNextTopCoin);
renderTable(top ? [top] : []);
}
function filterRocketRallyShort() {
renderTable(allData.filter(d => d.momentum < -1.5));
}
function filterMagicModeShort() {
renderTable(allData.filter(d => d.magicTop && d.momentum < 0));
}
function filterSuperRocketShort() {
renderTable(allData.filter(d => d.superRocket && d.momentum < 0));
}
function filterTrendingDown() {
renderTable(allData.filter(d => d.ema20 < d.ema50 && d.ema50 < d.ema200));
}
function filterStrongBBShort() {
renderTable(allData.filter(d => d.bbWidth > 1.6 && d.momentum < 0));
}
function filterInstitutionalFlowShort() {
renderTable(allData.filter(d => parseFloat(d.instFlow) < -50));
}
function filterSmartWhalesShort() {
renderTable(allData.filter(d => d.whalesScore > 2000 && d.momentum < 0));
}
function filterAIsignalsShort() {
renderTable(allData.filter(d => d.aiScore > 80 && d.momentum < 0));
}
function filterMultiTimeframeShort() {
renderTable(allData.filter(d => d.ema20 < d.ema50));
}
function filterWhaleAlertShort() {
renderTable(allData.filter(d => d.whaleAlert && d.momentum < 0));
}
function filterSentimentShort() {
renderTable(allData.filter(d => d.sentiment === "Bearish"));
}
function filterRiskRewardShort() {
renderTable(allData.filter(d => parseFloat(d.riskRewardRatio) > 2 && d.momentum < 0));
}
function filterVolatilityShort() {
renderTable(allData.filter(d => d.volatilityState === "Squeeze" && d.momentum < 0));
}
function filterLossPreventionShort() {
renderTable(allData.filter(d => d.volatilityState !== "Expanding" && d.momentum < 0));
}
function filterMACD_RSI_StochShort() {
renderTable(allData.filter(d => parseFloat(d.macd) < 0 && parseFloat(d.rsi) < 50 && parseFloat(d.stochastic) < 50));
}
function filterSpeedEarningShort() {
renderTable(allData.filter(d => d.speedEarning && d.momentum < 0));
}
function filterNextTopGainersShort() {
renderTable(allData.filter(d => d.momentum < -3));
}
function filterNextTopCoinShort() {
let minScore = Infinity, bottomSymbol = null;
allData.forEach(d => {
if (d.profitScore < minScore && !d.stopLossTriggered) {
minScore = d.profitScore;
bottomSymbol = d.symbol;
}
});
renderTable(allData.filter(d => d.symbol === bottomSymbol));
}
// Export functions for buttons
window.applyFilter = function(name) {
if (typeof window[name] === "function") {
window[name]();
}
}
window.clearFilter = function() {
renderTable(allData);
}
window.filterRocketRally = filterRocketRally;
window.filterMagicMode = filterMagicMode;
window.filterSuperRocket = filterSuperRocket;
window.filterTrendingUp = filterTrendingUp;
window.filterStrongBB = filterStrongBB;
window.filterInstitutionalFlow = filterInstitutionalFlow;
window.filterSmartWhales = filterSmartWhales;
window.filterAIsignals = filterAIsignals;
window.filterMultiTimeframe = filterMultiTimeframe;
window.filterWhaleAlert = filterWhaleAlert;
window.filterSentiment = filterSentiment;
window.filterRiskReward = filterRiskReward;
window.filterVolatility = filterVolatility;
window.filterLossPrevention = filterLossPrevention;
window.filterMACD_RSI_Stoch = filterMACD_RSI_Stoch;
window.filterSpeedEarning = filterSpeedEarning;
window.filterNextTopGainers = filterNextTopGainers;
window.filterNextTopCoin = filterNextTopCoin;
window.filterProfitPredictor = filterProfitPredictor;
window.filterSingleNextTop = filterSingleNextTop;
window.filterRocketRallyShort = filterRocketRallyShort;
window.filterMagicModeShort = filterMagicModeShort;
window.filterSuperRocketShort = filterSuperRocketShort;
window.filterTrendingDown = filterTrendingDown;
window.filterStrongBBShort = filterStrongBBShort;
window.filterInstitutionalFlowShort = filterInstitutionalFlowShort;
window.filterSmartWhalesShort = filterSmartWhalesShort;
window.filterAIsignalsShort = filterAIsignalsShort;
window.filterMultiTimeframeShort = filterMultiTimeframeShort;
window.filterWhaleAlertShort = filterWhaleAlertShort;
window.filterSentimentShort = filterSentimentShort;
window.filterRiskRewardShort = filterRiskRewardShort;
window.filterVolatilityShort = filterVolatilityShort;
window.filterLossPreventionShort = filterLossPreventionShort;
window.filterMACD_RSI_StochShort = filterMACD_RSI_StochShort;
window.filterSpeedEarningShort = filterSpeedEarningShort;
window.filterNextTopGainersShort = filterNextTopGainersShort;
window.filterNextTopCoinShort = filterNextTopCoinShort;
// Sample usage inside your data fetching & processing function, call this AFTER fetching and before rendering:
// Assuming you fetch allData array with all other fields from your API or data source,
// update allData targets using new formula like this:
function updateTargetsForAllData() {
allData = allData.map(d => {
const consts = getConstsForTimeframe(selectedTimeframe);
// Determine long or short based on momentum or your own logic
const direction = d.momentum >= 0 ? 'long' : 'short';
const atr = parseFloat(d.atr) || 1;
const { targetA, stoplossA } = calculateTargetsAndStoploss(
d.last, atr,
consts.S, consts.M, consts.N, consts.R,
consts.Wp, consts.Wr,
direction
);
return {
...d,
targetA1: targetA[0],
stoplossA1: stoplossA[0],
targetA2: targetA[1],
stoplossA2: stoplossA[1],
targetA3: targetA[2],
stoplossA3: stoplossA[2],
// Preserve all other properties as they are for full columns
};
});
}
// Call updateTargetsForAllData() each time you refresh or fetch new data, then call renderTable(allData).
// This script is complete and can replace your existing JavaScript part, preserving all columns, all button filter logic,
// with dynamically calculated targets and stoplosses changing based on timeframe and long/short condition.
// No column or data is removed or hidden, you get full data displayed as requested.
# app.py from flask import Flask, jsonify import numpy as np import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import LSTM, Dense import requests app = Flask(__name__) # Binance se last 60 minute price data fetch karna def fetch_binance_data(): url = "https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&limit=60" data = requests.get(url).json() closes = [float(item[4]) for item in data] return closes # LSTM input prepare karna sliding window ke form me def prepare_data(series, n_steps): X, y = [], [] for i in range(len(series) - n_steps): X.append(series[i:i+n_steps]) y.append(series[i+n_steps]) return np.array(X), np.array(y) # LSTM model train karna def train_model(series): n_steps = 10 X, y = prepare_data(series, n_steps) X = X.reshape((X.shape[0], X.shape[1], 1)) model = Sequential([ LSTM(50, activation='relu', input_shape=...
Comments
Post a Comment