Spaces:
Running
build the backend of this Forex bot <!DOCTYPE html>
Browse files<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forex Structure Bot Core (SMC)</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* Custom styles for better visibility and structure */
body { font-family: 'Inter', sans-serif; background-color: #f7f9fb; }
.bias-box {
font-size: 1.5rem;
font-weight: bold;
padding: 1rem;
border-radius: 0.75rem;
text-align: center;
transition: all 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.bullish { background-color: #10b981; color: white; }
.bearish { background-color: #ef4444; color: white; }
.accumulative { background-color: #f59e0b; color: white; }
.code-container {
max-height: 400px;
overflow-y: scroll;
background-color: #1f2937;
color: #d1d5db;
padding: 1rem;
border-radius: 0.5rem;
font-family: monospace;
white-space: pre-wrap;
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body class="p-6 md:p-10">
<div class="max-w-4xl mx-auto bg-white p-6 rounded-xl shadow-2xl">
<h1 class="text-3xl font-extrabold text-gray-900 mb-2">SMC Trade Execution Plan</h1>
<p class="text-gray-500 mb-6">
Analyzing 5M structure (N=2 pivot) and calculating the trade plan based on your custom OB/FVG/Engulfing or 30% Fib rules.
</p>
<!-- Bias Display -->
<div id="bias-display" class="bias-box accumulative mb-8">
Analyzing...
</div>
<!-- Trade Plan Summary -->
<div class="p-5 bg-blue-50 border-l-4 border-blue-400 rounded-lg shadow-md mb-8">
<h3 class="text-xl font-bold text-blue-700 mb-2">Calculated Trade Plan (R:R 1:2)</h3>
<div id="trade-plan-details" class="text-gray-800 space-y-1 text-sm">
<!-- Trade details will be inserted here -->
</div>
</div>
<!-- Key Strategy Data -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-center text-sm mb-8">
<div class="p-3 bg-green-100 rounded-lg shadow-inner font-medium">Structure TF: 5M (N=2)</div>
<div class="p-3 bg-red-100 rounded-lg shadow-inner font-medium">BOS/CHoCH: Candle Close</div>
<div class="p-3 bg-yellow-100 rounded-lg shadow-inner font-medium">TP Target: R:R 1:2</div>
</div>
<h2 class="text-xl font-bold text-gray-800 mb-3">Simulated 5M Bar Data & Pivots</h2>
<div id="data-log" class="code-container">
Loading simulated data...
</div>
<button onclick="determineBias()" class="mt-6 w-full py-3 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg shadow-lg transition duration-150">
Run Structure & Trade Plan Analysis
</button>
</div>
<script type="text/javascript">
// Global buffer used for SL/TP calculations
const SL_BUFFER = 0.0002; // 2 pips buffer
// ===================================================================================
// 1. SIMULATION DATA
// Simulating an Uptrend followed by a Bearish CHoCH, with a perfect Bearish OB/FVG setup.
// ===================================================================================
function getHistoricalData(timeframe) {
if (timeframe !== '5M') return [];
const data = [
// 0-3: Context of an Uptrend (P3 > P2)
{ open: 0.9990, high: 1.0000, low: 0.9990, close: 0.9995 },
{ open: 0.9995, high: 1.0005, low: 0.9990, close: 1.0000, pivotNote: "Previous HH (P3)" }, // P3 High (1.0005)
{ open: 1.0000, high: 1.0010, low: 0.9998, close: 1.0005 },
{ open: 1.0005, high: 1.0012, low: 1.0000, close: 1.0008, pivotNote: "Protected HL (P2)" }, // P2 Low (1.0000) - Protected Low/CHoCH Break Target
// 4-8: Impulse Down (CHoCH Move)
// Bar 4: Order Block (Last Up Candle)
{ open: 1.0008, high: 1.0015, low: 1.0005, close: 1.0010, pivotNote: "Bearish OB" }, // Bullish close (Up Candle) - Bearish OB here (Range 1.0005 - 1.0015)
// Bar 5: Engulfing Candle (C1) - Must engulf C4 (1.0005-1.0015)
{ open: 1.0010, high: 1.0018, low: 1.0000, close: 1.0003, pivotNote: "Engulfing C1" }, // Low 1.0000, High 1.0018 -> Engulfs OB.
// Bar 6: Middle FVG Candle (C2)
{ open: 1.0003, high: 1.0005, low: 0.9995, close: 0.9998, pivotNote: "FVG C2" },
// Bar 7: FVG Candle 3 (C3)
{ open: 0.9998, high: 1.0000, low: 0.9990, close: 0.9993, pivotNote: "FVG C3" }, // High 1.0000. FVG: Low of C5 (1.0000) to High of C7 (1.0000) - NO GAP. Let's adjust C5 Low and C7 High.
// Redo 5-7 to ensure FVG:
// Bar 4 (OB): { open: 1.0008, high: 1.0015, low: 1.0005, close: 1.0010 }
// Bar 5 (C1): { open: 1.0010, high: 1.0018, low: 1.0000, close: 1.0003, pivotNote: "Engulfing C1" }, // Low: 1.0000
// Bar 6 (C2): { open: 1.0003, high: 1.0005, low: 0.9995, close: 0.9998, pivotNote: "FVG C2" },
// Bar 7 (C3): { open: 0.9998, high: 1.0000, low: 0.9990, close: 0.9993, pivotNote: "FVG C3" }, // High: 1.0000
// Corrected setup for Bearish FVG: High of C3 (1.0000) must be lower than Low of C1 (1.0000). Let's make C1 Low lower.
{ open: 1.0008, high: 1.0015, low: 1.0005, close: 1.0010, pivotNote: "Bearish OB" },
{ open: 1.0010, high: 1.0018, low: 0.9990, close: 1.0003, pivotNote: "Engulfing C1" }, // Low: 0.9990
{ open: 1.0003, high: 1.0005, low: 0.9985, close: 0.9998, pivotNote: "FVG C2" },
{ open: 0.9998, high: 1.0005, low: 0.9980, close: 0.9993, pivotNote: "FVG C3" }, // High: 1.0005. Bearish FVG: Low of C1 (0.9990) > High of C3 (1.0005) -> NO.
// Let's simplify and make the FVG clearer: C1 high vs C3 low (Bullish) or C1 low vs C3 high (Bearish)
// Rerun data with clear Bearish FVG (C1.low > C3.high)
{ open: 1.0008, high: 1.0015, low: 1.0005, close: 1.0010, pivotNote: "Bearish OB" },
{ open: 1.0010, high: 1.0020, low: 1.0000, close: 1.0003, pivotNote: "Engulfing C1" }, // C1 Low: 1.0000
{ open: 1.0003, high: 1.0006, low: 0.9995, close: 0.9998, pivotNote: "FVG C2" },
{ open: 0.9998, high: 0.9999, low: 0.9990, close: 0.9993, pivotNote: "FVG C3" }, // C3 High: 0.9999. FVG: C1 Low (1.0000) > C3 High (0.9999). YES!
// Bar 8: CHoCH break
{ open: 0.9993, high: 0.9998, low: 0.9980, close: 0.9985, pivotNote: "CHoCH Close" }, // Close (0.9985) < P2 Low (1.0000) -> BEARISH CHoCH
// Bar 9: P1 LL
{ open: 0.9985, high: 0.9990, low: 0.9975, close: 0.9980, pivotNote: "CHoCH LL (P1)" },
// 10-12: Retracement phase (Current bars)
{ open: 0.9980, high: 0.9985, low: 0.9975, close: 0.9980 },
{ open: 0.9980, high: 0.9988, low: 0.9978, close: 0.9985 },
{ open: 0.9985, high: 0.9990, low: 0.9980, close: 0.9988 }, // Last bar: Waiting for entry
];
return data.map((bar, index) => ({
index,
time: new Date(Date.now() - (12 - index) * 5 * 60 * 1000).toLocaleTimeString(),
...bar
}));
}
// ===================================================================================
// 2. CORE STRATEGY LOGIC (PIVOTS, BOS/CHOCH) - unchanged from last version
// ===================================================================================
/**
* Identifies valid Swing Highs (1) and Swing Lows (-1) using the N=2 pivot rule.
*/
function getPivots(data, N) {
const pivots = data.map(() => 0);
const windowSize = 2 * N + 1;
if (data.length < windowSize) return pivots;
for (let i = N; i < data.length - N; i++) {
const current = data[i];
let is_swing_high = true;
let is_swing_low = true;
for (let j = i - N; j <= i + N; j++) {
if (i === j) continue;
if (data[j].high >= current.high) is_swing_high = false;
if (data[j].low <= current.low) is_swing_low = false;
}
// Relaxed pivot definition: must be the highest/lowest in the window
if (is_swing_high) pivots[i] = 1;
else if (is_swing_low) pivots[i] = -1;
}
return pivots;
}
/**
* Analyzes the sequence of pivots to detect BOS/CHoCH and determine market bias.
*/
function analyzeStructure(data, pivots) {
const structure = {
bias: 'Accumulative',
last_break_type: 'None',
protected_low: 0,
protected_high: 0,
impulse_start_price: 0,
impulse_end_price: 0,
break_index: -1, // New: Index of the candle that closed the break
protected_low_index: -1,
protected_high_index: -1,
};
const swingPoints = [];
for (let i = 0; i < data.length; i++) {
if (pivots[i] === 1) swingPoints.push({ type: 'H', price: data[i].high, index: i });
else if (pivots[i] === -1) swingPoints.push({ type: 'L', price: data[i].low, index: i });
}
if (swingPoints.length < 3) return structure;
const P1 = swingPoints[swingPoints.length - 1];
const P2 = swingPoint
- backend.html +174 -153
- bots.html +10 -10
- smc-bot-mql5.html +1 -1
|
@@ -3,23 +3,25 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<style>
|
| 9 |
-
.
|
| 10 |
transition: all 0.3s ease;
|
| 11 |
border-left: 4px solid #3b82f6;
|
| 12 |
}
|
| 13 |
-
.
|
| 14 |
transform: translateY(-5px);
|
| 15 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 16 |
}
|
| 17 |
-
.
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
</style>
|
| 25 |
</head>
|
|
@@ -29,195 +31,214 @@
|
|
| 29 |
<div class="bg-blue-600 p-6 text-white">
|
| 30 |
<div class="flex items-center">
|
| 31 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 32 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="
|
| 33 |
</svg>
|
| 34 |
<div>
|
| 35 |
-
<h1 class="text-3xl font-bold">
|
| 36 |
-
<p class="text-blue-100">
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
</div>
|
| 40 |
|
| 41 |
<!-- Main Content -->
|
| 42 |
<div class="p-8">
|
| 43 |
-
<!--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
<section class="mb-12">
|
| 45 |
-
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">
|
| 46 |
<div class="grid md:grid-cols-3 gap-6">
|
| 47 |
-
<div class="bg-gray-50 p-6 rounded-lg
|
| 48 |
<div class="flex items-center mb-3">
|
| 49 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 50 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 51 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="
|
| 52 |
</svg>
|
| 53 |
</div>
|
| 54 |
-
<h3 class="text-xl font-semibold">Data
|
| 55 |
-
</div>
|
| 56 |
-
<div class="space-y-4">
|
| 57 |
-
<div>
|
| 58 |
-
<h4 class="font-medium text-gray-700">Real-Time Data Feed</h4>
|
| 59 |
-
<p class="text-gray-600 text-sm">Broker APIs (OANDA, IB) or MT5 bridge</p>
|
| 60 |
-
</div>
|
| 61 |
-
<div>
|
| 62 |
-
<h4 class="font-medium text-gray-700">Persistence Layer</h4>
|
| 63 |
-
<p class="text-gray-600 text-sm">Firestore/MongoDB for state management</p>
|
| 64 |
-
</div>
|
| 65 |
-
<div>
|
| 66 |
-
<h4 class="font-medium text-gray-700">Hosting</h4>
|
| 67 |
-
<p class="text-gray-600 text-sm">AWS Lambda or DigitalOcean VPS for 24/5 operation</p>
|
| 68 |
-
</div>
|
| 69 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
-
<div class="bg-gray-50 p-6 rounded-lg
|
| 72 |
<div class="flex items-center mb-3">
|
| 73 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 74 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 75 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9
|
| 76 |
</svg>
|
| 77 |
</div>
|
| 78 |
-
<h3 class="text-xl font-semibold">
|
| 79 |
-
</div>
|
| 80 |
-
<div class="space-y-4">
|
| 81 |
-
<div>
|
| 82 |
-
<h4 class="font-medium text-gray-700">Language</h4>
|
| 83 |
-
<p class="text-gray-600 text-sm">Python with Pandas/numpy for calculations</p>
|
| 84 |
-
</div>
|
| 85 |
-
<div>
|
| 86 |
-
<h4 class="font-medium text-gray-700">Implementation</h4>
|
| 87 |
-
<p class="text-gray-600 text-sm">Translating JS logic to Python functions</p>
|
| 88 |
-
</div>
|
| 89 |
-
<div>
|
| 90 |
-
<h4 class="font-medium text-gray-700">State Management</h4>
|
| 91 |
-
<p class="text-gray-600 text-sm">Persisting market structure to database</p>
|
| 92 |
-
</div>
|
| 93 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
</div>
|
| 95 |
-
<div class="bg-gray-50 p-6 rounded-lg
|
| 96 |
<div class="flex items-center mb-3">
|
| 97 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 98 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 99 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="
|
| 100 |
</svg>
|
| 101 |
</div>
|
| 102 |
-
<h3 class="text-xl font-semibold">
|
| 103 |
-
</div>
|
| 104 |
-
<div class="space-y-4">
|
| 105 |
-
<div>
|
| 106 |
-
<h4 class="font-medium text-gray-700">Order Placement</h4>
|
| 107 |
-
<p class="text-gray-600 text-sm">Broker API integration with error handling</p>
|
| 108 |
-
</div>
|
| 109 |
-
<div>
|
| 110 |
-
<h4 class="font-medium text-gray-700">Risk Management</h4>
|
| 111 |
-
<p class="text-gray-600 text-sm">1% account risk per trade enforcement</p>
|
| 112 |
-
</div>
|
| 113 |
-
<div>
|
| 114 |
-
<h4 class="font-medium text-gray-700">Trade Monitoring</h4>
|
| 115 |
-
<p class="text-gray-600 text-sm">Break-even and trail stop logic</p>
|
| 116 |
-
</div>
|
| 117 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
</section>
|
| 121 |
|
| 122 |
-
<!--
|
| 123 |
<section class="mb-12">
|
| 124 |
-
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">
|
| 125 |
-
<div class="
|
| 126 |
-
<
|
| 127 |
-
|
| 128 |
-
<
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
<
|
|
|
|
|
|
|
| 134 |
</div>
|
| 135 |
-
<div class="
|
| 136 |
-
<
|
| 137 |
-
<
|
| 138 |
-
<
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
<
|
|
|
|
| 143 |
</div>
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
</div>
|
| 153 |
</div>
|
| 154 |
-
</section>
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
<
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
<p class="text-sm text-gray-600">Pivot Detection & Structure Analysis</p>
|
| 169 |
-
</div>
|
| 170 |
-
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 171 |
-
<div class="font-semibold text-blue-600">3. Risk Manager</div>
|
| 172 |
-
<p class="text-sm text-gray-600">Position Sizing & R:R Calculation</p>
|
| 173 |
-
</div>
|
| 174 |
-
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 175 |
-
<div class="font-semibold text-blue-600">4. Execution</div>
|
| 176 |
-
<p class="text-sm text-gray-600">Order Placement & Monitoring</p>
|
| 177 |
-
</div>
|
| 178 |
</div>
|
| 179 |
</div>
|
| 180 |
</section>
|
| 181 |
|
| 182 |
-
<!--
|
| 183 |
<section>
|
| 184 |
-
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">
|
| 185 |
-
<div class="bg-gray-50 p-
|
| 186 |
-
<
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
<div class="
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
</div>
|
| 194 |
-
|
| 195 |
-
<
|
| 196 |
-
|
| 197 |
-
<div class="
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
<
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
<
|
| 209 |
-
|
| 210 |
-
<span class="text-gray-700">Strict risk management enforcing 1% account risk per trade</span>
|
| 211 |
-
</li>
|
| 212 |
-
<li class="flex items-start">
|
| 213 |
-
<div class="bg-blue-100 rounded-full p-1 mr-3 flex-shrink-0">
|
| 214 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 215 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
| 216 |
-
</svg>
|
| 217 |
</div>
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
</ul>
|
| 221 |
</div>
|
| 222 |
</section>
|
| 223 |
</div>
|
|
@@ -231,9 +252,9 @@
|
|
| 231 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-2 text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 232 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
| 233 |
</svg>
|
| 234 |
-
<span class="text-xl font-bold">SMC Trading
|
| 235 |
</div>
|
| 236 |
-
<p class="text-gray-400 mt-1">
|
| 237 |
</div>
|
| 238 |
<div class="flex space-x-4">
|
| 239 |
<a href="index.html" class="text-gray-300 hover:text-white">Home</a>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Forex Bot Backend</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<style>
|
| 9 |
+
.server-card {
|
| 10 |
transition: all 0.3s ease;
|
| 11 |
border-left: 4px solid #3b82f6;
|
| 12 |
}
|
| 13 |
+
.server-card:hover {
|
| 14 |
transform: translateY(-5px);
|
| 15 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 16 |
}
|
| 17 |
+
.code-container {
|
| 18 |
+
background-color: #1f2937;
|
| 19 |
+
color: #d1d5db;
|
| 20 |
+
padding: 1rem;
|
| 21 |
+
border-radius: 0.5rem;
|
| 22 |
+
font-family: monospace;
|
| 23 |
+
white-space: pre-wrap;
|
| 24 |
+
overflow-x: auto;
|
| 25 |
}
|
| 26 |
</style>
|
| 27 |
</head>
|
|
|
|
| 31 |
<div class="bg-blue-600 p-6 text-white">
|
| 32 |
<div class="flex items-center">
|
| 33 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 34 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" />
|
| 35 |
</svg>
|
| 36 |
<div>
|
| 37 |
+
<h1 class="text-3xl font-bold">SMC Trading Bot - Backend System</h1>
|
| 38 |
+
<p class="text-blue-100">Node.js & Python backend infrastructure for trade execution and monitoring</p>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
</div>
|
| 42 |
|
| 43 |
<!-- Main Content -->
|
| 44 |
<div class="p-8">
|
| 45 |
+
<!-- Architecture Overview -->
|
| 46 |
+
<section class="mb-12">
|
| 47 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">System Architecture</h2>
|
| 48 |
+
<div class="bg-gray-100 p-6 rounded-lg">
|
| 49 |
+
<img src="http://static.photos/technology/1024x576/42" alt="Backend Architecture" class="w-full rounded-lg mb-4">
|
| 50 |
+
<div class="grid md:grid-cols-4 gap-4 text-center">
|
| 51 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 52 |
+
<div class="font-semibold text-blue-600">1. Data Collector</div>
|
| 53 |
+
<p class="text-sm text-gray-600">MT5 API & WebSocket feeds</p>
|
| 54 |
+
</div>
|
| 55 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 56 |
+
<div class="font-semibold text-blue-600">2. Strategy Engine</div>
|
| 57 |
+
<p class="text-sm text-gray-600">SMC pattern detection</p>
|
| 58 |
+
</div>
|
| 59 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 60 |
+
<div class="font-semibold text-blue-600">3. Execution Layer</div>
|
| 61 |
+
<p class="text-sm text-gray-600">Order management</p>
|
| 62 |
+
</div>
|
| 63 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 64 |
+
<div class="font-semibold text-blue-600">4. Monitoring</div>
|
| 65 |
+
<p class="text-sm text-gray-600">Performance tracking</p>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
</section>
|
| 70 |
+
|
| 71 |
+
<!-- Server Infrastructure -->
|
| 72 |
<section class="mb-12">
|
| 73 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">Server Infrastructure</h2>
|
| 74 |
<div class="grid md:grid-cols-3 gap-6">
|
| 75 |
+
<div class="bg-gray-50 p-6 rounded-lg server-card">
|
| 76 |
<div class="flex items-center mb-3">
|
| 77 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 78 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 79 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" />
|
| 80 |
</svg>
|
| 81 |
</div>
|
| 82 |
+
<h3 class="text-xl font-semibold">Data Processing</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</div>
|
| 84 |
+
<p class="text-gray-600 mb-2">AWS EC2 c5.2xlarge instance</p>
|
| 85 |
+
<ul class="text-sm text-gray-600 space-y-1">
|
| 86 |
+
<li>• 8 vCPUs, 16GB RAM</li>
|
| 87 |
+
<li>• 500GB SSD storage</li>
|
| 88 |
+
<li>• Dedicated MT5 bridge</li>
|
| 89 |
+
</ul>
|
| 90 |
</div>
|
| 91 |
+
<div class="bg-gray-50 p-6 rounded-lg server-card">
|
| 92 |
<div class="flex items-center mb-3">
|
| 93 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 94 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 95 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
|
| 96 |
</svg>
|
| 97 |
</div>
|
| 98 |
+
<h3 class="text-xl font-semibold">Execution Server</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
</div>
|
| 100 |
+
<p class="text-gray-600 mb-2">AWS EC2 c5.xlarge instance</p>
|
| 101 |
+
<ul class="text-sm text-gray-600 space-y-1">
|
| 102 |
+
<li>• 4 vCPUs, 8GB RAM</li>
|
| 103 |
+
<li>• 250GB SSD storage</li>
|
| 104 |
+
<li>• Low-latency networking</li>
|
| 105 |
+
</ul>
|
| 106 |
</div>
|
| 107 |
+
<div class="bg-gray-50 p-6 rounded-lg server-card">
|
| 108 |
<div class="flex items-center mb-3">
|
| 109 |
<div class="bg-blue-100 rounded-full p-2 mr-3">
|
| 110 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 111 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
| 112 |
</svg>
|
| 113 |
</div>
|
| 114 |
+
<h3 class="text-xl font-semibold">Monitoring</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
</div>
|
| 116 |
+
<p class="text-gray-600 mb-2">AWS EC2 t3.medium instance</p>
|
| 117 |
+
<ul class="text-sm text-gray-600 space-y-1">
|
| 118 |
+
<li>• 2 vCPUs, 4GB RAM</li>
|
| 119 |
+
<li>• CloudWatch integration</li>
|
| 120 |
+
<li>• Telegram alerts</li>
|
| 121 |
+
</ul>
|
| 122 |
</div>
|
| 123 |
</div>
|
| 124 |
</section>
|
| 125 |
|
| 126 |
+
<!-- API Endpoints -->
|
| 127 |
<section class="mb-12">
|
| 128 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">REST API Endpoints</h2>
|
| 129 |
+
<div class="bg-gray-50 p-5 rounded-lg mb-6">
|
| 130 |
+
<h3 class="text-xl font-semibold mb-3 text-blue-700">1. Market Data</h3>
|
| 131 |
+
<div class="code-container mb-4">
|
| 132 |
+
<span class="text-green-400">// Get current market structure</span><br>
|
| 133 |
+
<span class="text-blue-400">GET</span> <span class="text-yellow-200">/api/market/structure?symbol=EURUSD&tf=5M</span><br>
|
| 134 |
+
<span class="text-gray-500">Response:</span> {<br>
|
| 135 |
+
"bias": "Bullish",<br>
|
| 136 |
+
"protectedLow": 1.12345,<br>
|
| 137 |
+
"protectedHigh": 1.12567,<br>
|
| 138 |
+
"pivots": [1, -1, 0, 1]<br>
|
| 139 |
+
}
|
| 140 |
</div>
|
| 141 |
+
<div class="code-container">
|
| 142 |
+
<span class="text-green-400">// Stream real-time price data</span><br>
|
| 143 |
+
<span class="text-blue-400">WS</span> <span class="text-yellow-200">/ws/prices?symbols=EURUSD,GBPUSD,XAUUSD</span><br>
|
| 144 |
+
<span class="text-gray-500">Messages:</span> {<br>
|
| 145 |
+
"symbol": "EURUSD",<br>
|
| 146 |
+
"bid": 1.12345,<br>
|
| 147 |
+
"ask": 1.12355,<br>
|
| 148 |
+
"time": "2023-07-20T12:34:56Z"<br>
|
| 149 |
+
}
|
| 150 |
</div>
|
| 151 |
+
</div>
|
| 152 |
+
|
| 153 |
+
<div class="bg-gray-50 p-5 rounded-lg mb-6">
|
| 154 |
+
<h3 class="text-xl font-semibold mb-3 text-blue-700">2. Trade Execution</h3>
|
| 155 |
+
<div class="code-container mb-4">
|
| 156 |
+
<span class="text-green-400">// Submit new trade</span><br>
|
| 157 |
+
<span class="text-blue-400">POST</span> <span class="text-yellow-200">/api/trades</span><br>
|
| 158 |
+
<span class="text-gray-500">Body:</span> {<br>
|
| 159 |
+
"symbol": "EURUSD",<br>
|
| 160 |
+
"type": "BUY",<br>
|
| 161 |
+
"entry": 1.12345,<br>
|
| 162 |
+
"sl": 1.12245,<br>
|
| 163 |
+
"tp": 1.12545,<br>
|
| 164 |
+
"riskPercent": 1.0,<br>
|
| 165 |
+
"comment": "SMC BOS setup"<br>
|
| 166 |
+
}
|
| 167 |
+
</div>
|
| 168 |
+
<div class="code-container">
|
| 169 |
+
<span class="text-green-400">// Get active trades</span><br>
|
| 170 |
+
<span class="text-blue-400">GET</span> <span class="text-yellow-200">/api/trades?status=active</span><br>
|
| 171 |
+
<span class="text-gray-500">Response:</span> [{<br>
|
| 172 |
+
"id": 12345,<br>
|
| 173 |
+
"symbol": "EURUSD",<br>
|
| 174 |
+
"type": "BUY",<br>
|
| 175 |
+
"entry": 1.12345,<br>
|
| 176 |
+
"sl": 1.12245,<br>
|
| 177 |
+
"tp": 1.12545,<br>
|
| 178 |
+
"profit": 32.50,<br>
|
| 179 |
+
"status": "open"<br>
|
| 180 |
+
}]
|
| 181 |
</div>
|
| 182 |
</div>
|
|
|
|
| 183 |
|
| 184 |
+
<div class="bg-gray-50 p-5 rounded-lg">
|
| 185 |
+
<h3 class="text-xl font-semibold mb-3 text-blue-700">3. System Monitoring</h3>
|
| 186 |
+
<div class="code-container">
|
| 187 |
+
<span class="text-green-400">// Get system health</span><br>
|
| 188 |
+
<span class="text-blue-400">GET</span> <span class="text-yellow-200">/api/health</span><br>
|
| 189 |
+
<span class="text-gray-500">Response:</span> {<br>
|
| 190 |
+
"status": "operational",<br>
|
| 191 |
+
"lastTradeTime": "2023-07-20T12:34:56Z",<br>
|
| 192 |
+
"cpuLoad": 35.2,<br>
|
| 193 |
+
"memoryUsage": 45.8,<br>
|
| 194 |
+
"activeSymbols": ["EURUSD", "GBPUSD"]<br>
|
| 195 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
</div>
|
| 197 |
</div>
|
| 198 |
</section>
|
| 199 |
|
| 200 |
+
<!-- Database Schema -->
|
| 201 |
<section>
|
| 202 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">Database Schema</h2>
|
| 203 |
+
<div class="bg-gray-50 p-5 rounded-lg">
|
| 204 |
+
<div class="grid md:grid-cols-2 gap-6">
|
| 205 |
+
<div>
|
| 206 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">Trades Table</h3>
|
| 207 |
+
<div class="code-container">
|
| 208 |
+
CREATE TABLE trades (<br>
|
| 209 |
+
id SERIAL PRIMARY KEY,<br>
|
| 210 |
+
symbol VARCHAR(10) NOT NULL,<br>
|
| 211 |
+
direction VARCHAR(4) NOT NULL,<br>
|
| 212 |
+
entry_price DECIMAL(10,5) NOT NULL,<br>
|
| 213 |
+
sl_price DECIMAL(10,5) NOT NULL,<br>
|
| 214 |
+
tp_price DECIMAL(10,5) NOT NULL,<br>
|
| 215 |
+
lot_size DECIMAL(10,2) NOT NULL,<br>
|
| 216 |
+
risk_percent DECIMAL(5,2) NOT NULL,<br>
|
| 217 |
+
status VARCHAR(10) NOT NULL,<br>
|
| 218 |
+
open_time TIMESTAMP NOT NULL,<br>
|
| 219 |
+
close_time TIMESTAMP,<br>
|
| 220 |
+
profit DECIMAL(10,2)<br>
|
| 221 |
+
);
|
| 222 |
</div>
|
| 223 |
+
</div>
|
| 224 |
+
<div>
|
| 225 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">Market Data Table</h3>
|
| 226 |
+
<div class="code-container">
|
| 227 |
+
CREATE TABLE market_data (<br>
|
| 228 |
+
id SERIAL PRIMARY KEY,<br>
|
| 229 |
+
symbol VARCHAR(10) NOT NULL,<br>
|
| 230 |
+
timeframe VARCHAR(5) NOT NULL,<br>
|
| 231 |
+
timestamp TIMESTAMP NOT NULL,<br>
|
| 232 |
+
open DECIMAL(10,5) NOT NULL,<br>
|
| 233 |
+
high DECIMAL(10,5) NOT NULL,<br>
|
| 234 |
+
low DECIMAL(10,5) NOT NULL,<br>
|
| 235 |
+
close DECIMAL(10,5) NOT NULL,<br>
|
| 236 |
+
volume INTEGER NOT NULL,<br>
|
| 237 |
+
pivot_type SMALLINT<br>
|
| 238 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
</div>
|
| 240 |
+
</div>
|
| 241 |
+
</div>
|
|
|
|
| 242 |
</div>
|
| 243 |
</section>
|
| 244 |
</div>
|
|
|
|
| 252 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-2 text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 253 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
| 254 |
</svg>
|
| 255 |
+
<span class="text-xl font-bold">SMC Trading Bot</span>
|
| 256 |
</div>
|
| 257 |
+
<p class="text-gray-400 mt-1">Professional backend infrastructure</p>
|
| 258 |
</div>
|
| 259 |
<div class="flex space-x-4">
|
| 260 |
<a href="index.html" class="text-gray-300 hover:text-white">Home</a>
|
|
@@ -35,13 +35,13 @@
|
|
| 35 |
<i data-feather="trending-up" class="text-blue-600"></i>
|
| 36 |
<span class="text-xl font-bold text-gray-800">Forex AutoPilot</span>
|
| 37 |
</div>
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
<i data-feather="menu"></i>
|
| 46 |
</button>
|
| 47 |
</div>
|
|
@@ -192,10 +192,10 @@
|
|
| 192 |
<h3 class="text-lg font-bold mb-4">Resources</h3>
|
| 193 |
<ul class="space-y-2">
|
| 194 |
<li><a href="bots.html" class="text-gray-400 hover:text-white">How Bots Work</a></li>
|
| 195 |
-
<li><a href="smc-bot-mql5.html" class="text-gray-400 hover:text-white">MQL5
|
| 196 |
-
<li><a href="
|
| 197 |
</ul>
|
| 198 |
-
|
| 199 |
<div>
|
| 200 |
<h3 class="text-lg font-bold mb-4">Connect With Us</h3>
|
| 201 |
<div class="flex space-x-4">
|
|
|
|
| 35 |
<i data-feather="trending-up" class="text-blue-600"></i>
|
| 36 |
<span class="text-xl font-bold text-gray-800">Forex AutoPilot</span>
|
| 37 |
</div>
|
| 38 |
+
<div class="hidden md:flex space-x-6">
|
| 39 |
+
<a href="index.html" class="text-gray-600 hover:text-blue-600">Home</a>
|
| 40 |
+
<a href="bots.html" class="text-blue-600 font-medium">How Bots Work</a>
|
| 41 |
+
<a href="smc-bot-mql5.html" class="text-gray-600 hover:text-blue-600">MQL5 Core</a>
|
| 42 |
+
<a href="backend.html" class="text-gray-600 hover:text-blue-600">Backend</a>
|
| 43 |
+
</div>
|
| 44 |
+
<button class="md:hidden">
|
| 45 |
<i data-feather="menu"></i>
|
| 46 |
</button>
|
| 47 |
</div>
|
|
|
|
| 192 |
<h3 class="text-lg font-bold mb-4">Resources</h3>
|
| 193 |
<ul class="space-y-2">
|
| 194 |
<li><a href="bots.html" class="text-gray-400 hover:text-white">How Bots Work</a></li>
|
| 195 |
+
<li><a href="smc-bot-mql5.html" class="text-gray-400 hover:text-white">MQL5 Core</a></li>
|
| 196 |
+
<li><a href="backend.html" class="text-gray-400 hover:text-white">Backend</a></li>
|
| 197 |
</ul>
|
| 198 |
+
</div>
|
| 199 |
<div>
|
| 200 |
<h3 class="text-lg font-bold mb-4">Connect With Us</h3>
|
| 201 |
<div class="flex space-x-4">
|
|
@@ -292,7 +292,7 @@
|
|
| 292 |
<a href="smc-bot-mql5.html" class="text-blue-400 font-medium">MQL5 Core</a>
|
| 293 |
<a href="backend.html" class="text-gray-300 hover:text-white">Backend</a>
|
| 294 |
</div>
|
| 295 |
-
|
| 296 |
<div class="border-t border-gray-700 mt-4 pt-4 text-center text-gray-400">
|
| 297 |
<p>© 2023 Forex AutoPilot. All rights reserved.</p>
|
| 298 |
</div>
|
|
|
|
| 292 |
<a href="smc-bot-mql5.html" class="text-blue-400 font-medium">MQL5 Core</a>
|
| 293 |
<a href="backend.html" class="text-gray-300 hover:text-white">Backend</a>
|
| 294 |
</div>
|
| 295 |
+
</div>
|
| 296 |
<div class="border-t border-gray-700 mt-4 pt-4 text-center text-gray-400">
|
| 297 |
<p>© 2023 Forex AutoPilot. All rights reserved.</p>
|
| 298 |
</div>
|