Spaces:
Running
Running
Add 2 files
Browse files- index.html +231 -120
index.html
CHANGED
|
@@ -6,109 +6,186 @@
|
|
| 6 |
<title>Interactive Trading Application</title>
|
| 7 |
<link rel="stylesheet" href="styles.css">
|
| 8 |
<script src="https://s3.tradingview.com/tv.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
|
| 12 |
<h1>Commodity Trading Dashboard</h1>
|
| 13 |
|
| 14 |
-
<div>
|
| 15 |
-
<
|
| 16 |
-
<
|
| 17 |
-
<option value="OANDA:WTICOUSD">Oil</option>
|
| 18 |
-
<option value="OANDA:XAGUSD">Silver</option>
|
| 19 |
-
<option value="OANDA:XAUUSD">Gold</option>
|
| 20 |
-
</select>
|
| 21 |
-
</div>
|
| 22 |
-
|
| 23 |
-
<div>
|
| 24 |
-
<label for="timeframe">Select Timeframe:</label>
|
| 25 |
-
<select id="timeframe" onchange="updateChart()">
|
| 26 |
-
<option value="1">1 Minute</option>
|
| 27 |
-
<option value="5">5 Minutes</option>
|
| 28 |
-
<option value="15">15 Minutes</option>
|
| 29 |
-
<option value="60">1 Hour</option>
|
| 30 |
-
<option value="240">4 Hours</option>
|
| 31 |
-
<option value="D">1 Day</option>
|
| 32 |
-
</select>
|
| 33 |
-
</div>
|
| 34 |
-
|
| 35 |
-
<h2>Indicator Parameters</h2>
|
| 36 |
-
<div>
|
| 37 |
-
<label for="rsi-period">RSI Period:</label>
|
| 38 |
-
<input type="number" id="rsi-period" value="14" min="1" onchange="updateIndicators()">
|
| 39 |
-
</div>
|
| 40 |
-
<div>
|
| 41 |
-
<label for="macd-fast">MACD Fast Period:</label>
|
| 42 |
-
<input type="number" id="macd-fast" value="12" min="1" onchange="updateIndicators()">
|
| 43 |
-
</div>
|
| 44 |
-
<div>
|
| 45 |
-
<label for="macd-slow">MACD Slow Period:</label>
|
| 46 |
-
<input type="number" id="macd-slow" value="26" min="1" onchange="updateIndicators()">
|
| 47 |
-
</div>
|
| 48 |
-
<div>
|
| 49 |
-
<label for="macd-signal">MACD Signal Period:</label>
|
| 50 |
-
<input type="number" id="macd-signal" value="9" min="1" onchange="updateIndicators()">
|
| 51 |
-
</div>
|
| 52 |
-
<div>
|
| 53 |
-
<label for="stochastic-k">Stochastic %K Period:</label>
|
| 54 |
-
<input type="number" id="stochastic-k" value="14" min="1" onchange="updateIndicators()">
|
| 55 |
-
</div>
|
| 56 |
-
<div>
|
| 57 |
-
<label for="stochastic-d">Stochastic %D Period:</label>
|
| 58 |
-
<input type="number" id="stochastic-d" value="3" min="1" onchange="updateIndicators()">
|
| 59 |
-
</div>
|
| 60 |
-
<div>
|
| 61 |
-
<label for="momentum-period">Momentum Period:</label>
|
| 62 |
-
<input type="number" id="momentum-period" value="10" min="1" onchange="updateIndicators()">
|
| 63 |
</div>
|
| 64 |
|
| 65 |
-
<div id="
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
<
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</div>
|
| 84 |
|
| 85 |
-
<
|
| 86 |
-
|
| 87 |
-
<
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
<div id="economic-calendar">
|
| 93 |
-
<table>
|
| 94 |
<thead>
|
| 95 |
<tr>
|
| 96 |
<th>Date</th>
|
| 97 |
-
<th>
|
| 98 |
-
<th>
|
| 99 |
-
<th>
|
| 100 |
-
<th>Forecast</th>
|
| 101 |
</tr>
|
| 102 |
</thead>
|
| 103 |
-
<tbody id="
|
| 104 |
<tr>
|
| 105 |
-
<td colspan="
|
| 106 |
</tr>
|
| 107 |
</tbody>
|
| 108 |
</table>
|
| 109 |
</div>
|
| 110 |
|
| 111 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
function updateChart() {
|
| 113 |
const commodity = document.getElementById("commodity").value;
|
| 114 |
const timeframe = document.getElementById("timeframe").value;
|
|
@@ -147,8 +224,6 @@
|
|
| 147 |
const stochasticD = parseInt(document.getElementById("stochastic-d").value);
|
| 148 |
const momentumPeriod = parseInt(document.getElementById("momentum-period").value);
|
| 149 |
|
| 150 |
-
// Here you would typically call a function to recalculate the indicators based on the new parameters
|
| 151 |
-
// For demonstration, we will just log the values
|
| 152 |
console.log("RSI Period:", rsiPeriod);
|
| 153 |
console.log("MACD Fast Period:", macdFast);
|
| 154 |
console.log("MACD Slow Period:", macdSlow);
|
|
@@ -156,16 +231,73 @@
|
|
| 156 |
console.log("Stochastic %K Period:", stochasticK);
|
| 157 |
console.log("Stochastic %D Period:", stochasticD);
|
| 158 |
console.log("Momentum Period:", momentumPeriod);
|
|
|
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
}
|
| 163 |
|
| 164 |
-
function
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
const indicators = getIndicatorsBasedOnTimeframe(timeframe);
|
| 170 |
|
| 171 |
const sentiment = {
|
|
@@ -173,29 +305,23 @@
|
|
| 173 |
marketMakerData: Math.random() > 0.5 ? "Long" : "Short"
|
| 174 |
};
|
| 175 |
|
| 176 |
-
// Update the UI with fetched data
|
| 177 |
document.getElementById("rsi-value").innerText = indicators.rsi.toFixed(2);
|
| 178 |
document.getElementById("macd-value").innerText = indicators.macd.toFixed(2);
|
| 179 |
document.getElementById("stochastic-value").innerText = indicators.stochastic.toFixed(2);
|
| 180 |
document.getElementById("ao-value").innerText = indicators.ao.toFixed(2);
|
| 181 |
document.getElementById("momentum-value").innerText = indicators.momentum.toFixed(2);
|
| 182 |
|
| 183 |
-
// Generate recommendations based on indicator values
|
| 184 |
document.getElementById("rsi-recommendation").innerText = getRSIRecommendation(indicators.rsi);
|
| 185 |
document.getElementById("macd-recommendation").innerText = getMACDRecommendation(indicators.macd);
|
| 186 |
document.getElementById("stochastic-recommendation").innerText = getStochasticRecommendation(indicators.stochastic);
|
| 187 |
document.getElementById("ao-recommendation").innerText = getAORecommendation(indicators.ao);
|
| 188 |
document.getElementById("momentum-recommendation").innerText = getMomentumRecommendation(indicators.momentum);
|
| 189 |
|
| 190 |
-
// Update sentiment analysis
|
| 191 |
document.getElementById("retail-recommendation").innerText = sentiment.retailRecommendation;
|
| 192 |
document.getElementById("market-maker-data").innerText = sentiment.marketMakerData;
|
| 193 |
}
|
| 194 |
|
| 195 |
function fetchEconomicCalendar() {
|
| 196 |
-
// Placeholder for fetching economic calendar data
|
| 197 |
-
// Replace with actual API call to fetch economic events
|
| 198 |
-
|
| 199 |
const events = [
|
| 200 |
{ date: "2025-06-01", event: "Manufacturing PMI", impact: "High", actual: "N/A", forecast: "52.5" },
|
| 201 |
{ date: "2025-06-03", event: "Non-Farm Payrolls", impact: "High", actual: "N/A", forecast: "200K" },
|
|
@@ -210,7 +336,6 @@
|
|
| 210 |
const calendarBody = document.getElementById("calendar-body");
|
| 211 |
calendarBody.innerHTML = ""; // Clear previous data
|
| 212 |
|
| 213 |
-
// Display events in the calendar
|
| 214 |
events.forEach(event => {
|
| 215 |
const row = document.createElement("tr");
|
| 216 |
row.innerHTML = `
|
|
@@ -225,7 +350,6 @@
|
|
| 225 |
}
|
| 226 |
|
| 227 |
function getIndicatorsBasedOnTimeframe(timeframe) {
|
| 228 |
-
// Simulated indicator values based on the selected timeframe
|
| 229 |
const baseValues = {
|
| 230 |
rsi: Math.random() * 100,
|
| 231 |
macd: Math.random() * 2 - 1,
|
|
@@ -234,25 +358,24 @@
|
|
| 234 |
momentum: Math.random() * 100
|
| 235 |
};
|
| 236 |
|
| 237 |
-
// Adjust values based on timeframe (this is just an example)
|
| 238 |
switch (timeframe) {
|
| 239 |
case "1":
|
| 240 |
-
baseValues.rsi += 5;
|
| 241 |
break;
|
| 242 |
case "5":
|
| 243 |
-
baseValues.macd += 0.1;
|
| 244 |
break;
|
| 245 |
case "15":
|
| 246 |
-
baseValues.stochastic += 10;
|
| 247 |
break;
|
| 248 |
case "60":
|
| 249 |
-
baseValues.ao += 0.5;
|
| 250 |
break;
|
| 251 |
case "240":
|
| 252 |
-
baseValues.momentum += 15;
|
| 253 |
break;
|
| 254 |
case "D":
|
| 255 |
-
baseValues.rsi -= 10;
|
| 256 |
break;
|
| 257 |
}
|
| 258 |
|
|
@@ -270,11 +393,7 @@
|
|
| 270 |
}
|
| 271 |
|
| 272 |
function getMACDRecommendation(macd) {
|
| 273 |
-
|
| 274 |
-
return "Buy";
|
| 275 |
-
} else {
|
| 276 |
-
return "Sell";
|
| 277 |
-
}
|
| 278 |
}
|
| 279 |
|
| 280 |
function getStochasticRecommendation(stochastic) {
|
|
@@ -288,19 +407,11 @@
|
|
| 288 |
}
|
| 289 |
|
| 290 |
function getAORecommendation(ao) {
|
| 291 |
-
|
| 292 |
-
return "Buy";
|
| 293 |
-
} else {
|
| 294 |
-
return "Sell";
|
| 295 |
-
}
|
| 296 |
}
|
| 297 |
|
| 298 |
function getMomentumRecommendation(momentum) {
|
| 299 |
-
|
| 300 |
-
return "Buy";
|
| 301 |
-
} else {
|
| 302 |
-
return "Sell";
|
| 303 |
-
}
|
| 304 |
}
|
| 305 |
|
| 306 |
// Initialize the chart on page load
|
|
|
|
| 6 |
<title>Interactive Trading Application</title>
|
| 7 |
<link rel="stylesheet" href="styles.css">
|
| 8 |
<script src="https://s3.tradingview.com/tv.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
/* Basic styling for the tab navigation */
|
| 11 |
+
.tab {
|
| 12 |
+
display: none;
|
| 13 |
+
}
|
| 14 |
+
.tab.active {
|
| 15 |
+
display: block;
|
| 16 |
+
}
|
| 17 |
+
.tab-links {
|
| 18 |
+
margin-bottom: 20px;
|
| 19 |
+
}
|
| 20 |
+
.tab-links button {
|
| 21 |
+
margin-right: 10px;
|
| 22 |
+
padding: 10px;
|
| 23 |
+
cursor: pointer;
|
| 24 |
+
}
|
| 25 |
+
/* Basic styling for the trading journal */
|
| 26 |
+
#trading-journal {
|
| 27 |
+
margin-top: 20px;
|
| 28 |
+
}
|
| 29 |
+
#journal-table {
|
| 30 |
+
width: 100%;
|
| 31 |
+
border-collapse: collapse;
|
| 32 |
+
}
|
| 33 |
+
#journal-table th, #journal-table td {
|
| 34 |
+
border: 1px solid #ddd;
|
| 35 |
+
padding: 8px;
|
| 36 |
+
}
|
| 37 |
+
#journal-table th {
|
| 38 |
+
background-color: #f2f2f2;
|
| 39 |
+
}
|
| 40 |
+
.edit-button, .delete-button {
|
| 41 |
+
cursor: pointer;
|
| 42 |
+
color: blue;
|
| 43 |
+
text-decoration: underline;
|
| 44 |
+
}
|
| 45 |
+
</style>
|
| 46 |
</head>
|
| 47 |
<body>
|
| 48 |
|
| 49 |
<h1>Commodity Trading Dashboard</h1>
|
| 50 |
|
| 51 |
+
<div class="tab-links">
|
| 52 |
+
<button onclick="showTab('dashboard')">Dashboard</button>
|
| 53 |
+
<button onclick="showTab('trading-journal')">Trading Journal</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</div>
|
| 55 |
|
| 56 |
+
<div id="dashboard" class="tab active">
|
| 57 |
+
<div>
|
| 58 |
+
<label for="commodity">Select Commodity:</label>
|
| 59 |
+
<select id="commodity" onchange="updateChart()">
|
| 60 |
+
<option value="OANDA:WTICOUSD">Oil</option>
|
| 61 |
+
<option value="OANDA:XAGUSD">Silver</option>
|
| 62 |
+
<option value="OANDA:XAUUSD">Gold</option>
|
| 63 |
+
</select>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
<div>
|
| 67 |
+
<label for="timeframe">Select Timeframe:</label>
|
| 68 |
+
<select id="timeframe" onchange="updateChart()">
|
| 69 |
+
<option value="1">1 Minute</option>
|
| 70 |
+
<option value="5">5 Minutes</option>
|
| 71 |
+
<option value="15">15 Minutes</option>
|
| 72 |
+
<option value="60">1 Hour</option>
|
| 73 |
+
<option value="240">4 Hours</option>
|
| 74 |
+
<option value="D">1 Day</option>
|
| 75 |
+
</select>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
<h2>Indicator Parameters</h2>
|
| 79 |
+
<div>
|
| 80 |
+
<label for="rsi-period">RSI Period:</label>
|
| 81 |
+
<input type="number" id="rsi-period" value="14" min="1" onchange="updateIndicators()">
|
| 82 |
+
</div>
|
| 83 |
+
<div>
|
| 84 |
+
<label for="macd-fast">MACD Fast Period:</label>
|
| 85 |
+
<input type="number" id="macd-fast" value="12" min="1" onchange="updateIndicators()">
|
| 86 |
+
</div>
|
| 87 |
+
<div>
|
| 88 |
+
<label for="macd-slow">MACD Slow Period:</label>
|
| 89 |
+
<input type="number" id="macd-slow" value="26" min="1" onchange="updateIndicators()">
|
| 90 |
+
</div>
|
| 91 |
+
<div>
|
| 92 |
+
<label for="macd-signal">MACD Signal Period:</label>
|
| 93 |
+
<input type="number" id="macd-signal" value="9" min="1" onchange="updateIndicators()">
|
| 94 |
+
</div>
|
| 95 |
+
<div>
|
| 96 |
+
<label for="stochastic-k">Stochastic %K Period:</label>
|
| 97 |
+
<input type="number" id="stochastic-k" value="14" min="1" onchange="updateIndicators()">
|
| 98 |
+
</div>
|
| 99 |
+
<div>
|
| 100 |
+
<label for="stochastic-d">Stochastic %D Period:</label>
|
| 101 |
+
<input type="number" id="stochastic-d" value="3" min="1" onchange="updateIndicators()">
|
| 102 |
+
</div>
|
| 103 |
+
<div>
|
| 104 |
+
<label for="momentum-period">Momentum Period:</label>
|
| 105 |
+
<input type="number" id="momentum-period" value="10" min="1" onchange="updateIndicators()">
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div id="tradingview-chart"></div>
|
| 109 |
+
|
| 110 |
+
<h2>Indicators</h2>
|
| 111 |
+
<ul>
|
| 112 |
+
<li>RSI: <span id="rsi-value">Loading...</span></li>
|
| 113 |
+
<li>MACD: <span id="macd-value">Loading...</span></li>
|
| 114 |
+
<li>Stochastic: <span id="stochastic-value">Loading...</span></li>
|
| 115 |
+
<li>Awesome Oscillator: <span id="ao-value">Loading...</span></li>
|
| 116 |
+
<li>Momentum: <span id="momentum-value">Loading...</span></li>
|
| 117 |
+
</ul>
|
| 118 |
+
|
| 119 |
+
<h2>Recommendations</h2>
|
| 120 |
+
<div id="recommendations">
|
| 121 |
+
<p>RSI Recommendation: <span id="rsi-recommendation">Loading...</span></p>
|
| 122 |
+
<p>MACD Recommendation: <span id="macd-recommendation">Loading...</span></p>
|
| 123 |
+
<p>Stochastic Recommendation: <span id="stochastic-recommendation">Loading...</span></p>
|
| 124 |
+
<p>Awesome Oscillator Recommendation: <span id="ao-recommendation">Loading...</span></p>
|
| 125 |
+
<p>Momentum Recommendation: <span id="momentum-recommendation">Loading...</span></p>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<h2>Sentiment Analysis</h2>
|
| 129 |
+
<div id="sentiment-analysis">
|
| 130 |
+
<p>Retail Position Recommendation: <span id="retail-recommendation">Loading...</span></p>
|
| 131 |
+
<p>Market Maker Data: <span id="market-maker-data">Loading...</span></p>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<h2>Upcoming Economic Calendar</h2>
|
| 135 |
+
<div id="economic-calendar">
|
| 136 |
+
<table>
|
| 137 |
+
<thead>
|
| 138 |
+
<tr>
|
| 139 |
+
<th>Date</th>
|
| 140 |
+
<th>Event</th>
|
| 141 |
+
<th>Impact</th>
|
| 142 |
+
<th>Actual</th>
|
| 143 |
+
<th>Forecast</th>
|
| 144 |
+
</tr>
|
| 145 |
+
</thead>
|
| 146 |
+
<tbody id="calendar-body">
|
| 147 |
+
<tr>
|
| 148 |
+
<td colspan="5">Loading...</td>
|
| 149 |
+
</tr>
|
| 150 |
+
</tbody>
|
| 151 |
+
</table>
|
| 152 |
+
</div>
|
| 153 |
</div>
|
| 154 |
|
| 155 |
+
<div id="trading-journal" class="tab">
|
| 156 |
+
<h2>Trading Journal</h2>
|
| 157 |
+
<input type="date" id="trade-date" placeholder="Trade Date">
|
| 158 |
+
<input type="number" id="buy-price" placeholder="Buy Price" step="0.01">
|
| 159 |
+
<input type="number" id="sell-price" placeholder="Sell Price" step="0.01">
|
| 160 |
+
<button onclick="addJournalEntry()">Add Entry</button>
|
| 161 |
+
<table id="journal-table">
|
|
|
|
|
|
|
| 162 |
<thead>
|
| 163 |
<tr>
|
| 164 |
<th>Date</th>
|
| 165 |
+
<th>Buy Price</th>
|
| 166 |
+
<th>Sell Price</th>
|
| 167 |
+
<th>Actions</th>
|
|
|
|
| 168 |
</tr>
|
| 169 |
</thead>
|
| 170 |
+
<tbody id="journal-body">
|
| 171 |
<tr>
|
| 172 |
+
<td colspan="4">No entries yet.</td>
|
| 173 |
</tr>
|
| 174 |
</tbody>
|
| 175 |
</table>
|
| 176 |
</div>
|
| 177 |
|
| 178 |
<script>
|
| 179 |
+
let journalEntries = [];
|
| 180 |
+
|
| 181 |
+
function showTab(tabName) {
|
| 182 |
+
const tabs = document.querySelectorAll('.tab');
|
| 183 |
+
tabs.forEach(tab => {
|
| 184 |
+
tab.classList.remove('active');
|
| 185 |
+
});
|
| 186 |
+
document.getElementById(tabName).classList.add('active');
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
function updateChart() {
|
| 190 |
const commodity = document.getElementById("commodity").value;
|
| 191 |
const timeframe = document.getElementById("timeframe").value;
|
|
|
|
| 224 |
const stochasticD = parseInt(document.getElementById("stochastic-d").value);
|
| 225 |
const momentumPeriod = parseInt(document.getElementById("momentum-period").value);
|
| 226 |
|
|
|
|
|
|
|
| 227 |
console.log("RSI Period:", rsiPeriod);
|
| 228 |
console.log("MACD Fast Period:", macdFast);
|
| 229 |
console.log("MACD Slow Period:", macdSlow);
|
|
|
|
| 231 |
console.log("Stochastic %K Period:", stochasticK);
|
| 232 |
console.log("Stochastic %D Period:", stochasticD);
|
| 233 |
console.log("Momentum Period:", momentumPeriod);
|
| 234 |
+
}
|
| 235 |
|
| 236 |
+
function addJournalEntry() {
|
| 237 |
+
const tradeDate = document.getElementById("trade-date").value;
|
| 238 |
+
const buyPrice = parseFloat(document.getElementById("buy-price").value);
|
| 239 |
+
const sellPrice = parseFloat(document.getElementById("sell-price").value);
|
| 240 |
+
|
| 241 |
+
if (!tradeDate || isNaN(buyPrice) || isNaN(sellPrice)) {
|
| 242 |
+
alert("Please fill in all fields correctly.");
|
| 243 |
+
return;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
journalEntries.push({ date: tradeDate, buy: buyPrice, sell: sellPrice });
|
| 247 |
+
document.getElementById("trade-date").value = ""; // Clear input
|
| 248 |
+
document.getElementById("buy-price").value = ""; // Clear input
|
| 249 |
+
document.getElementById("sell-price").value = ""; // Clear input
|
| 250 |
+
renderJournalEntries();
|
| 251 |
}
|
| 252 |
|
| 253 |
+
function renderJournalEntries() {
|
| 254 |
+
const journalBody = document.getElementById("journal-body");
|
| 255 |
+
journalBody.innerHTML = ""; // Clear previous entries
|
| 256 |
+
|
| 257 |
+
if (journalEntries.length === 0) {
|
| 258 |
+
journalBody.innerHTML = "<tr><td colspan='4'>No entries yet.</td></tr>";
|
| 259 |
+
return;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
journalEntries.forEach((entry, index) => {
|
| 263 |
+
const row = document.createElement("tr");
|
| 264 |
+
row.innerHTML = `
|
| 265 |
+
<td>${entry.date}</td>
|
| 266 |
+
<td>${entry.buy.toFixed(2)}</td>
|
| 267 |
+
<td>${entry.sell.toFixed(2)}</td>
|
| 268 |
+
<td>
|
| 269 |
+
<span class="edit-button" onclick="editJournalEntry(${index})">Edit</span> |
|
| 270 |
+
<span class="delete-button" onclick="deleteJournalEntry(${index})">Delete</span>
|
| 271 |
+
</td>
|
| 272 |
+
`;
|
| 273 |
+
journalBody.appendChild(row);
|
| 274 |
+
});
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
function editJournalEntry(index) {
|
| 278 |
+
const entry = journalEntries[index];
|
| 279 |
+
const newDate = prompt("Edit Trade Date:", entry.date);
|
| 280 |
+
const newBuyPrice = prompt("Edit Buy Price:", entry.buy);
|
| 281 |
+
const newSellPrice = prompt("Edit Sell Price:", entry.sell);
|
| 282 |
+
|
| 283 |
+
if (newDate !== null && newBuyPrice !== null && newSellPrice !== null) {
|
| 284 |
+
journalEntries[index] = {
|
| 285 |
+
date: newDate,
|
| 286 |
+
buy: parseFloat(newBuyPrice),
|
| 287 |
+
sell: parseFloat(newSellPrice)
|
| 288 |
+
};
|
| 289 |
+
renderJournalEntries();
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
|
| 293 |
+
function deleteJournalEntry(index) {
|
| 294 |
+
if (confirm("Are you sure you want to delete this entry?")) {
|
| 295 |
+
journalEntries.splice(index, 1);
|
| 296 |
+
renderJournalEntries();
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
function fetchIndicatorsAndSentiment(commodity, timeframe) {
|
| 301 |
const indicators = getIndicatorsBasedOnTimeframe(timeframe);
|
| 302 |
|
| 303 |
const sentiment = {
|
|
|
|
| 305 |
marketMakerData: Math.random() > 0.5 ? "Long" : "Short"
|
| 306 |
};
|
| 307 |
|
|
|
|
| 308 |
document.getElementById("rsi-value").innerText = indicators.rsi.toFixed(2);
|
| 309 |
document.getElementById("macd-value").innerText = indicators.macd.toFixed(2);
|
| 310 |
document.getElementById("stochastic-value").innerText = indicators.stochastic.toFixed(2);
|
| 311 |
document.getElementById("ao-value").innerText = indicators.ao.toFixed(2);
|
| 312 |
document.getElementById("momentum-value").innerText = indicators.momentum.toFixed(2);
|
| 313 |
|
|
|
|
| 314 |
document.getElementById("rsi-recommendation").innerText = getRSIRecommendation(indicators.rsi);
|
| 315 |
document.getElementById("macd-recommendation").innerText = getMACDRecommendation(indicators.macd);
|
| 316 |
document.getElementById("stochastic-recommendation").innerText = getStochasticRecommendation(indicators.stochastic);
|
| 317 |
document.getElementById("ao-recommendation").innerText = getAORecommendation(indicators.ao);
|
| 318 |
document.getElementById("momentum-recommendation").innerText = getMomentumRecommendation(indicators.momentum);
|
| 319 |
|
|
|
|
| 320 |
document.getElementById("retail-recommendation").innerText = sentiment.retailRecommendation;
|
| 321 |
document.getElementById("market-maker-data").innerText = sentiment.marketMakerData;
|
| 322 |
}
|
| 323 |
|
| 324 |
function fetchEconomicCalendar() {
|
|
|
|
|
|
|
|
|
|
| 325 |
const events = [
|
| 326 |
{ date: "2025-06-01", event: "Manufacturing PMI", impact: "High", actual: "N/A", forecast: "52.5" },
|
| 327 |
{ date: "2025-06-03", event: "Non-Farm Payrolls", impact: "High", actual: "N/A", forecast: "200K" },
|
|
|
|
| 336 |
const calendarBody = document.getElementById("calendar-body");
|
| 337 |
calendarBody.innerHTML = ""; // Clear previous data
|
| 338 |
|
|
|
|
| 339 |
events.forEach(event => {
|
| 340 |
const row = document.createElement("tr");
|
| 341 |
row.innerHTML = `
|
|
|
|
| 350 |
}
|
| 351 |
|
| 352 |
function getIndicatorsBasedOnTimeframe(timeframe) {
|
|
|
|
| 353 |
const baseValues = {
|
| 354 |
rsi: Math.random() * 100,
|
| 355 |
macd: Math.random() * 2 - 1,
|
|
|
|
| 358 |
momentum: Math.random() * 100
|
| 359 |
};
|
| 360 |
|
|
|
|
| 361 |
switch (timeframe) {
|
| 362 |
case "1":
|
| 363 |
+
baseValues.rsi += 5;
|
| 364 |
break;
|
| 365 |
case "5":
|
| 366 |
+
baseValues.macd += 0.1;
|
| 367 |
break;
|
| 368 |
case "15":
|
| 369 |
+
baseValues.stochastic += 10;
|
| 370 |
break;
|
| 371 |
case "60":
|
| 372 |
+
baseValues.ao += 0.5;
|
| 373 |
break;
|
| 374 |
case "240":
|
| 375 |
+
baseValues.momentum += 15;
|
| 376 |
break;
|
| 377 |
case "D":
|
| 378 |
+
baseValues.rsi -= 10;
|
| 379 |
break;
|
| 380 |
}
|
| 381 |
|
|
|
|
| 393 |
}
|
| 394 |
|
| 395 |
function getMACDRecommendation(macd) {
|
| 396 |
+
return macd > 0 ? "Buy" : "Sell";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
}
|
| 398 |
|
| 399 |
function getStochasticRecommendation(stochastic) {
|
|
|
|
| 407 |
}
|
| 408 |
|
| 409 |
function getAORecommendation(ao) {
|
| 410 |
+
return ao > 0 ? "Buy" : "Sell";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
}
|
| 412 |
|
| 413 |
function getMomentumRecommendation(momentum) {
|
| 414 |
+
return momentum > 0 ? "Buy" : "Sell";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
}
|
| 416 |
|
| 417 |
// Initialize the chart on page load
|