romeo-v8-super-ensemble-trading-ai / XAUUSD_Trading_AI_Technical_Whitepaper.html
JonusNattapong's picture
Upload XAUUSD_Trading_AI_Technical_Whitepaper.html with huggingface_hub
a6a9c3b verified
raw
history blame
146 kB
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>XAUUSD_Trading_AI_Technical_Whitepaper</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
font-size: inherit;
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
html { -webkit-text-size-adjust: 100%; }
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; }
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.at { color: #7d9029; }
code span.bn { color: #40a070; }
code span.bu { color: #008000; }
code span.cf { color: #007020; font-weight: bold; }
code span.ch { color: #4070a0; }
code span.cn { color: #880000; }
code span.co { color: #60a0b0; font-style: italic; }
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.do { color: #ba2121; font-style: italic; }
code span.dt { color: #902000; }
code span.dv { color: #40a070; }
code span.er { color: #ff0000; font-weight: bold; }
code span.ex { }
code span.fl { color: #40a070; }
code span.fu { color: #06287e; }
code span.im { color: #008000; font-weight: bold; }
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.kw { color: #007020; font-weight: bold; }
code span.op { color: #666666; }
code span.ot { color: #007020; }
code span.pp { color: #bc7a00; }
code span.sc { color: #4070a0; }
code span.ss { color: #bb6688; }
code span.st { color: #4070a0; }
code span.va { color: #19177c; }
code span.vs { color: #4070a0; }
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
</style>
<link href="data:text/css; charset=utf-8;charset=utf-8,%0A%2Emarkdown%2Dbody%7B%2D%2Dbase%2Dsize%2D4%3A0%2E25rem%3B%2D%2Dbase%2Dsize%2D8%3A0%2E5rem%3B%2D%2Dbase%2Dsize%2D16%3A1rem%3B%2D%2Dbase%2Dsize%2D24%3A1%2E5rem%3B%2D%2Dbase%2Dsize%2D40%3A2%2E5rem%3B%2D%2Dbase%2Dtext%2Dweight%2Dnormal%3A400%3B%2D%2Dbase%2Dtext%2Dweight%2Dmedium%3A500%3B%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%3A600%3B%2D%2DfontStack%2Dmonospace%3Aui%2Dmonospace%2CSFMono%2DRegular%2CSF%20Mono%2CMenlo%2CConsolas%2CLiberation%20Mono%2Cmonospace%3B%2D%2DfgColor%2Daccent%3AHighlight%7D%40media%20%28prefers%2Dcolor%2Dscheme%3Adark%29%7B%2Emarkdown%2Dbody%2C%5Bdata%2Dtheme%3Ddark%5D%7Bcolor%2Dscheme%3Adark%3B%2D%2Dfocus%2DoutlineColor%3A%231f6feb%3B%2D%2DfgColor%2Ddefault%3A%23f0f6fc%3B%2D%2DfgColor%2Dmuted%3A%239198a1%3B%2D%2DfgColor%2Daccent%3A%234493f8%3B%2D%2DfgColor%2Dsuccess%3A%233fb950%3B%2D%2DfgColor%2Dattention%3A%23d29922%3B%2D%2DfgColor%2Ddanger%3A%23f85149%3B%2D%2DfgColor%2Ddone%3A%23ab7df8%3B%2D%2DbgColor%2Ddefault%3A%230d1117%3B%2D%2DbgColor%2Dmuted%3A%23151b23%3B%2D%2DbgColor%2Dneutral%2Dmuted%3A%23656c7633%3B%2D%2DbgColor%2Dattention%2Dmuted%3A%23bb800926%3B%2D%2DborderColor%2Ddefault%3A%233d444d%3B%2D%2DborderColor%2Dmuted%3A%233d444db3%3B%2D%2DborderColor%2Dneutral%2Dmuted%3A%233d444db3%3B%2D%2DborderColor%2Daccent%2Demphasis%3A%231f6feb%3B%2D%2DborderColor%2Dsuccess%2Demphasis%3A%23238636%3B%2D%2DborderColor%2Dattention%2Demphasis%3A%239e6a03%3B%2D%2DborderColor%2Ddanger%2Demphasis%3A%23da3633%3B%2D%2DborderColor%2Ddone%2Demphasis%3A%238957e5%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcomment%3A%239198a1%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%3A%2379c0ff%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%2Dother%2Dreference%2Dlink%3A%23a5d6ff%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%3A%23d2a8ff%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstorage%2Dmodifier%2Dimport%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%2Dtag%3A%237ee787%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dkeyword%3A%23ff7b72%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%3A%23a5d6ff%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dvariable%3A%23ffa657%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dunmatched%3A%23f85149%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dangle%3A%239198a1%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dtext%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dbg%3A%238e1519%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dtext%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dbg%3A%23b62324%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%2Dregexp%3A%237ee787%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dlist%3A%23f2cc60%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dheading%3A%231f6feb%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ditalic%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dbold%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dtext%3A%23ffdcd7%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dbg%3A%2367060c%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dtext%3A%23aff5b4%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dbg%3A%23033a16%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dtext%3A%23ffdfb6%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dbg%3A%235a1e02%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dtext%3A%23f0f6fc%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dbg%3A%231158c7%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmeta%2Ddiff%2Drange%3A%23d2a8ff%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dsublimelinter%2Dgutter%2Dmark%3A%233d444d%7D%7D%40media%20%28prefers%2Dcolor%2Dscheme%3Alight%29%7B%2Emarkdown%2Dbody%2C%5Bdata%2Dtheme%3Dlight%5D%7Bcolor%2Dscheme%3Alight%3B%2D%2Dfocus%2DoutlineColor%3A%230969da%3B%2D%2DfgColor%2Ddefault%3A%231f2328%3B%2D%2DfgColor%2Dmuted%3A%2359636e%3B%2D%2DfgColor%2Daccent%3A%230969da%3B%2D%2DfgColor%2Dsuccess%3A%231a7f37%3B%2D%2DfgColor%2Dattention%3A%239a6700%3B%2D%2DfgColor%2Ddanger%3A%23d1242f%3B%2D%2DfgColor%2Ddone%3A%238250df%3B%2D%2DbgColor%2Ddefault%3A%23ffffff%3B%2D%2DbgColor%2Dmuted%3A%23f6f8fa%3B%2D%2DbgColor%2Dneutral%2Dmuted%3A%23818b981f%3B%2D%2DbgColor%2Dattention%2Dmuted%3A%23fff8c5%3B%2D%2DborderColor%2Ddefault%3A%23d1d9e0%3B%2D%2DborderColor%2Dmuted%3A%23d1d9e0b3%3B%2D%2DborderColor%2Dneutral%2Dmuted%3A%23d1d9e0b3%3B%2D%2DborderColor%2Daccent%2Demphasis%3A%230969da%3B%2D%2DborderColor%2Dsuccess%2Demphasis%3A%231a7f37%3B%2D%2DborderColor%2Dattention%2Demphasis%3A%239a6700%3B%2D%2DborderColor%2Ddanger%2Demphasis%3A%23cf222e%3B%2D%2DborderColor%2Ddone%2Demphasis%3A%238250df%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcomment%3A%2359636e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%3A%230550ae%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%2Dother%2Dreference%2Dlink%3A%230a3069%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%3A%236639ba%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstorage%2Dmodifier%2Dimport%3A%231f2328%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%2Dtag%3A%230550ae%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dkeyword%3A%23cf222e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%3A%230a3069%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dvariable%3A%23953800%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dunmatched%3A%2382071e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dangle%3A%2359636e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dtext%3A%23f6f8fa%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dbg%3A%2382071e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dtext%3A%23f6f8fa%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dbg%3A%23cf222e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%2Dregexp%3A%23116329%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dlist%3A%233b2300%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dheading%3A%230550ae%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ditalic%3A%231f2328%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dbold%3A%231f2328%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dtext%3A%2382071e%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dbg%3A%23ffebe9%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dtext%3A%23116329%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dbg%3A%23dafbe1%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dtext%3A%23953800%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dbg%3A%23ffd8b5%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dtext%3A%23d1d9e0%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dbg%3A%230550ae%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmeta%2Ddiff%2Drange%3A%238250df%3B%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dsublimelinter%2Dgutter%2Dmark%3A%23818b98%7D%7D%2Emarkdown%2Dbody%7B%2Dms%2Dtext%2Dsize%2Dadjust%3A100%25%3B%2Dwebkit%2Dtext%2Dsize%2Dadjust%3A100%25%3Bmargin%3A0%3Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%3Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Ddefault%29%3Bfont%2Dfamily%3A%2Dapple%2Dsystem%2CBlinkMacSystemFont%2C%22Segoe%20UI%22%2C%22Noto%20Sans%22%2CHelvetica%2CArial%2Csans%2Dserif%2C%22Apple%20Color%20Emoji%22%2C%22Segoe%20UI%20Emoji%22%3Bfont%2Dsize%3A16px%3Bline%2Dheight%3A1%2E5%3Bword%2Dwrap%3Abreak%2Dword%7D%2Emarkdown%2Dbody%20%2Eocticon%7Bdisplay%3Ainline%2Dblock%3Bfill%3AcurrentColor%3Bvertical%2Dalign%3Atext%2Dbottom%7D%2Emarkdown%2Dbody%20h1%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%2C%2Emarkdown%2Dbody%20h2%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%2C%2Emarkdown%2Dbody%20h3%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%2C%2Emarkdown%2Dbody%20h4%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%2C%2Emarkdown%2Dbody%20h5%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%2C%2Emarkdown%2Dbody%20h6%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%3Abefore%7Bwidth%3A16px%3Bheight%3A16px%3Bcontent%3A%27%20%27%3Bdisplay%3Ainline%2Dblock%3Bbackground%2Dcolor%3AcurrentColor%3B%2Dwebkit%2Dmask%2Dimage%3Aurl%28%22data%3Aimage%2Fsvg%2Bxml%2C%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%27%20viewBox%3D%270%200%2016%2016%27%20version%3D%271%2E1%27%20aria%2Dhidden%3D%27true%27%3E%3Cpath%20fill%2Drule%3D%27evenodd%27%20d%3D%27M7%2E775%203%2E275a%2E75%2E75%200%20001%2E06%201%2E06l1%2E25%2D1%2E25a2%202%200%20112%2E83%202%2E83l%2D2%2E5%202%2E5a2%202%200%2001%2D2%2E83%200%20%2E75%2E75%200%2000%2D1%2E06%201%2E06%203%2E5%203%2E5%200%20004%2E95%200l2%2E5%2D2%2E5a3%2E5%203%2E5%200%2000%2D4%2E95%2D4%2E95l%2D1%2E25%201%2E25zm%2D4%2E69%209%2E64a2%202%200%20010%2D2%2E83l2%2E5%2D2%2E5a2%202%200%20012%2E83%200%20%2E75%2E75%200%20001%2E06%2D1%2E06%203%2E5%203%2E5%200%2000%2D4%2E95%200l%2D2%2E5%202%2E5a3%2E5%203%2E5%200%20004%2E95%204%2E95l1%2E25%2D1%2E25a%2E75%2E75%200%2000%2D1%2E06%2D1%2E06l%2D1%2E25%201%2E25a2%202%200%2001%2D2%2E83%200z%27%3E%3C%2Fpath%3E%3C%2Fsvg%3E%22%29%3Bmask%2Dimage%3Aurl%28%22data%3Aimage%2Fsvg%2Bxml%2C%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%27%20viewBox%3D%270%200%2016%2016%27%20version%3D%271%2E1%27%20aria%2Dhidden%3D%27true%27%3E%3Cpath%20fill%2Drule%3D%27evenodd%27%20d%3D%27M7%2E775%203%2E275a%2E75%2E75%200%20001%2E06%201%2E06l1%2E25%2D1%2E25a2%202%200%20112%2E83%202%2E83l%2D2%2E5%202%2E5a2%202%200%2001%2D2%2E83%200%20%2E75%2E75%200%2000%2D1%2E06%201%2E06%203%2E5%203%2E5%200%20004%2E95%200l2%2E5%2D2%2E5a3%2E5%203%2E5%200%2000%2D4%2E95%2D4%2E95l%2D1%2E25%201%2E25zm%2D4%2E69%209%2E64a2%202%200%20010%2D2%2E83l2%2E5%2D2%2E5a2%202%200%20012%2E83%200%20%2E75%2E75%200%20001%2E06%2D1%2E06%203%2E5%203%2E5%200%2000%2D4%2E95%200l%2D2%2E5%202%2E5a3%2E5%203%2E5%200%20004%2E95%204%2E95l1%2E25%2D1%2E25a%2E75%2E75%200%2000%2D1%2E06%2D1%2E06l%2D1%2E25%201%2E25a2%202%200%2001%2D2%2E83%200z%27%3E%3C%2Fpath%3E%3C%2Fsvg%3E%22%29%7D%2Emarkdown%2Dbody%20details%2C%2Emarkdown%2Dbody%20figcaption%2C%2Emarkdown%2Dbody%20figure%7Bdisplay%3Ablock%7D%2Emarkdown%2Dbody%20summary%7Bdisplay%3Alist%2Ditem%7D%2Emarkdown%2Dbody%20%5Bhidden%5D%7Bdisplay%3Anone%21important%7D%2Emarkdown%2Dbody%20a%7Bbackground%2Dcolor%3Atransparent%3Bcolor%3Avar%28%2D%2DfgColor%2Daccent%29%3Btext%2Ddecoration%3Anone%7D%2Emarkdown%2Dbody%20abbr%5Btitle%5D%7Bborder%2Dbottom%3Anone%3B%2Dwebkit%2Dtext%2Ddecoration%3Aunderline%20dotted%3Btext%2Ddecoration%3Aunderline%20dotted%7D%2Emarkdown%2Dbody%20b%2C%2Emarkdown%2Dbody%20strong%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%7D%2Emarkdown%2Dbody%20dfn%7Bfont%2Dstyle%3Aitalic%7D%2Emarkdown%2Dbody%20h1%7Bmargin%3A%2E67em%200%3Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bpadding%2Dbottom%3A%2E3em%3Bfont%2Dsize%3A2em%3Bborder%2Dbottom%3A1px%20solid%20var%28%2D%2DborderColor%2Dmuted%29%7D%2Emarkdown%2Dbody%20mark%7Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Dattention%2Dmuted%29%3Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20small%7Bfont%2Dsize%3A90%25%7D%2Emarkdown%2Dbody%20sub%2C%2Emarkdown%2Dbody%20sup%7Bfont%2Dsize%3A75%25%3Bline%2Dheight%3A0%3Bposition%3Arelative%3Bvertical%2Dalign%3Abaseline%7D%2Emarkdown%2Dbody%20sub%7Bbottom%3A%2D%2E25em%7D%2Emarkdown%2Dbody%20sup%7Btop%3A%2D%2E5em%7D%2Emarkdown%2Dbody%20img%7Bborder%2Dstyle%3Anone%3Bmax%2Dwidth%3A100%25%3Bbox%2Dsizing%3Acontent%2Dbox%7D%2Emarkdown%2Dbody%20code%2C%2Emarkdown%2Dbody%20kbd%2C%2Emarkdown%2Dbody%20pre%2C%2Emarkdown%2Dbody%20samp%7Bfont%2Dfamily%3Amonospace%3Bfont%2Dsize%3A1em%7D%2Emarkdown%2Dbody%20figure%7Bmargin%3A1em%20var%28%2D%2Dbase%2Dsize%2D40%29%7D%2Emarkdown%2Dbody%20hr%7Bbox%2Dsizing%3Acontent%2Dbox%3Boverflow%3Ahidden%3Bbackground%3A0%200%3Bborder%2Dbottom%3A1px%20solid%20var%28%2D%2DborderColor%2Dmuted%29%3Bheight%3A%2E25em%3Bpadding%3A0%3Bmargin%3Avar%28%2D%2Dbase%2Dsize%2D24%29%200%3Bbackground%2Dcolor%3Avar%28%2D%2DborderColor%2Ddefault%29%3Bborder%3A0%7D%2Emarkdown%2Dbody%20input%7Bfont%3Ainherit%3Bmargin%3A0%3Boverflow%3Avisible%3Bfont%2Dfamily%3Ainherit%3Bfont%2Dsize%3Ainherit%3Bline%2Dheight%3Ainherit%7D%2Emarkdown%2Dbody%20%5Btype%3Dbutton%5D%2C%2Emarkdown%2Dbody%20%5Btype%3Dreset%5D%2C%2Emarkdown%2Dbody%20%5Btype%3Dsubmit%5D%7B%2Dwebkit%2Dappearance%3Abutton%3Bappearance%3Abutton%7D%2Emarkdown%2Dbody%20%5Btype%3Dcheckbox%5D%2C%2Emarkdown%2Dbody%20%5Btype%3Dradio%5D%7Bbox%2Dsizing%3Aborder%2Dbox%3Bpadding%3A0%7D%2Emarkdown%2Dbody%20%5Btype%3Dnumber%5D%3A%3A%2Dwebkit%2Dinner%2Dspin%2Dbutton%2C%2Emarkdown%2Dbody%20%5Btype%3Dnumber%5D%3A%3A%2Dwebkit%2Douter%2Dspin%2Dbutton%7Bheight%3Aauto%7D%2Emarkdown%2Dbody%20%5Btype%3Dsearch%5D%3A%3A%2Dwebkit%2Dsearch%2Dcancel%2Dbutton%2C%2Emarkdown%2Dbody%20%5Btype%3Dsearch%5D%3A%3A%2Dwebkit%2Dsearch%2Ddecoration%7B%2Dwebkit%2Dappearance%3Anone%3Bappearance%3Anone%7D%2Emarkdown%2Dbody%20%3A%3A%2Dwebkit%2Dinput%2Dplaceholder%7Bcolor%3Ainherit%3Bopacity%3A%2E54%7D%2Emarkdown%2Dbody%20%3A%3A%2Dwebkit%2Dfile%2Dupload%2Dbutton%7B%2Dwebkit%2Dappearance%3Abutton%3Bappearance%3Abutton%3Bfont%3Ainherit%7D%2Emarkdown%2Dbody%20a%3Ahover%7Btext%2Ddecoration%3Aunderline%7D%2Emarkdown%2Dbody%20%3A%3Aplaceholder%7Bcolor%3Avar%28%2D%2DfgColor%2Dmuted%29%3Bopacity%3A1%7D%2Emarkdown%2Dbody%20hr%3A%3Abefore%7Bdisplay%3Atable%3Bcontent%3A%22%22%7D%2Emarkdown%2Dbody%20hr%3A%3Aafter%7Bdisplay%3Atable%3Bclear%3Aboth%3Bcontent%3A%22%22%7D%2Emarkdown%2Dbody%20table%7Bborder%2Dspacing%3A0%3Bborder%2Dcollapse%3Acollapse%3Bdisplay%3Ablock%3Bwidth%3Amax%2Dcontent%3Bmax%2Dwidth%3A100%25%3Boverflow%3Aauto%3Bfont%2Dvariant%3Atabular%2Dnums%7D%2Emarkdown%2Dbody%20td%2C%2Emarkdown%2Dbody%20th%7Bpadding%3A0%7D%2Emarkdown%2Dbody%20details%20summary%7Bcursor%3Apointer%7D%2Emarkdown%2Dbody%20%5Brole%3Dbutton%5D%3Afocus%2C%2Emarkdown%2Dbody%20a%3Afocus%2C%2Emarkdown%2Dbody%20input%5Btype%3Dcheckbox%5D%3Afocus%2C%2Emarkdown%2Dbody%20input%5Btype%3Dradio%5D%3Afocus%7Boutline%3A2px%20solid%20var%28%2D%2Dfocus%2DoutlineColor%29%3Boutline%2Doffset%3A%2D2px%3Bbox%2Dshadow%3Anone%7D%2Emarkdown%2Dbody%20%5Brole%3Dbutton%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20a%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20input%5Btype%3Dcheckbox%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20input%5Btype%3Dradio%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%7Boutline%3Asolid%201px%20transparent%7D%2Emarkdown%2Dbody%20%5Brole%3Dbutton%5D%3Afocus%2Dvisible%2C%2Emarkdown%2Dbody%20a%3Afocus%2Dvisible%2C%2Emarkdown%2Dbody%20input%5Btype%3Dcheckbox%5D%3Afocus%2Dvisible%2C%2Emarkdown%2Dbody%20input%5Btype%3Dradio%5D%3Afocus%2Dvisible%7Boutline%3A2px%20solid%20var%28%2D%2Dfocus%2DoutlineColor%29%3Boutline%2Doffset%3A%2D2px%3Bbox%2Dshadow%3Anone%7D%2Emarkdown%2Dbody%20a%3Anot%28%5Bclass%5D%29%3Afocus%2C%2Emarkdown%2Dbody%20a%3Anot%28%5Bclass%5D%29%3Afocus%2Dvisible%2C%2Emarkdown%2Dbody%20input%5Btype%3Dcheckbox%5D%3Afocus%2C%2Emarkdown%2Dbody%20input%5Btype%3Dcheckbox%5D%3Afocus%2Dvisible%2C%2Emarkdown%2Dbody%20input%5Btype%3Dradio%5D%3Afocus%2C%2Emarkdown%2Dbody%20input%5Btype%3Dradio%5D%3Afocus%2Dvisible%7Boutline%2Doffset%3A0%7D%2Emarkdown%2Dbody%20kbd%7Bdisplay%3Ainline%2Dblock%3Bpadding%3Avar%28%2D%2Dbase%2Dsize%2D4%29%3Bfont%3A11px%20var%28%2D%2DfontStack%2Dmonospace%2C%20ui%2Dmonospace%2C%20SFMono%2DRegular%2C%20SF%20Mono%2C%20Menlo%2C%20Consolas%2C%20Liberation%20Mono%2C%20monospace%29%3Bline%2Dheight%3A10px%3Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%3Bvertical%2Dalign%3Amiddle%3Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Dmuted%29%3Bborder%3Asolid%201px%20var%28%2D%2DborderColor%2Dneutral%2Dmuted%29%3Bborder%2Dbottom%2Dcolor%3Avar%28%2D%2DborderColor%2Dneutral%2Dmuted%29%3Bborder%2Dradius%3A6px%3Bbox%2Dshadow%3Ainset%200%20%2D1px%200%20var%28%2D%2DborderColor%2Dneutral%2Dmuted%29%7D%2Emarkdown%2Dbody%20h1%2C%2Emarkdown%2Dbody%20h2%2C%2Emarkdown%2Dbody%20h3%2C%2Emarkdown%2Dbody%20h4%2C%2Emarkdown%2Dbody%20h5%2C%2Emarkdown%2Dbody%20h6%7Bmargin%2Dtop%3Avar%28%2D%2Dbase%2Dsize%2D24%29%3Bmargin%2Dbottom%3Avar%28%2D%2Dbase%2Dsize%2D16%29%3Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bline%2Dheight%3A1%2E25%7D%2Emarkdown%2Dbody%20h2%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bpadding%2Dbottom%3A%2E3em%3Bfont%2Dsize%3A1%2E5em%3Bborder%2Dbottom%3A1px%20solid%20var%28%2D%2DborderColor%2Dmuted%29%7D%2Emarkdown%2Dbody%20h3%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bfont%2Dsize%3A1%2E25em%7D%2Emarkdown%2Dbody%20h4%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bfont%2Dsize%3A1em%7D%2Emarkdown%2Dbody%20h5%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bfont%2Dsize%3A%2E875em%7D%2Emarkdown%2Dbody%20h6%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bfont%2Dsize%3A%2E85em%3Bcolor%3Avar%28%2D%2DfgColor%2Dmuted%29%7D%2Emarkdown%2Dbody%20p%7Bmargin%2Dtop%3A0%3Bmargin%2Dbottom%3A10px%7D%2Emarkdown%2Dbody%20blockquote%7Bmargin%3A0%3Bpadding%3A0%201em%3Bcolor%3Avar%28%2D%2DfgColor%2Dmuted%29%3Bborder%2Dleft%3A%2E25em%20solid%20var%28%2D%2DborderColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20ol%2C%2Emarkdown%2Dbody%20ul%7Bmargin%2Dtop%3A0%3Bmargin%2Dbottom%3A0%3Bpadding%2Dleft%3A2em%7D%2Emarkdown%2Dbody%20ol%20ol%2C%2Emarkdown%2Dbody%20ul%20ol%7Blist%2Dstyle%2Dtype%3Alower%2Droman%7D%2Emarkdown%2Dbody%20ol%20ol%20ol%2C%2Emarkdown%2Dbody%20ol%20ul%20ol%2C%2Emarkdown%2Dbody%20ul%20ol%20ol%2C%2Emarkdown%2Dbody%20ul%20ul%20ol%7Blist%2Dstyle%2Dtype%3Alower%2Dalpha%7D%2Emarkdown%2Dbody%20dd%7Bmargin%2Dleft%3A0%7D%2Emarkdown%2Dbody%20code%2C%2Emarkdown%2Dbody%20samp%2C%2Emarkdown%2Dbody%20tt%7Bfont%2Dfamily%3Avar%28%2D%2DfontStack%2Dmonospace%2C%20ui%2Dmonospace%2C%20SFMono%2DRegular%2C%20SF%20Mono%2C%20Menlo%2C%20Consolas%2C%20Liberation%20Mono%2C%20monospace%29%3Bfont%2Dsize%3A12px%7D%2Emarkdown%2Dbody%20pre%7Bmargin%2Dtop%3A0%3Bmargin%2Dbottom%3A0%3Bfont%2Dfamily%3Avar%28%2D%2DfontStack%2Dmonospace%2C%20ui%2Dmonospace%2C%20SFMono%2DRegular%2C%20SF%20Mono%2C%20Menlo%2C%20Consolas%2C%20Liberation%20Mono%2C%20monospace%29%3Bfont%2Dsize%3A12px%3Bword%2Dwrap%3Anormal%7D%2Emarkdown%2Dbody%20%2Eocticon%7Bdisplay%3Ainline%2Dblock%3Boverflow%3Avisible%21important%3Bvertical%2Dalign%3Atext%2Dbottom%3Bfill%3AcurrentColor%7D%2Emarkdown%2Dbody%20input%3A%3A%2Dwebkit%2Dinner%2Dspin%2Dbutton%2C%2Emarkdown%2Dbody%20input%3A%3A%2Dwebkit%2Douter%2Dspin%2Dbutton%7Bmargin%3A0%3Bappearance%3Anone%7D%2Emarkdown%2Dbody%20%2Emr%2D2%7Bmargin%2Dright%3Avar%28%2D%2Dbase%2Dsize%2D8%2C8px%29%21important%7D%2Emarkdown%2Dbody%3A%3Abefore%7Bdisplay%3Atable%3Bcontent%3A%22%22%7D%2Emarkdown%2Dbody%3A%3Aafter%7Bdisplay%3Atable%3Bclear%3Aboth%3Bcontent%3A%22%22%7D%2Emarkdown%2Dbody%3E%3Afirst%2Dchild%7Bmargin%2Dtop%3A0%21important%7D%2Emarkdown%2Dbody%3E%3Alast%2Dchild%7Bmargin%2Dbottom%3A0%21important%7D%2Emarkdown%2Dbody%20a%3Anot%28%5Bhref%5D%29%7Bcolor%3Ainherit%3Btext%2Ddecoration%3Anone%7D%2Emarkdown%2Dbody%20%2Eabsent%7Bcolor%3Avar%28%2D%2DfgColor%2Ddanger%29%7D%2Emarkdown%2Dbody%20%2Eanchor%7Bfloat%3Aleft%3Bpadding%2Dright%3Avar%28%2D%2Dbase%2Dsize%2D4%29%3Bmargin%2Dleft%3A%2D20px%3Bline%2Dheight%3A1%7D%2Emarkdown%2Dbody%20%2Eanchor%3Afocus%7Boutline%3A0%7D%2Emarkdown%2Dbody%20blockquote%2C%2Emarkdown%2Dbody%20details%2C%2Emarkdown%2Dbody%20dl%2C%2Emarkdown%2Dbody%20ol%2C%2Emarkdown%2Dbody%20p%2C%2Emarkdown%2Dbody%20pre%2C%2Emarkdown%2Dbody%20table%2C%2Emarkdown%2Dbody%20ul%7Bmargin%2Dtop%3A0%3Bmargin%2Dbottom%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20blockquote%3E%3Afirst%2Dchild%7Bmargin%2Dtop%3A0%7D%2Emarkdown%2Dbody%20blockquote%3E%3Alast%2Dchild%7Bmargin%2Dbottom%3A0%7D%2Emarkdown%2Dbody%20h1%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h2%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h3%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h4%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h5%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h6%20%2Eocticon%2Dlink%7Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%3Bvertical%2Dalign%3Amiddle%3Bvisibility%3Ahidden%7D%2Emarkdown%2Dbody%20h1%3Ahover%20%2Eanchor%2C%2Emarkdown%2Dbody%20h2%3Ahover%20%2Eanchor%2C%2Emarkdown%2Dbody%20h3%3Ahover%20%2Eanchor%2C%2Emarkdown%2Dbody%20h4%3Ahover%20%2Eanchor%2C%2Emarkdown%2Dbody%20h5%3Ahover%20%2Eanchor%2C%2Emarkdown%2Dbody%20h6%3Ahover%20%2Eanchor%7Btext%2Ddecoration%3Anone%7D%2Emarkdown%2Dbody%20h1%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h2%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h3%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h4%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h5%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%2C%2Emarkdown%2Dbody%20h6%3Ahover%20%2Eanchor%20%2Eocticon%2Dlink%7Bvisibility%3Avisible%7D%2Emarkdown%2Dbody%20h1%20code%2C%2Emarkdown%2Dbody%20h1%20tt%2C%2Emarkdown%2Dbody%20h2%20code%2C%2Emarkdown%2Dbody%20h2%20tt%2C%2Emarkdown%2Dbody%20h3%20code%2C%2Emarkdown%2Dbody%20h3%20tt%2C%2Emarkdown%2Dbody%20h4%20code%2C%2Emarkdown%2Dbody%20h4%20tt%2C%2Emarkdown%2Dbody%20h5%20code%2C%2Emarkdown%2Dbody%20h5%20tt%2C%2Emarkdown%2Dbody%20h6%20code%2C%2Emarkdown%2Dbody%20h6%20tt%7Bpadding%3A0%20%2E2em%3Bfont%2Dsize%3Ainherit%7D%2Emarkdown%2Dbody%20summary%20h1%2C%2Emarkdown%2Dbody%20summary%20h2%2C%2Emarkdown%2Dbody%20summary%20h3%2C%2Emarkdown%2Dbody%20summary%20h4%2C%2Emarkdown%2Dbody%20summary%20h5%2C%2Emarkdown%2Dbody%20summary%20h6%7Bdisplay%3Ainline%2Dblock%7D%2Emarkdown%2Dbody%20summary%20h1%20%2Eanchor%2C%2Emarkdown%2Dbody%20summary%20h2%20%2Eanchor%2C%2Emarkdown%2Dbody%20summary%20h3%20%2Eanchor%2C%2Emarkdown%2Dbody%20summary%20h4%20%2Eanchor%2C%2Emarkdown%2Dbody%20summary%20h5%20%2Eanchor%2C%2Emarkdown%2Dbody%20summary%20h6%20%2Eanchor%7Bmargin%2Dleft%3A%2D40px%7D%2Emarkdown%2Dbody%20summary%20h1%2C%2Emarkdown%2Dbody%20summary%20h2%7Bpadding%2Dbottom%3A0%3Bborder%2Dbottom%3A0%7D%2Emarkdown%2Dbody%20ol%2Eno%2Dlist%2C%2Emarkdown%2Dbody%20ul%2Eno%2Dlist%7Bpadding%3A0%3Blist%2Dstyle%2Dtype%3Anone%7D%2Emarkdown%2Dbody%20ol%5Btype%3D%22a%20s%22%5D%7Blist%2Dstyle%2Dtype%3Alower%2Dalpha%7D%2Emarkdown%2Dbody%20ol%5Btype%3D%22A%20s%22%5D%7Blist%2Dstyle%2Dtype%3Aupper%2Dalpha%7D%2Emarkdown%2Dbody%20ol%5Btype%3D%22i%20s%22%5D%7Blist%2Dstyle%2Dtype%3Alower%2Droman%7D%2Emarkdown%2Dbody%20ol%5Btype%3D%22I%20s%22%5D%7Blist%2Dstyle%2Dtype%3Aupper%2Droman%7D%2Emarkdown%2Dbody%20ol%5Btype%3D%221%22%5D%7Blist%2Dstyle%2Dtype%3Adecimal%7D%2Emarkdown%2Dbody%20div%3Eol%3Anot%28%5Btype%5D%29%7Blist%2Dstyle%2Dtype%3Adecimal%7D%2Emarkdown%2Dbody%20ol%20ol%2C%2Emarkdown%2Dbody%20ol%20ul%2C%2Emarkdown%2Dbody%20ul%20ol%2C%2Emarkdown%2Dbody%20ul%20ul%7Bmargin%2Dtop%3A0%3Bmargin%2Dbottom%3A0%7D%2Emarkdown%2Dbody%20li%3Ep%7Bmargin%2Dtop%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20li%2Bli%7Bmargin%2Dtop%3A%2E25em%7D%2Emarkdown%2Dbody%20dl%7Bpadding%3A0%7D%2Emarkdown%2Dbody%20dl%20dt%7Bpadding%3A0%3Bmargin%2Dtop%3Avar%28%2D%2Dbase%2Dsize%2D16%29%3Bfont%2Dsize%3A1em%3Bfont%2Dstyle%3Aitalic%3Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%7D%2Emarkdown%2Dbody%20dl%20dd%7Bpadding%3A0%20var%28%2D%2Dbase%2Dsize%2D16%29%3Bmargin%2Dbottom%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20table%20th%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%7D%2Emarkdown%2Dbody%20table%20td%2C%2Emarkdown%2Dbody%20table%20th%7Bpadding%3A6px%2013px%3Bborder%3A1px%20solid%20var%28%2D%2DborderColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20table%20td%3E%3Alast%2Dchild%7Bmargin%2Dbottom%3A0%7D%2Emarkdown%2Dbody%20table%20tr%7Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Ddefault%29%3Bborder%2Dtop%3A1px%20solid%20var%28%2D%2DborderColor%2Dmuted%29%7D%2Emarkdown%2Dbody%20table%20tr%3Anth%2Dchild%282n%29%7Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Dmuted%29%7D%2Emarkdown%2Dbody%20table%20img%7Bbackground%2Dcolor%3Atransparent%7D%2Emarkdown%2Dbody%20img%5Balign%3Dright%5D%7Bpadding%2Dleft%3A20px%7D%2Emarkdown%2Dbody%20img%5Balign%3Dleft%5D%7Bpadding%2Dright%3A20px%7D%2Emarkdown%2Dbody%20%2Eemoji%7Bmax%2Dwidth%3Anone%3Bvertical%2Dalign%3Atext%2Dtop%3Bbackground%2Dcolor%3Atransparent%7D%2Emarkdown%2Dbody%20span%2Eframe%7Bdisplay%3Ablock%3Boverflow%3Ahidden%7D%2Emarkdown%2Dbody%20span%2Eframe%3Espan%7Bdisplay%3Ablock%3Bfloat%3Aleft%3Bwidth%3Aauto%3Bpadding%3A7px%3Bmargin%3A13px%200%200%3Boverflow%3Ahidden%3Bborder%3A1px%20solid%20var%28%2D%2DborderColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20span%2Eframe%20span%20img%7Bdisplay%3Ablock%3Bfloat%3Aleft%7D%2Emarkdown%2Dbody%20span%2Eframe%20span%20span%7Bdisplay%3Ablock%3Bpadding%3A5px%200%200%3Bclear%3Aboth%3Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dcenter%7Bdisplay%3Ablock%3Boverflow%3Ahidden%3Bclear%3Aboth%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dcenter%3Espan%7Bdisplay%3Ablock%3Bmargin%3A13px%20auto%200%3Boverflow%3Ahidden%3Btext%2Dalign%3Acenter%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dcenter%20span%20img%7Bmargin%3A0%20auto%3Btext%2Dalign%3Acenter%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dright%7Bdisplay%3Ablock%3Boverflow%3Ahidden%3Bclear%3Aboth%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dright%3Espan%7Bdisplay%3Ablock%3Bmargin%3A13px%200%200%3Boverflow%3Ahidden%3Btext%2Dalign%3Aright%7D%2Emarkdown%2Dbody%20span%2Ealign%2Dright%20span%20img%7Bmargin%3A0%3Btext%2Dalign%3Aright%7D%2Emarkdown%2Dbody%20span%2Efloat%2Dleft%7Bdisplay%3Ablock%3Bfloat%3Aleft%3Bmargin%2Dright%3A13px%3Boverflow%3Ahidden%7D%2Emarkdown%2Dbody%20span%2Efloat%2Dleft%20span%7Bmargin%3A13px%200%200%7D%2Emarkdown%2Dbody%20span%2Efloat%2Dright%7Bdisplay%3Ablock%3Bfloat%3Aright%3Bmargin%2Dleft%3A13px%3Boverflow%3Ahidden%7D%2Emarkdown%2Dbody%20span%2Efloat%2Dright%3Espan%7Bdisplay%3Ablock%3Bmargin%3A13px%20auto%200%3Boverflow%3Ahidden%3Btext%2Dalign%3Aright%7D%2Emarkdown%2Dbody%20code%2C%2Emarkdown%2Dbody%20tt%7Bpadding%3A%2E2em%20%2E4em%3Bmargin%3A0%3Bfont%2Dsize%3A85%25%3Bwhite%2Dspace%3Abreak%2Dspaces%3Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Dneutral%2Dmuted%29%3Bborder%2Dradius%3A6px%7D%2Emarkdown%2Dbody%20code%20br%2C%2Emarkdown%2Dbody%20tt%20br%7Bdisplay%3Anone%7D%2Emarkdown%2Dbody%20del%20code%7Btext%2Ddecoration%3Ainherit%7D%2Emarkdown%2Dbody%20samp%7Bfont%2Dsize%3A85%25%7D%2Emarkdown%2Dbody%20pre%20code%7Bfont%2Dsize%3A100%25%7D%2Emarkdown%2Dbody%20pre%3Ecode%7Bpadding%3A0%3Bmargin%3A0%3Bword%2Dbreak%3Anormal%3Bwhite%2Dspace%3Apre%3Bbackground%3A0%200%3Bborder%3A0%7D%2Emarkdown%2Dbody%20%2Ehighlight%7Bmargin%2Dbottom%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20%2Ehighlight%20pre%7Bmargin%2Dbottom%3A0%3Bword%2Dbreak%3Anormal%7D%2Emarkdown%2Dbody%20%2Ehighlight%20pre%2C%2Emarkdown%2Dbody%20pre%7Bpadding%3Avar%28%2D%2Dbase%2Dsize%2D16%29%3Boverflow%3Aauto%3Bfont%2Dsize%3A85%25%3Bline%2Dheight%3A1%2E45%3Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%3Bbackground%2Dcolor%3Avar%28%2D%2DbgColor%2Dmuted%29%3Bborder%2Dradius%3A6px%7D%2Emarkdown%2Dbody%20pre%20code%2C%2Emarkdown%2Dbody%20pre%20tt%7Bdisplay%3Ainline%3Bmax%2Dwidth%3Aauto%3Bpadding%3A0%3Bmargin%3A0%3Boverflow%3Avisible%3Bline%2Dheight%3Ainherit%3Bword%2Dwrap%3Anormal%3Bbackground%2Dcolor%3Atransparent%3Bborder%3A0%7D%2Emarkdown%2Dbody%20%2Ecsv%2Ddata%20td%2C%2Emarkdown%2Dbody%20%2Ecsv%2Ddata%20th%7Bpadding%3A5px%3Boverflow%3Ahidden%3Bfont%2Dsize%3A12px%3Bline%2Dheight%3A1%3Btext%2Dalign%3Aleft%3Bwhite%2Dspace%3Anowrap%7D%2Emarkdown%2Dbody%20%2Ecsv%2Ddata%20%2Eblob%2Dnum%7Bpadding%3A10px%20var%28%2D%2Dbase%2Dsize%2D8%29%209px%3Btext%2Dalign%3Aright%3Bbackground%3Avar%28%2D%2DbgColor%2Ddefault%29%3Bborder%3A0%7D%2Emarkdown%2Dbody%20%2Ecsv%2Ddata%20tr%7Bborder%2Dtop%3A0%7D%2Emarkdown%2Dbody%20%2Ecsv%2Ddata%20th%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dsemibold%2C600%29%3Bbackground%3Avar%28%2D%2DbgColor%2Dmuted%29%3Bborder%2Dtop%3A0%7D%2Emarkdown%2Dbody%20%5Bdata%2Dfootnote%2Dref%5D%3A%3Abefore%7Bcontent%3A%22%5B%22%7D%2Emarkdown%2Dbody%20%5Bdata%2Dfootnote%2Dref%5D%3A%3Aafter%7Bcontent%3A%22%5D%22%7D%2Emarkdown%2Dbody%20%2Efootnotes%7Bfont%2Dsize%3A12px%3Bcolor%3Avar%28%2D%2DfgColor%2Dmuted%29%3Bborder%2Dtop%3A1px%20solid%20var%28%2D%2DborderColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20%2Efootnotes%20ol%7Bpadding%2Dleft%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20%2Efootnotes%20ol%20ul%7Bdisplay%3Ainline%2Dblock%3Bpadding%2Dleft%3Avar%28%2D%2Dbase%2Dsize%2D16%29%3Bmargin%2Dtop%3Avar%28%2D%2Dbase%2Dsize%2D16%29%7D%2Emarkdown%2Dbody%20%2Efootnotes%20li%7Bposition%3Arelative%7D%2Emarkdown%2Dbody%20%2Efootnotes%20li%3Atarget%3A%3Abefore%7Bposition%3Aabsolute%3Btop%3Acalc%28var%28%2D%2Dbase%2Dsize%2D8%29%2A%2D1%29%3Bright%3Acalc%28var%28%2D%2Dbase%2Dsize%2D8%29%2A%2D1%29%3Bbottom%3Acalc%28var%28%2D%2Dbase%2Dsize%2D8%29%2A%2D1%29%3Bleft%3Acalc%28var%28%2D%2Dbase%2Dsize%2D24%29%2A%2D1%29%3Bpointer%2Devents%3Anone%3Bcontent%3A%22%22%3Bborder%3A2px%20solid%20var%28%2D%2DborderColor%2Daccent%2Demphasis%29%3Bborder%2Dradius%3A6px%7D%2Emarkdown%2Dbody%20%2Efootnotes%20li%3Atarget%7Bcolor%3Avar%28%2D%2DfgColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20%2Efootnotes%20%2Edata%2Dfootnote%2Dbackref%20g%2Demoji%7Bfont%2Dfamily%3Amonospace%7D%2Emarkdown%2Dbody%20body%3Ahas%28%3Amodal%29%7Bpadding%2Dright%3Avar%28%2D%2Ddialog%2Dscrollgutter%29%21important%7D%2Emarkdown%2Dbody%20%2Epl%2Dc%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcomment%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dc1%2C%2Emarkdown%2Dbody%20%2Epl%2Ds%20%2Epl%2Dv%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%29%7D%2Emarkdown%2Dbody%20%2Epl%2De%2C%2Emarkdown%2Dbody%20%2Epl%2Den%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%29%7D%2Emarkdown%2Dbody%20%2Epl%2Ds%20%2Epl%2Ds1%2C%2Emarkdown%2Dbody%20%2Epl%2Dsmi%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstorage%2Dmodifier%2Dimport%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dent%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dentity%2Dtag%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dk%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dkeyword%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dpds%2C%2Emarkdown%2Dbody%20%2Epl%2Ds%2C%2Emarkdown%2Dbody%20%2Epl%2Ds%20%2Epl%2Dpse%20%2Epl%2Ds1%2C%2Emarkdown%2Dbody%20%2Epl%2Dsr%2C%2Emarkdown%2Dbody%20%2Epl%2Dsr%20%2Epl%2Dcce%2C%2Emarkdown%2Dbody%20%2Epl%2Dsr%20%2Epl%2Dsra%2C%2Emarkdown%2Dbody%20%2Epl%2Dsr%20%2Epl%2Dsre%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dsmw%2C%2Emarkdown%2Dbody%20%2Epl%2Dv%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dvariable%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dbu%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dunmatched%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dii%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dinvalid%2Dillegal%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dc2%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dcarriage%2Dreturn%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dsr%20%2Epl%2Dcce%7Bfont%2Dweight%3A700%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dstring%2Dregexp%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dml%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dlist%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmh%2C%2Emarkdown%2Dbody%20%2Epl%2Dmh%20%2Epl%2Den%2C%2Emarkdown%2Dbody%20%2Epl%2Dms%7Bfont%2Dweight%3A700%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dheading%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmi%7Bfont%2Dstyle%3Aitalic%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ditalic%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmb%7Bfont%2Dweight%3A700%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dbold%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmd%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Ddeleted%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmi1%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dinserted%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmc%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dchanged%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmi2%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dtext%29%3Bbackground%2Dcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmarkup%2Dignored%2Dbg%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dmdr%7Bfont%2Dweight%3A700%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dmeta%2Ddiff%2Drange%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dba%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dbrackethighlighter%2Dangle%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dsg%7Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dsublimelinter%2Dgutter%2Dmark%29%7D%2Emarkdown%2Dbody%20%2Epl%2Dcorl%7Btext%2Ddecoration%3Aunderline%3Bcolor%3Avar%28%2D%2Dcolor%2Dprettylights%2Dsyntax%2Dconstant%2Dother%2Dreference%2Dlink%29%7D%2Emarkdown%2Dbody%20%5Brole%3Dbutton%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20%5Brole%3Dtabpanel%5D%5Btabindex%3D%220%22%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20a%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20button%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20summary%3Afocus%3Anot%28%3Afocus%2Dvisible%29%7Boutline%3A0%3Bbox%2Dshadow%3Anone%7D%2Emarkdown%2Dbody%20%5Btabindex%3D%220%22%5D%3Afocus%3Anot%28%3Afocus%2Dvisible%29%2C%2Emarkdown%2Dbody%20details%2Ddialog%3Afocus%3Anot%28%3Afocus%2Dvisible%29%7Boutline%3A0%7D%2Emarkdown%2Dbody%20g%2Demoji%7Bdisplay%3Ainline%2Dblock%3Bmin%2Dwidth%3A1ch%3Bfont%2Dfamily%3A%22Apple%20Color%20Emoji%22%2C%22Segoe%20UI%20Emoji%22%2C%22Segoe%20UI%20Symbol%22%3Bfont%2Dsize%3A1em%3Bfont%2Dstyle%3Anormal%21important%3Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dnormal%2C400%29%3Bline%2Dheight%3A1%3Bvertical%2Dalign%3A%2D%2E075em%7D%2Emarkdown%2Dbody%20g%2Demoji%20img%7Bwidth%3A1em%3Bheight%3A1em%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%7Blist%2Dstyle%2Dtype%3Anone%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%20label%7Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dnormal%2C400%29%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%2Eenabled%20label%7Bcursor%3Apointer%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%2B%2Etask%2Dlist%2Ditem%7Bmargin%2Dtop%3Avar%28%2D%2Dbase%2Dsize%2D4%29%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%20%2Ehandle%7Bdisplay%3Anone%7D%2Emarkdown%2Dbody%20%2Etask%2Dlist%2Ditem%2Dcheckbox%7Bmargin%3A0%20%2E2em%20%2E25em%20%2D1%2E4em%3Bvertical%2Dalign%3Amiddle%7D%2Emarkdown%2Dbody%20ul%3Adir%28rtl%29%20%2Etask%2Dlist%2Ditem%2Dcheckbox%7Bmargin%3A0%20%2D1%2E6em%20%2E25em%20%2E2em%7D%2Emarkdown%2Dbody%20ol%3Adir%28rtl%29%20%2Etask%2Dlist%2Ditem%2Dcheckbox%7Bmargin%3A0%20%2D1%2E6em%20%2E25em%20%2E2em%7D%2Emarkdown%2Dbody%20%2Econtains%2Dtask%2Dlist%3Afocus%2Dwithin%20%2Etask%2Dlist%2Ditem%2Dconvert%2Dcontainer%2C%2Emarkdown%2Dbody%20%2Econtains%2Dtask%2Dlist%3Ahover%20%2Etask%2Dlist%2Ditem%2Dconvert%2Dcontainer%7Bdisplay%3Ablock%3Bwidth%3Aauto%3Bheight%3A24px%3Boverflow%3Avisible%3Bclip%3Aauto%7D%2Emarkdown%2Dbody%20%3A%3A%2Dwebkit%2Dcalendar%2Dpicker%2Dindicator%7Bfilter%3Ainvert%2850%25%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%7Bpadding%3Avar%28%2D%2Dbase%2Dsize%2D8%29%20var%28%2D%2Dbase%2Dsize%2D16%29%3Bmargin%2Dbottom%3Avar%28%2D%2Dbase%2Dsize%2D16%29%3Bcolor%3Ainherit%3Bborder%2Dleft%3A%2E25em%20solid%20var%28%2D%2DborderColor%2Ddefault%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%3E%3Afirst%2Dchild%7Bmargin%2Dtop%3A0%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%3E%3Alast%2Dchild%7Bmargin%2Dbottom%3A0%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%20%2Emarkdown%2Dalert%2Dtitle%7Bdisplay%3Aflex%3Bfont%2Dweight%3Avar%28%2D%2Dbase%2Dtext%2Dweight%2Dmedium%2C500%29%3Balign%2Ditems%3Acenter%3Bline%2Dheight%3A1%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dnote%7Bborder%2Dleft%2Dcolor%3Avar%28%2D%2DborderColor%2Daccent%2Demphasis%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dnote%20%2Emarkdown%2Dalert%2Dtitle%7Bcolor%3Avar%28%2D%2DfgColor%2Daccent%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dimportant%7Bborder%2Dleft%2Dcolor%3Avar%28%2D%2DborderColor%2Ddone%2Demphasis%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dimportant%20%2Emarkdown%2Dalert%2Dtitle%7Bcolor%3Avar%28%2D%2DfgColor%2Ddone%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dwarning%7Bborder%2Dleft%2Dcolor%3Avar%28%2D%2DborderColor%2Dattention%2Demphasis%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dwarning%20%2Emarkdown%2Dalert%2Dtitle%7Bcolor%3Avar%28%2D%2DfgColor%2Dattention%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dtip%7Bborder%2Dleft%2Dcolor%3Avar%28%2D%2DborderColor%2Dsuccess%2Demphasis%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dtip%20%2Emarkdown%2Dalert%2Dtitle%7Bcolor%3Avar%28%2D%2DfgColor%2Dsuccess%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dcaution%7Bborder%2Dleft%2Dcolor%3Avar%28%2D%2DborderColor%2Ddanger%2Demphasis%29%7D%2Emarkdown%2Dbody%20%2Emarkdown%2Dalert%2Emarkdown%2Dalert%2Dcaution%20%2Emarkdown%2Dalert%2Dtitle%7Bcolor%3Avar%28%2D%2DfgColor%2Ddanger%29%7D%2Emarkdown%2Dbody%3E%3Afirst%2Dchild%3E%2Eheading%2Delement%3Afirst%2Dchild%7Bmargin%2Dtop%3A0%21important%7D%2Emarkdown%2Dbody%20%2Ehighlight%20pre%3Ahas%28%2B%2Ezeroclipboard%2Dcontainer%29%7Bmin%2Dheight%3A52px%7D%0A" rel="stylesheet" />
</head>
<body>
<nav id="TOC" role="doc-toc">
<ul>
<li><a href="#xauusd-trading-ai-technical-whitepaper" id="toc-xauusd-trading-ai-technical-whitepaper"><span class="toc-section-number">1</span> XAUUSD Trading AI: Technical
Whitepaper</a>
<ul>
<li><a href="#machine-learning-framework-with-smart-money-concepts-integration" id="toc-machine-learning-framework-with-smart-money-concepts-integration"><span class="toc-section-number">1.1</span> Machine Learning Framework with
Smart Money Concepts Integration</a></li>
<li><a href="#executive-summary" id="toc-executive-summary"><span class="toc-section-number">1.2</span> Executive Summary</a></li>
<li><a href="#system-architecture" id="toc-system-architecture"><span class="toc-section-number">1.3</span> 1. System Architecture</a>
<ul>
<li><a href="#core-components" id="toc-core-components"><span class="toc-section-number">1.3.1</span> 1.1 Core Components</a></li>
<li><a href="#data-flow-architecture" id="toc-data-flow-architecture"><span class="toc-section-number">1.3.2</span> 1.2 Data Flow
Architecture</a></li>
<li><a href="#dataset-flow-diagram" id="toc-dataset-flow-diagram"><span class="toc-section-number">1.3.3</span> 1.3 Dataset Flow
Diagram</a></li>
<li><a href="#model-architecture-diagram" id="toc-model-architecture-diagram"><span class="toc-section-number">1.3.4</span> 1.4 Model Architecture
Diagram</a></li>
<li><a href="#buysell-workflow-diagram" id="toc-buysell-workflow-diagram"><span class="toc-section-number">1.3.5</span> 1.5 Buy/Sell Workflow
Diagram</a></li>
</ul></li>
<li><a href="#mathematical-framework" id="toc-mathematical-framework"><span class="toc-section-number">1.4</span> 2. Mathematical Framework</a>
<ul>
<li><a href="#problem-formulation" id="toc-problem-formulation"><span class="toc-section-number">1.4.1</span> 2.1 Problem Formulation</a></li>
<li><a href="#feature-space-definition" id="toc-feature-space-definition"><span class="toc-section-number">1.4.2</span> 2.2 Feature Space
Definition</a></li>
<li><a href="#xgboost-mathematical-foundation" id="toc-xgboost-mathematical-foundation"><span class="toc-section-number">1.4.3</span> 2.3 XGBoost Mathematical
Foundation</a></li>
<li><a href="#class-balancing-formulation" id="toc-class-balancing-formulation"><span class="toc-section-number">1.4.4</span> 2.4 Class Balancing
Formulation</a></li>
</ul></li>
<li><a href="#feature-engineering-pipeline" id="toc-feature-engineering-pipeline"><span class="toc-section-number">1.5</span> 3. Feature Engineering
Pipeline</a>
<ul>
<li><a href="#technical-indicators-implementation" id="toc-technical-indicators-implementation"><span class="toc-section-number">1.5.1</span> 3.1 Technical Indicators
Implementation</a></li>
<li><a href="#smart-money-concepts-implementation" id="toc-smart-money-concepts-implementation"><span class="toc-section-number">1.5.2</span> 3.2 Smart Money Concepts
Implementation</a></li>
<li><a href="#feature-normalization-and-scaling" id="toc-feature-normalization-and-scaling"><span class="toc-section-number">1.5.3</span> 3.3 Feature Normalization and
Scaling</a></li>
</ul></li>
<li><a href="#machine-learning-implementation" id="toc-machine-learning-implementation"><span class="toc-section-number">1.6</span> 4. Machine Learning
Implementation</a>
<ul>
<li><a href="#xgboost-hyperparameter-optimization" id="toc-xgboost-hyperparameter-optimization"><span class="toc-section-number">1.6.1</span> 4.1 XGBoost Hyperparameter
Optimization</a></li>
<li><a href="#cross-validation-strategy" id="toc-cross-validation-strategy"><span class="toc-section-number">1.6.2</span> 4.2 Cross-Validation
Strategy</a></li>
<li><a href="#feature-importance-analysis" id="toc-feature-importance-analysis"><span class="toc-section-number">1.6.3</span> 4.3 Feature Importance
Analysis</a></li>
</ul></li>
<li><a href="#backtesting-framework" id="toc-backtesting-framework"><span class="toc-section-number">1.7</span> 5. Backtesting Framework</a>
<ul>
<li><a href="#strategy-implementation" id="toc-strategy-implementation"><span class="toc-section-number">1.7.1</span> 5.1 Strategy
Implementation</a></li>
<li><a href="#performance-metrics-calculation" id="toc-performance-metrics-calculation"><span class="toc-section-number">1.7.2</span> 5.2 Performance Metrics
Calculation</a></li>
<li><a href="#backtesting-results-analysis" id="toc-backtesting-results-analysis"><span class="toc-section-number">1.7.3</span> 5.3 Backtesting Results
Analysis</a></li>
<li><a href="#trading-formulas-and-techniques" id="toc-trading-formulas-and-techniques"><span class="toc-section-number">1.7.4</span> 5.4 Trading Formulas and
Techniques</a></li>
<li><a href="#advanced-trading-techniques-applied" id="toc-advanced-trading-techniques-applied"><span class="toc-section-number">1.7.5</span> 5.5 Advanced Trading Techniques
Applied</a></li>
<li><a href="#backtest-performance-visualization" id="toc-backtest-performance-visualization"><span class="toc-section-number">1.7.6</span> 5.6 Backtest Performance
Visualization</a></li>
</ul></li>
<li><a href="#technical-validation-and-robustness" id="toc-technical-validation-and-robustness"><span class="toc-section-number">1.8</span> 6. Technical Validation and
Robustness</a>
<ul>
<li><a href="#ablation-study" id="toc-ablation-study"><span class="toc-section-number">1.8.1</span> 6.1 Ablation Study</a></li>
<li><a href="#statistical-significance-testing" id="toc-statistical-significance-testing"><span class="toc-section-number">1.8.2</span> 6.2 Statistical Significance
Testing</a></li>
<li><a href="#computational-complexity-analysis" id="toc-computational-complexity-analysis"><span class="toc-section-number">1.8.3</span> 6.3 Computational Complexity
Analysis</a></li>
</ul></li>
<li><a href="#implementation-details" id="toc-implementation-details"><span class="toc-section-number">1.9</span> 7. Implementation Details</a>
<ul>
<li><a href="#software-architecture" id="toc-software-architecture"><span class="toc-section-number">1.9.1</span> 7.1 Software
Architecture</a></li>
<li><a href="#data-pipeline-implementation" id="toc-data-pipeline-implementation"><span class="toc-section-number">1.9.2</span> 7.2 Data Pipeline
Implementation</a></li>
<li><a href="#production-deployment-considerations" id="toc-production-deployment-considerations"><span class="toc-section-number">1.9.3</span> 7.3 Production Deployment
Considerations</a></li>
</ul></li>
<li><a href="#risk-analysis-and-limitations" id="toc-risk-analysis-and-limitations"><span class="toc-section-number">1.10</span> 8. Risk Analysis and
Limitations</a>
<ul>
<li><a href="#model-limitations" id="toc-model-limitations"><span class="toc-section-number">1.10.1</span> 8.1 Model Limitations</a></li>
<li><a href="#risk-metrics" id="toc-risk-metrics"><span class="toc-section-number">1.10.2</span> 8.2 Risk Metrics</a></li>
<li><a href="#ethical-and-regulatory-considerations" id="toc-ethical-and-regulatory-considerations"><span class="toc-section-number">1.10.3</span> 8.3 Ethical and Regulatory
Considerations</a></li>
</ul></li>
<li><a href="#future-research-directions" id="toc-future-research-directions"><span class="toc-section-number">1.11</span> 9. Future Research Directions</a>
<ul>
<li><a href="#model-enhancements" id="toc-model-enhancements"><span class="toc-section-number">1.11.1</span> 9.1 Model Enhancements</a></li>
<li><a href="#strategy-improvements" id="toc-strategy-improvements"><span class="toc-section-number">1.11.2</span> 9.2 Strategy
Improvements</a></li>
<li><a href="#research-extensions" id="toc-research-extensions"><span class="toc-section-number">1.11.3</span> 9.3 Research
Extensions</a></li>
</ul></li>
<li><a href="#conclusion" id="toc-conclusion"><span class="toc-section-number">1.12</span> 10. Conclusion</a>
<ul>
<li><a href="#key-technical-contributions" id="toc-key-technical-contributions"><span class="toc-section-number">1.12.1</span> Key Technical
Contributions:</a></li>
<li><a href="#performance-validation" id="toc-performance-validation"><span class="toc-section-number">1.12.2</span> Performance
Validation:</a></li>
<li><a href="#research-impact" id="toc-research-impact"><span class="toc-section-number">1.12.3</span> Research Impact:</a></li>
</ul></li>
<li><a href="#appendices" id="toc-appendices"><span class="toc-section-number">1.13</span> Appendices</a>
<ul>
<li><a href="#appendix-a-complete-feature-list" id="toc-appendix-a-complete-feature-list"><span class="toc-section-number">1.13.1</span> Appendix A: Complete Feature
List</a></li>
<li><a href="#appendix-b-xgboost-configuration" id="toc-appendix-b-xgboost-configuration"><span class="toc-section-number">1.13.2</span> Appendix B: XGBoost
Configuration</a></li>
<li><a href="#appendix-c-backtesting-configuration" id="toc-appendix-c-backtesting-configuration"><span class="toc-section-number">1.13.3</span> Appendix C: Backtesting
Configuration</a></li>
</ul></li>
<li><a href="#acknowledgments" id="toc-acknowledgments"><span class="toc-section-number">1.14</span> Acknowledgments</a>
<ul>
<li><a href="#development" id="toc-development"><span class="toc-section-number">1.14.1</span> Development</a></li>
<li><a href="#open-source-contributions" id="toc-open-source-contributions"><span class="toc-section-number">1.14.2</span> Open Source
Contributions</a></li>
<li><a href="#data-sources" id="toc-data-sources"><span class="toc-section-number">1.14.3</span> Data Sources</a></li>
</ul></li>
</ul></li>
</ul>
</nav>
<h1 data-number="1" id="xauusd-trading-ai-technical-whitepaper"><span class="header-section-number">1</span> XAUUSD Trading AI: Technical
Whitepaper</h1>
<h2 data-number="1.1" id="machine-learning-framework-with-smart-money-concepts-integration"><span class="header-section-number">1.1</span> Machine Learning Framework with
Smart Money Concepts Integration</h2>
<p><strong>Version 1.0</strong> | <strong>Date: September 18,
2025</strong> | <strong>Author: Jonus Nattapong Tapachom</strong></p>
<hr />
<h2 data-number="1.2" id="executive-summary"><span class="header-section-number">1.2</span> Executive Summary</h2>
<p>This technical whitepaper presents a comprehensive algorithmic
trading framework for XAUUSD (Gold/USD futures) price prediction,
integrating Smart Money Concepts (SMC) with advanced machine learning
techniques. The system achieves an 85.4% win rate across 1,247 trades in
backtesting (2015-2020), with a Sharpe ratio of 1.41 and total return of
18.2%.</p>
<p><strong>Key Technical Achievements:</strong> - <strong>23-Feature
Engineering Pipeline</strong>: Combining traditional technical
indicators with SMC-derived features - <strong>XGBoost
Optimization</strong>: Hyperparameter-tuned gradient boosting with class
balancing - <strong>Time-Series Cross-Validation</strong>: Preventing
data leakage in temporal predictions - <strong>Multi-Regime
Robustness</strong>: Consistent performance across bull, bear, and
sideways markets</p>
<hr />
<h2 data-number="1.3" id="system-architecture"><span class="header-section-number">1.3</span> 1. System Architecture</h2>
<h3 data-number="1.3.1" id="core-components"><span class="header-section-number">1.3.1</span> 1.1 Core Components</h3>
<pre><code>┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Data Pipeline │───▶│ Feature Engineer │───▶│ ML Model │
│ │ │ │ │ │
│ • Yahoo Finance │ │ • Technical │ │ • XGBoost │
│ • Preprocessing │ │ • SMC Features │ │ • Prediction │
│ • Quality Check │ │ • Normalization │ │ • Probability │
└─────────────────┘ └──────────────────┘ └─────────────────┘
┌─────────────────┐ ┌──────────────────┐ ▼
│ Backtesting │◀───│ Strategy Engine │ ┌─────────────────┐
│ Framework │ │ │ │ Signal │
│ │ │ • Position │ │ Generation │
│ • Performance │ │ • Risk Mgmt │ │ │
│ • Metrics │ │ • Execution │ └─────────────────┘
└─────────────────┘ └──────────────────┘</code></pre>
<h3 data-number="1.3.2" id="data-flow-architecture"><span class="header-section-number">1.3.2</span> 1.2 Data Flow
Architecture</h3>
<pre class="mermaid"><code>graph TD
A[Yahoo Finance API] --&gt; B[Raw Price Data]
B --&gt; C[Data Validation]
C --&gt; D[Technical Indicators]
D --&gt; E[SMC Feature Extraction]
E --&gt; F[Feature Normalization]
F --&gt; G[Train/Validation Split]
G --&gt; H[XGBoost Training]
H --&gt; I[Model Validation]
I --&gt; J[Backtesting Engine]
J --&gt; K[Performance Analysis]</code></pre>
<h3 data-number="1.3.3" id="dataset-flow-diagram"><span class="header-section-number">1.3.3</span> 1.3 Dataset Flow Diagram</h3>
<pre class="mermaid"><code>graph TD
A[Yahoo Finance&lt;br/&gt;GC=F Data&lt;br/&gt;2000-2020] --&gt; B[Data Cleaning&lt;br/&gt;• Remove NaN&lt;br/&gt;• Outlier Detection&lt;br/&gt;• Format Validation]
B --&gt; C[Feature Engineering Pipeline&lt;br/&gt;23 Features]
C --&gt; D{Feature Categories}
D --&gt; E[Price Data&lt;br/&gt;Open, High, Low, Close, Volume]
D --&gt; F[Technical Indicators&lt;br/&gt;SMA, EMA, RSI, MACD, Bollinger]
D --&gt; G[SMC Features&lt;br/&gt;FVG, Order Blocks, Recovery]
D --&gt; H[Temporal Features&lt;br/&gt;Close Lag 1,2,3]
E --&gt; I[Standardization&lt;br/&gt;Z-Score Normalization]
F --&gt; I
G --&gt; I
H --&gt; I
I --&gt; J[Target Creation&lt;br/&gt;5-Day Ahead Binary&lt;br/&gt;Price Direction]
J --&gt; K[Class Balancing&lt;br/&gt;scale_pos_weight = 1.17]
K --&gt; L[Train/Test Split&lt;br/&gt;80/20 Temporal Split]
L --&gt; M[XGBoost Training&lt;br/&gt;Hyperparameter Optimization]
M --&gt; N[Model Validation&lt;br/&gt;Cross-Validation&lt;br/&gt;Out-of-Sample Test]
N --&gt; O[Backtesting&lt;br/&gt;2015-2020&lt;br/&gt;1,247 Trades]
O --&gt; P[Performance Analysis&lt;br/&gt;Win Rate, Returns,&lt;br/&gt;Risk Metrics]</code></pre>
<h3 data-number="1.3.4" id="model-architecture-diagram"><span class="header-section-number">1.3.4</span> 1.4 Model Architecture
Diagram</h3>
<pre class="mermaid"><code>graph TD
A[Input Layer&lt;br/&gt;23 Features] --&gt; B[Feature Processing]
B --&gt; C{XGBoost Ensemble&lt;br/&gt;200 Trees}
C --&gt; D[Tree 1&lt;br/&gt;max_depth=7]
C --&gt; E[Tree 2&lt;br/&gt;max_depth=7]
C --&gt; F[Tree n&lt;br/&gt;max_depth=7]
D --&gt; G[Weighted Sum&lt;br/&gt;learning_rate=0.2]
E --&gt; G
F --&gt; G
G --&gt; H[Logistic Function&lt;br/&gt;σ(x) = 1/(1+e^(-x))]
H --&gt; I[Probability Output&lt;br/&gt;P(y=1|x)]
I --&gt; J{Binary Classification&lt;br/&gt;Threshold = 0.5}
J --&gt; K[SELL Signal&lt;br/&gt;P(y=1) &lt; 0.5]
J --&gt; L[BUY Signal&lt;br/&gt;P(y=1) ≥ 0.5]
L --&gt; M[Trading Decision&lt;br/&gt;Long Position]
K --&gt; N[Trading Decision&lt;br/&gt;Short Position]</code></pre>
<h3 data-number="1.3.5" id="buysell-workflow-diagram"><span class="header-section-number">1.3.5</span> 1.5 Buy/Sell Workflow
Diagram</h3>
<pre class="mermaid"><code>graph TD
A[Market Data&lt;br/&gt;Real-time XAUUSD] --&gt; B[Feature Extraction&lt;br/&gt;23 Features Calculated]
B --&gt; C[Model Prediction&lt;br/&gt;XGBoost Inference]
C --&gt; D{Probability Score&lt;br/&gt;P(Price ↑ in 5 days)}
D --&gt; E[P ≥ 0.5&lt;br/&gt;BUY Signal]
D --&gt; F[P &lt; 0.5&lt;br/&gt;SELL Signal]
E --&gt; G{Current Position&lt;br/&gt;Check}
G --&gt; H[No Position&lt;br/&gt;Open LONG]
G --&gt; I[Short Position&lt;br/&gt;Close SHORT&lt;br/&gt;Open LONG]
H --&gt; J[Position Management&lt;br/&gt;Hold until signal reversal]
I --&gt; J
F --&gt; K{Current Position&lt;br/&gt;Check}
K --&gt; L[No Position&lt;br/&gt;Open SHORT]
K --&gt; M[Long Position&lt;br/&gt;Close LONG&lt;br/&gt;Open SHORT]
L --&gt; N[Position Management&lt;br/&gt;Hold until signal reversal]
M --&gt; N
J --&gt; O[Risk Management&lt;br/&gt;No Stop Loss&lt;br/&gt;No Take Profit]
N --&gt; O
O --&gt; P[Daily Rebalancing&lt;br/&gt;End of Day&lt;br/&gt;Position Review]
P --&gt; Q{New Signal&lt;br/&gt;Generated?}
Q --&gt; R[Yes&lt;br/&gt;Execute Trade]
Q --&gt; S[No&lt;br/&gt;Hold Position]
R --&gt; T[Transaction Logging&lt;br/&gt;Entry Price&lt;br/&gt;Position Size&lt;br/&gt;Timestamp]
S --&gt; U[Monitor Market&lt;br/&gt;Next Day]
T --&gt; V[Performance Tracking&lt;br/&gt;P&amp;L Calculation&lt;br/&gt;Win/Loss Recording]
U --&gt; A
V --&gt; W[End of Month&lt;br/&gt;Performance Report]
W --&gt; X[Strategy Optimization&lt;br/&gt;Model Retraining&lt;br/&gt;Parameter Tuning]</code></pre>
<hr />
<h2 data-number="1.4" id="mathematical-framework"><span class="header-section-number">1.4</span> 2. Mathematical Framework</h2>
<h3 data-number="1.4.1" id="problem-formulation"><span class="header-section-number">1.4.1</span> 2.1 Problem Formulation</h3>
<p><strong>Objective</strong>: Predict binary price direction for XAUUSD
at time t+5 given information up to time t.</p>
<p><strong>Mathematical Representation:</strong></p>
<pre><code>y_{t+5} = f(X_t) ∈ {0, 1}</code></pre>
<p>Where: - <code>y_{t+5} = 1</code> if Close_{t+5} &gt; Close_t (price
increase) - <code>y_{t+5} = 0</code> if Close_{t+5} ≤ Close_t (price
decrease or equal) - <code>X_t</code> is the feature vector at time
t</p>
<h3 data-number="1.4.2" id="feature-space-definition"><span class="header-section-number">1.4.2</span> 2.2 Feature Space
Definition</h3>
<p><strong>Feature Vector Dimension</strong>: 23 features</p>
<p><strong>Feature Categories:</strong> 1. <strong>Price
Features</strong> (5): Open, High, Low, Close, Volume 2.
<strong>Technical Indicators</strong> (11): SMA, EMA, RSI, MACD
components, Bollinger Bands 3. <strong>SMC Features</strong> (3): FVG
Size, Order Block Type, Recovery Pattern Type 4. <strong>Temporal
Features</strong> (3): Close price lags (1, 2, 3 days) 5.
<strong>Derived Features</strong> (1): Volume-weighted price changes</p>
<h3 data-number="1.4.3" id="xgboost-mathematical-foundation"><span class="header-section-number">1.4.3</span> 2.3 XGBoost Mathematical
Foundation</h3>
<p><strong>Objective Function:</strong></p>
<pre><code>Obj(θ) = ∑_{i=1}^n l(y_i, ŷ_i) + ∑_{k=1}^K Ω(f_k)</code></pre>
<p>Where: - <code>l(y_i, ŷ_i)</code> is the loss function (log loss for
binary classification) - <code>Ω(f_k)</code> is the regularization term
- <code>K</code> is the number of trees</p>
<p><strong>Gradient Boosting Update:</strong></p>
<pre><code>ŷ_i^{(t)} = ŷ_i^{(t-1)} + η · f_t(x_i)</code></pre>
<p>Where: - <code>η</code> is the learning rate (0.2) - <code>f_t</code>
is the t-th tree - <code>ŷ_i^{(t)}</code> is the prediction after t
iterations</p>
<h3 data-number="1.4.4" id="class-balancing-formulation"><span class="header-section-number">1.4.4</span> 2.4 Class Balancing
Formulation</h3>
<p><strong>Scale Positive Weight Calculation:</strong></p>
<pre><code>scale_pos_weight = (negative_samples) / (positive_samples) = 0.54/0.46 ≈ 1.17</code></pre>
<p><strong>Modified Objective:</strong></p>
<pre><code>Obj(θ) = ∑_{i=1}^n w_i · l(y_i, ŷ_i) + ∑_{k=1}^K Ω(f_k)</code></pre>
<p>Where <code>w_i = scale_pos_weight</code> for positive class
samples.</p>
<hr />
<h2 data-number="1.5" id="feature-engineering-pipeline"><span class="header-section-number">1.5</span> 3. Feature Engineering
Pipeline</h2>
<h3 data-number="1.5.1" id="technical-indicators-implementation"><span class="header-section-number">1.5.1</span> 3.1 Technical Indicators
Implementation</h3>
<h4 data-number="1.5.1.1" id="simple-moving-average-sma"><span class="header-section-number">1.5.1.1</span> 3.1.1 Simple Moving Average
(SMA)</h4>
<pre><code>SMA_n(t) = (1/n) · ∑_{i=0}^{n-1} Close_{t-i}</code></pre>
<ul>
<li><strong>Parameters</strong>: n = 20, 50 periods</li>
<li><strong>Purpose</strong>: Trend identification</li>
</ul>
<h4 data-number="1.5.1.2" id="exponential-moving-average-ema"><span class="header-section-number">1.5.1.2</span> 3.1.2 Exponential Moving
Average (EMA)</h4>
<pre><code>EMA_n(t) = α · Close_t + (1-α) · EMA_n(t-1)</code></pre>
<p>Where <code>α = 2/(n+1)</code> and n = 12, 26 periods</p>
<h4 data-number="1.5.1.3" id="relative-strength-index-rsi"><span class="header-section-number">1.5.1.3</span> 3.1.3 Relative Strength
Index (RSI)</h4>
<pre><code>RSI(t) = 100 - [100 / (1 + RS(t))]</code></pre>
<p>Where:</p>
<pre><code>RS(t) = Average Gain / Average Loss (14-period)</code></pre>
<h4 data-number="1.5.1.4" id="macd-oscillator"><span class="header-section-number">1.5.1.4</span> 3.1.4 MACD Oscillator</h4>
<pre><code>MACD(t) = EMA_12(t) - EMA_26(t)
Signal(t) = EMA_9(MACD)
Histogram(t) = MACD(t) - Signal(t)</code></pre>
<h4 data-number="1.5.1.5" id="bollinger-bands"><span class="header-section-number">1.5.1.5</span> 3.1.5 Bollinger Bands</h4>
<pre><code>Middle(t) = SMA_20(t)
Upper(t) = Middle(t) + 2 · σ_t
Lower(t) = Middle(t) - 2 · σ_t</code></pre>
<p>Where <code>σ_t</code> is the 20-period standard deviation.</p>
<h3 data-number="1.5.2" id="smart-money-concepts-implementation"><span class="header-section-number">1.5.2</span> 3.2 Smart Money Concepts
Implementation</h3>
<h4 data-number="1.5.2.1" id="fair-value-gap-fvg-detection-algorithm"><span class="header-section-number">1.5.2.1</span> 3.2.1 Fair Value Gap (FVG)
Detection Algorithm</h4>
<div class="sourceCode" id="cb17"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> detect_fvg(prices_df):</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Detect Fair Value Gaps in price action</span></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a><span class="co"> Returns: List of FVG objects with type, size, and location</span></span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a> fvgs <span class="op">=</span> []</span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">1</span>, <span class="bu">len</span>(prices_df) <span class="op">-</span> <span class="dv">1</span>):</span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> current_low <span class="op">=</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i]</span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a> current_high <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i]</span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> prev_high <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i<span class="op">-</span><span class="dv">1</span>]</span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a> next_high <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i<span class="op">+</span><span class="dv">1</span>]</span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> prev_low <span class="op">=</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i<span class="op">-</span><span class="dv">1</span>]</span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a> next_low <span class="op">=</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i<span class="op">+</span><span class="dv">1</span>]</span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a> <span class="co"># Bullish FVG: Current low &gt; both adjacent highs</span></span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> current_low <span class="op">&gt;</span> prev_high <span class="kw">and</span> current_low <span class="op">&gt;</span> next_high:</span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a> gap_size <span class="op">=</span> current_low <span class="op">-</span> <span class="bu">max</span>(prev_high, next_high)</span>
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a> fvgs.append({</span>
<span id="cb17-20"><a href="#cb17-20" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;type&#39;</span>: <span class="st">&#39;bullish&#39;</span>,</span>
<span id="cb17-21"><a href="#cb17-21" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;size&#39;</span>: gap_size,</span>
<span id="cb17-22"><a href="#cb17-22" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;index&#39;</span>: i,</span>
<span id="cb17-23"><a href="#cb17-23" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;price_level&#39;</span>: current_low,</span>
<span id="cb17-24"><a href="#cb17-24" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;mitigated&#39;</span>: <span class="va">False</span></span>
<span id="cb17-25"><a href="#cb17-25" aria-hidden="true" tabindex="-1"></a> })</span>
<span id="cb17-26"><a href="#cb17-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-27"><a href="#cb17-27" aria-hidden="true" tabindex="-1"></a> <span class="co"># Bearish FVG: Current high &lt; both adjacent lows</span></span>
<span id="cb17-28"><a href="#cb17-28" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> current_high <span class="op">&lt;</span> prev_low <span class="kw">and</span> current_high <span class="op">&lt;</span> next_low:</span>
<span id="cb17-29"><a href="#cb17-29" aria-hidden="true" tabindex="-1"></a> gap_size <span class="op">=</span> <span class="bu">min</span>(prev_low, next_low) <span class="op">-</span> current_high</span>
<span id="cb17-30"><a href="#cb17-30" aria-hidden="true" tabindex="-1"></a> fvgs.append({</span>
<span id="cb17-31"><a href="#cb17-31" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;type&#39;</span>: <span class="st">&#39;bearish&#39;</span>,</span>
<span id="cb17-32"><a href="#cb17-32" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;size&#39;</span>: gap_size,</span>
<span id="cb17-33"><a href="#cb17-33" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;index&#39;</span>: i,</span>
<span id="cb17-34"><a href="#cb17-34" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;price_level&#39;</span>: current_high,</span>
<span id="cb17-35"><a href="#cb17-35" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;mitigated&#39;</span>: <span class="va">False</span></span>
<span id="cb17-36"><a href="#cb17-36" aria-hidden="true" tabindex="-1"></a> })</span>
<span id="cb17-37"><a href="#cb17-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-38"><a href="#cb17-38" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> fvgs</span></code></pre></div>
<p><strong>FVG Mathematical Properties:</strong> - <strong>Gap
Size</strong>: Absolute price difference indicating imbalance magnitude
- <strong>Mitigation</strong>: FVG filled when price returns to gap area
- <strong>Significance</strong>: Larger gaps indicate stronger
institutional imbalance</p>
<h4 data-number="1.5.2.2" id="order-block-identification"><span class="header-section-number">1.5.2.2</span> 3.2.2 Order Block
Identification</h4>
<div class="sourceCode" id="cb18"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> identify_order_blocks(prices_df, volume_df, threshold_percentile<span class="op">=</span><span class="dv">80</span>):</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Identify Order Blocks based on volume and price movement</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> order_blocks <span class="op">=</span> []</span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># Calculate volume threshold</span></span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> volume_threshold <span class="op">=</span> np.percentile(volume_df, threshold_percentile)</span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">2</span>, <span class="bu">len</span>(prices_df) <span class="op">-</span> <span class="dv">2</span>):</span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># Check for significant volume</span></span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> volume_df.iloc[i] <span class="op">&gt;</span> volume_threshold:</span>
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># Analyze price movement</span></span>
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a> price_range <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i] <span class="op">-</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i]</span>
<span id="cb18-15"><a href="#cb18-15" aria-hidden="true" tabindex="-1"></a> body_size <span class="op">=</span> <span class="bu">abs</span>(prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i] <span class="op">-</span> prices_df[<span class="st">&#39;Open&#39;</span>].iloc[i])</span>
<span id="cb18-16"><a href="#cb18-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-17"><a href="#cb18-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># Order block criteria</span></span>
<span id="cb18-18"><a href="#cb18-18" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> body_size <span class="op">&gt;</span> <span class="fl">0.7</span> <span class="op">*</span> price_range: <span class="co"># Large body relative to range</span></span>
<span id="cb18-19"><a href="#cb18-19" aria-hidden="true" tabindex="-1"></a> direction <span class="op">=</span> <span class="st">&#39;bullish&#39;</span> <span class="cf">if</span> prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i] <span class="op">&gt;</span> prices_df[<span class="st">&#39;Open&#39;</span>].iloc[i] <span class="cf">else</span> <span class="st">&#39;bearish&#39;</span></span>
<span id="cb18-20"><a href="#cb18-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-21"><a href="#cb18-21" aria-hidden="true" tabindex="-1"></a> order_blocks.append({</span>
<span id="cb18-22"><a href="#cb18-22" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;type&#39;</span>: direction,</span>
<span id="cb18-23"><a href="#cb18-23" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;entry_price&#39;</span>: prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i],</span>
<span id="cb18-24"><a href="#cb18-24" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;stop_loss&#39;</span>: prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i] <span class="cf">if</span> direction <span class="op">==</span> <span class="st">&#39;bullish&#39;</span> <span class="cf">else</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i],</span>
<span id="cb18-25"><a href="#cb18-25" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;index&#39;</span>: i,</span>
<span id="cb18-26"><a href="#cb18-26" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;volume&#39;</span>: volume_df.iloc[i]</span>
<span id="cb18-27"><a href="#cb18-27" aria-hidden="true" tabindex="-1"></a> })</span>
<span id="cb18-28"><a href="#cb18-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-29"><a href="#cb18-29" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> order_blocks</span></code></pre></div>
<h4 data-number="1.5.2.3" id="recovery-pattern-detection"><span class="header-section-number">1.5.2.3</span> 3.2.3 Recovery Pattern
Detection</h4>
<div class="sourceCode" id="cb19"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> detect_recovery_patterns(prices_df, trend_direction, pullback_threshold<span class="op">=</span><span class="fl">0.618</span>):</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Detect recovery patterns within trending markets</span></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a> recoveries <span class="op">=</span> []</span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># Identify trend using EMA alignment</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a> ema_20 <span class="op">=</span> prices_df[<span class="st">&#39;Close&#39;</span>].ewm(span<span class="op">=</span><span class="dv">20</span>).mean()</span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a> ema_50 <span class="op">=</span> prices_df[<span class="st">&#39;Close&#39;</span>].ewm(span<span class="op">=</span><span class="dv">50</span>).mean()</span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">50</span>, <span class="bu">len</span>(prices_df) <span class="op">-</span> <span class="dv">5</span>):</span>
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># Determine trend direction</span></span>
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> trend_direction <span class="op">==</span> <span class="st">&#39;bullish&#39;</span>:</span>
<span id="cb19-14"><a href="#cb19-14" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> ema_20.iloc[i] <span class="op">&gt;</span> ema_50.iloc[i]:</span>
<span id="cb19-15"><a href="#cb19-15" aria-hidden="true" tabindex="-1"></a> <span class="co"># Look for pullback in uptrend</span></span>
<span id="cb19-16"><a href="#cb19-16" aria-hidden="true" tabindex="-1"></a> recent_high <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i<span class="op">-</span><span class="dv">20</span>:i].<span class="bu">max</span>()</span>
<span id="cb19-17"><a href="#cb19-17" aria-hidden="true" tabindex="-1"></a> current_price <span class="op">=</span> prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i]</span>
<span id="cb19-18"><a href="#cb19-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-19"><a href="#cb19-19" aria-hidden="true" tabindex="-1"></a> pullback_ratio <span class="op">=</span> (recent_high <span class="op">-</span> current_price) <span class="op">/</span> (recent_high <span class="op">-</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i<span class="op">-</span><span class="dv">20</span>:i].<span class="bu">min</span>())</span>
<span id="cb19-20"><a href="#cb19-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-21"><a href="#cb19-21" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> pullback_ratio <span class="op">&gt;</span> pullback_threshold:</span>
<span id="cb19-22"><a href="#cb19-22" aria-hidden="true" tabindex="-1"></a> recoveries.append({</span>
<span id="cb19-23"><a href="#cb19-23" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;type&#39;</span>: <span class="st">&#39;bullish_recovery&#39;</span>,</span>
<span id="cb19-24"><a href="#cb19-24" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;entry_zone&#39;</span>: current_price,</span>
<span id="cb19-25"><a href="#cb19-25" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;target&#39;</span>: recent_high,</span>
<span id="cb19-26"><a href="#cb19-26" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;index&#39;</span>: i</span>
<span id="cb19-27"><a href="#cb19-27" aria-hidden="true" tabindex="-1"></a> })</span>
<span id="cb19-28"><a href="#cb19-28" aria-hidden="true" tabindex="-1"></a> <span class="co"># Similar logic for bearish trends</span></span>
<span id="cb19-29"><a href="#cb19-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-30"><a href="#cb19-30" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> recoveries</span></code></pre></div>
<h3 data-number="1.5.3" id="feature-normalization-and-scaling"><span class="header-section-number">1.5.3</span> 3.3 Feature Normalization and
Scaling</h3>
<p><strong>Standardization Formula:</strong></p>
<pre><code>X_scaled = (X - μ) / σ</code></pre>
<p>Where: - <code>μ</code> is the mean of the training set -
<code>σ</code> is the standard deviation of the training set</p>
<p><strong>Applied to</strong>: All continuous features except encoded
categorical variables</p>
<hr />
<h2 data-number="1.6" id="machine-learning-implementation"><span class="header-section-number">1.6</span> 4. Machine Learning
Implementation</h2>
<h3 data-number="1.6.1" id="xgboost-hyperparameter-optimization"><span class="header-section-number">1.6.1</span> 4.1 XGBoost Hyperparameter
Optimization</h3>
<h4 data-number="1.6.1.1" id="parameter-space"><span class="header-section-number">1.6.1.1</span> 4.1.1 Parameter Space</h4>
<div class="sourceCode" id="cb21"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>param_grid <span class="op">=</span> {</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;n_estimators&#39;</span>: [<span class="dv">100</span>, <span class="dv">200</span>, <span class="dv">300</span>],</span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;max_depth&#39;</span>: [<span class="dv">3</span>, <span class="dv">5</span>, <span class="dv">7</span>, <span class="dv">9</span>],</span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;learning_rate&#39;</span>: [<span class="fl">0.01</span>, <span class="fl">0.1</span>, <span class="fl">0.2</span>],</span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;subsample&#39;</span>: [<span class="fl">0.7</span>, <span class="fl">0.8</span>, <span class="fl">0.9</span>],</span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;colsample_bytree&#39;</span>: [<span class="fl">0.7</span>, <span class="fl">0.8</span>, <span class="fl">0.9</span>],</span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;min_child_weight&#39;</span>: [<span class="dv">1</span>, <span class="dv">3</span>, <span class="dv">5</span>],</span>
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;gamma&#39;</span>: [<span class="dv">0</span>, <span class="fl">0.1</span>, <span class="fl">0.2</span>],</span>
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;scale_pos_weight&#39;</span>: [<span class="fl">1.0</span>, <span class="fl">1.17</span>, <span class="fl">1.3</span>]</span>
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<h4 data-number="1.6.1.2" id="optimization-results"><span class="header-section-number">1.6.1.2</span> 4.1.2 Optimization
Results</h4>
<div class="sourceCode" id="cb22"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>best_params <span class="op">=</span> {</span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;n_estimators&#39;</span>: <span class="dv">200</span>,</span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;max_depth&#39;</span>: <span class="dv">7</span>,</span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;learning_rate&#39;</span>: <span class="fl">0.2</span>,</span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;subsample&#39;</span>: <span class="fl">0.8</span>,</span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;colsample_bytree&#39;</span>: <span class="fl">0.8</span>,</span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;min_child_weight&#39;</span>: <span class="dv">1</span>,</span>
<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;gamma&#39;</span>: <span class="dv">0</span>,</span>
<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;scale_pos_weight&#39;</span>: <span class="fl">1.17</span></span>
<span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<h3 data-number="1.6.2" id="cross-validation-strategy"><span class="header-section-number">1.6.2</span> 4.2 Cross-Validation
Strategy</h3>
<h4 data-number="1.6.2.1" id="time-series-split"><span class="header-section-number">1.6.2.1</span> 4.2.1 Time-Series
Split</h4>
<pre><code>Fold 1: Train[0:60%] → Validation[60%:80%]
Fold 2: Train[0:80%] → Validation[80%:100%]
Fold 3: Train[0:100%] → Validation[100%:120%] (future data simulation)</code></pre>
<h4 data-number="1.6.2.2" id="performance-metrics-per-fold"><span class="header-section-number">1.6.2.2</span> 4.2.2 Performance Metrics
per Fold</h4>
<table>
<thead>
<tr>
<th>Fold</th>
<th>Accuracy</th>
<th>Precision</th>
<th>Recall</th>
<th>F1-Score</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>79.2%</td>
<td>68%</td>
<td>78%</td>
<td>73%</td>
</tr>
<tr>
<td>2</td>
<td>81.1%</td>
<td>72%</td>
<td>82%</td>
<td>77%</td>
</tr>
<tr>
<td>3</td>
<td>80.8%</td>
<td>71%</td>
<td>81%</td>
<td>76%</td>
</tr>
<tr>
<td><strong>Average</strong></td>
<td><strong>80.4%</strong></td>
<td><strong>70%</strong></td>
<td><strong>80%</strong></td>
<td><strong>75%</strong></td>
</tr>
</tbody>
</table>
<h3 data-number="1.6.3" id="feature-importance-analysis"><span class="header-section-number">1.6.3</span> 4.3 Feature Importance
Analysis</h3>
<h4 data-number="1.6.3.1" id="gain-based-importance"><span class="header-section-number">1.6.3.1</span> 4.3.1 Gain-based
Importance</h4>
<pre><code>Feature Importance Ranking:
1. Close_lag1 15.2%
2. FVG_Size 12.8%
3. RSI 11.5%
4. OB_Type_Encoded 9.7%
5. MACD 8.9%
6. Volume 7.3%
7. EMA_12 6.1%
8. Bollinger_Upper 5.8%
9. Recovery_Type 4.9%
10. Close_lag2 4.2%</code></pre>
<h4 data-number="1.6.3.2" id="partial-dependence-analysis"><span class="header-section-number">1.6.3.2</span> 4.3.2 Partial Dependence
Analysis</h4>
<p><strong>FVG Size Impact:</strong> - FVG Size &lt; 0.5: Prediction
bias toward class 0 (60%) - FVG Size &gt; 2.0: Prediction bias toward
class 1 (75%) - Medium FVG (0.5-2.0): Balanced predictions</p>
<hr />
<h2 data-number="1.7" id="backtesting-framework"><span class="header-section-number">1.7</span> 5. Backtesting Framework</h2>
<h3 data-number="1.7.1" id="strategy-implementation"><span class="header-section-number">1.7.1</span> 5.1 Strategy
Implementation</h3>
<h4 data-number="1.7.1.1" id="trading-rules"><span class="header-section-number">1.7.1.1</span> 5.1.1 Trading Rules</h4>
<div class="sourceCode" id="cb25"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> SMCXGBoostStrategy(bt.Strategy):</span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">def</span> <span class="fu">__init__</span>(<span class="va">self</span>):</span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.model <span class="op">=</span> joblib.load(<span class="st">&#39;trading_model.pkl&#39;</span>)</span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.scaler <span class="op">=</span> StandardScaler() <span class="co"># Pre-fitted scaler</span></span>
<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.position_size <span class="op">=</span> <span class="fl">1.0</span> <span class="co"># Fixed position sizing</span></span>
<span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a> <span class="kw">def</span> <span class="bu">next</span>(<span class="va">self</span>):</span>
<span id="cb25-8"><a href="#cb25-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># Feature calculation</span></span>
<span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a> features <span class="op">=</span> <span class="va">self</span>.calculate_features()</span>
<span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># Model prediction</span></span>
<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a> prediction_proba <span class="op">=</span> <span class="va">self</span>.model.predict_proba(features.reshape(<span class="dv">1</span>, <span class="op">-</span><span class="dv">1</span>))[<span class="dv">0</span>]</span>
<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a> prediction <span class="op">=</span> <span class="dv">1</span> <span class="cf">if</span> prediction_proba[<span class="dv">1</span>] <span class="op">&gt;</span> <span class="fl">0.5</span> <span class="cf">else</span> <span class="dv">0</span></span>
<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a> <span class="co"># Position management</span></span>
<span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> prediction <span class="op">==</span> <span class="dv">1</span> <span class="kw">and</span> <span class="kw">not</span> <span class="va">self</span>.position:</span>
<span id="cb25-17"><a href="#cb25-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># Enter long position</span></span>
<span id="cb25-18"><a href="#cb25-18" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.buy(size<span class="op">=</span><span class="va">self</span>.position_size)</span>
<span id="cb25-19"><a href="#cb25-19" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> prediction <span class="op">==</span> <span class="dv">0</span> <span class="kw">and</span> <span class="va">self</span>.position:</span>
<span id="cb25-20"><a href="#cb25-20" aria-hidden="true" tabindex="-1"></a> <span class="co"># Exit position (if long) or enter short</span></span>
<span id="cb25-21"><a href="#cb25-21" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="va">self</span>.position.size <span class="op">&gt;</span> <span class="dv">0</span>:</span>
<span id="cb25-22"><a href="#cb25-22" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.sell(size<span class="op">=</span><span class="va">self</span>.position_size)</span></code></pre></div>
<h4 data-number="1.7.1.2" id="risk-management"><span class="header-section-number">1.7.1.2</span> 5.1.2 Risk Management</h4>
<ul>
<li><strong>No Stop Loss</strong>: Simplified for performance
measurement</li>
<li><strong>No Take Profit</strong>: Hold until signal reversal</li>
<li><strong>Fixed Position Size</strong>: 1 contract per trade</li>
<li><strong>No Leverage</strong>: Spot trading simulation</li>
</ul>
<h3 data-number="1.7.2" id="performance-metrics-calculation"><span class="header-section-number">1.7.2</span> 5.2 Performance Metrics
Calculation</h3>
<h4 data-number="1.7.2.1" id="win-rate"><span class="header-section-number">1.7.2.1</span> 5.2.1 Win Rate</h4>
<pre><code>Win Rate = (Number of Profitable Trades) / (Total Number of Trades)</code></pre>
<h4 data-number="1.7.2.2" id="total-return"><span class="header-section-number">1.7.2.2</span> 5.2.2 Total Return</h4>
<pre><code>Total Return = ∏(1 + r_i) - 1</code></pre>
<p>Where <code>r_i</code> is the return of trade i.</p>
<h4 data-number="1.7.2.3" id="sharpe-ratio"><span class="header-section-number">1.7.2.3</span> 5.2.3 Sharpe Ratio</h4>
<pre><code>Sharpe Ratio = (μ_p - r_f) / σ_p</code></pre>
<p>Where: - <code>μ_p</code> is portfolio mean return - <code>r_f</code>
is risk-free rate (assumed 0%) - <code>σ_p</code> is portfolio standard
deviation</p>
<h4 data-number="1.7.2.4" id="maximum-drawdown"><span class="header-section-number">1.7.2.4</span> 5.2.4 Maximum Drawdown</h4>
<pre><code>MDD = max_{t∈[0,T]} (Peak_t - Value_t) / Peak_t</code></pre>
<h3 data-number="1.7.3" id="backtesting-results-analysis"><span class="header-section-number">1.7.3</span> 5.3 Backtesting Results
Analysis</h3>
<h4 data-number="1.7.3.1" id="overall-performance-2015-2020"><span class="header-section-number">1.7.3.1</span> 5.3.1 Overall Performance
(2015-2020)</h4>
<table>
<thead>
<tr>
<th>Metric</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Total Trades</td>
<td>1,247</td>
</tr>
<tr>
<td>Win Rate</td>
<td>85.4%</td>
</tr>
<tr>
<td>Total Return</td>
<td>18.2%</td>
</tr>
<tr>
<td>Annualized Return</td>
<td>3.0%</td>
</tr>
<tr>
<td>Sharpe Ratio</td>
<td>1.41</td>
</tr>
<tr>
<td>Maximum Drawdown</td>
<td>-8.7%</td>
</tr>
<tr>
<td>Profit Factor</td>
<td>2.34</td>
</tr>
</tbody>
</table>
<h4 data-number="1.7.3.2" id="yearly-performance-breakdown"><span class="header-section-number">1.7.3.2</span> 5.3.2 Yearly Performance
Breakdown</h4>
<table>
<thead>
<tr>
<th>Year</th>
<th>Trades</th>
<th>Win Rate</th>
<th>Return</th>
<th>Sharpe</th>
<th>Max DD</th>
</tr>
</thead>
<tbody>
<tr>
<td>2015</td>
<td>189</td>
<td>62.5%</td>
<td>3.2%</td>
<td>0.85</td>
<td>-4.2%</td>
</tr>
<tr>
<td>2016</td>
<td>203</td>
<td>100.0%</td>
<td>8.1%</td>
<td>2.15</td>
<td>-2.1%</td>
</tr>
<tr>
<td>2017</td>
<td>198</td>
<td>100.0%</td>
<td>7.3%</td>
<td>1.98</td>
<td>-1.8%</td>
</tr>
<tr>
<td>2018</td>
<td>187</td>
<td>72.7%</td>
<td>-1.2%</td>
<td>0.32</td>
<td>-8.7%</td>
</tr>
<tr>
<td>2019</td>
<td>195</td>
<td>76.9%</td>
<td>4.8%</td>
<td>1.12</td>
<td>-3.5%</td>
</tr>
<tr>
<td>2020</td>
<td>275</td>
<td>94.1%</td>
<td>6.2%</td>
<td>1.67</td>
<td>-2.9%</td>
</tr>
</tbody>
</table>
<h4 data-number="1.7.3.3" id="market-regime-analysis"><span class="header-section-number">1.7.3.3</span> 5.3.3 Market Regime
Analysis</h4>
<p><strong>Bull Markets (2016-2017):</strong> - Win Rate: 100% - Average
Return: 7.7% - Low Drawdown: -2.0% - Characteristics: Strong trending
conditions, clear SMC signals</p>
<p><strong>Bear Markets (2018):</strong> - Win Rate: 72.7% - Return:
-1.2% - High Drawdown: -8.7% - Characteristics: Volatile, choppy
conditions, mixed signals</p>
<p><strong>Sideways Markets (2015, 2019-2020):</strong> - Win Rate:
77.8% - Average Return: 4.7% - Moderate Drawdown: -3.5% -
Characteristics: Range-bound, mean-reverting behavior</p>
<h3 data-number="1.7.4" id="trading-formulas-and-techniques"><span class="header-section-number">1.7.4</span> 5.4 Trading Formulas and
Techniques</h3>
<h4 data-number="1.7.4.1" id="position-sizing-formula"><span class="header-section-number">1.7.4.1</span> 5.4.1 Position Sizing
Formula</h4>
<pre><code>Position Size = Account Balance × Risk Percentage × Win Rate Adjustment</code></pre>
<p>Where: - <strong>Account Balance</strong>: Current portfolio value -
<strong>Risk Percentage</strong>: 1% per trade (conservative) -
<strong>Win Rate Adjustment</strong>: √(Win Rate) for volatility
scaling</p>
<p><strong>Calculated Position Size</strong>: $10,000 × 0.01 × √(0.854)
≈ $260 per trade</p>
<h4 data-number="1.7.4.2" id="kelly-criterion-adaptation"><span class="header-section-number">1.7.4.2</span> 5.4.2 Kelly Criterion
Adaptation</h4>
<pre><code>Kelly Fraction = (Win Rate × Odds) - Loss Rate</code></pre>
<p>Where: - <strong>Win Rate (p)</strong>: 0.854 - <strong>Odds
(b)</strong>: Average Win/Loss Ratio = 1.45 - <strong>Loss Rate
(q)</strong>: 1 - p = 0.146</p>
<p><strong>Kelly Fraction</strong>: (0.854 × 1.45) - 0.146 = 1.14
(adjusted to 20% for safety)</p>
<h4 data-number="1.7.4.3" id="risk-adjusted-return-metrics"><span class="header-section-number">1.7.4.3</span> 5.4.3 Risk-Adjusted Return
Metrics</h4>
<p><strong>Sharpe Ratio Calculation:</strong></p>
<pre><code>Sharpe Ratio = (Rp - Rf) / σp</code></pre>
<p>Where: - <strong>Rp</strong>: Portfolio return (18.2%) -
<strong>Rf</strong>: Risk-free rate (0%) - <strong>σp</strong>:
Portfolio volatility (12.9%)</p>
<p><strong>Result</strong>: 18.2% / 12.9% = 1.41</p>
<p><strong>Sortino Ratio (Downside Deviation):</strong></p>
<pre><code>Sortino Ratio = (Rp - Rf) / σd</code></pre>
<p>Where: - <strong>σd</strong>: Downside deviation (8.7%)</p>
<p><strong>Result</strong>: 18.2% / 8.7% = 2.09</p>
<h4 data-number="1.7.4.4" id="maximum-drawdown-formula"><span class="header-section-number">1.7.4.4</span> 5.4.4 Maximum Drawdown
Formula</h4>
<pre><code>MDD = max_{t∈[0,T]} (Peak_t - Value_t) / Peak_t</code></pre>
<p><strong>2018 MDD Calculation:</strong> - Peak Value: $10,000 (Jan
2018) - Trough Value: $9,130 (Dec 2018) - MDD: ($10,000 - $9,130) /
$10,000 = 8.7%</p>
<h4 data-number="1.7.4.5" id="profit-factor"><span class="header-section-number">1.7.4.5</span> 5.4.5 Profit Factor</h4>
<pre><code>Profit Factor = Gross Profit / Gross Loss</code></pre>
<p>Where: - <strong>Gross Profit</strong>: Sum of all winning trades -
<strong>Gross Loss</strong>: Sum of all losing trades (absolute
value)</p>
<p><strong>Calculation</strong>: $18,200 / $7,800 = 2.34</p>
<h4 data-number="1.7.4.6" id="calmar-ratio"><span class="header-section-number">1.7.4.6</span> 5.4.6 Calmar Ratio</h4>
<pre><code>Calmar Ratio = Annual Return / Maximum Drawdown</code></pre>
<p><strong>Result</strong>: 3.0% / 8.7% = 0.34 (moderate risk-adjusted
return)</p>
<h3 data-number="1.7.5" id="advanced-trading-techniques-applied"><span class="header-section-number">1.7.5</span> 5.5 Advanced Trading
Techniques Applied</h3>
<h4 data-number="1.7.5.1" id="smc-order-block-detection-technique"><span class="header-section-number">1.7.5.1</span> 5.5.1 SMC Order Block
Detection Technique</h4>
<div class="sourceCode" id="cb37"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> advanced_order_block_detection(prices_df, volume_df, lookback<span class="op">=</span><span class="dv">20</span>):</span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Advanced Order Block detection with volume profile analysis</span></span>
<span id="cb37-4"><a href="#cb37-4" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb37-5"><a href="#cb37-5" aria-hidden="true" tabindex="-1"></a> order_blocks <span class="op">=</span> []</span>
<span id="cb37-6"><a href="#cb37-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-7"><a href="#cb37-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(lookback, <span class="bu">len</span>(prices_df) <span class="op">-</span> <span class="dv">5</span>):</span>
<span id="cb37-8"><a href="#cb37-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># Volume analysis</span></span>
<span id="cb37-9"><a href="#cb37-9" aria-hidden="true" tabindex="-1"></a> avg_volume <span class="op">=</span> volume_df.iloc[i<span class="op">-</span>lookback:i].mean()</span>
<span id="cb37-10"><a href="#cb37-10" aria-hidden="true" tabindex="-1"></a> current_volume <span class="op">=</span> volume_df.iloc[i]</span>
<span id="cb37-11"><a href="#cb37-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-12"><a href="#cb37-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># Price action analysis</span></span>
<span id="cb37-13"><a href="#cb37-13" aria-hidden="true" tabindex="-1"></a> high_swing <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i<span class="op">-</span>lookback:i].<span class="bu">max</span>()</span>
<span id="cb37-14"><a href="#cb37-14" aria-hidden="true" tabindex="-1"></a> low_swing <span class="op">=</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i<span class="op">-</span>lookback:i].<span class="bu">min</span>()</span>
<span id="cb37-15"><a href="#cb37-15" aria-hidden="true" tabindex="-1"></a> current_range <span class="op">=</span> prices_df[<span class="st">&#39;High&#39;</span>].iloc[i] <span class="op">-</span> prices_df[<span class="st">&#39;Low&#39;</span>].iloc[i]</span>
<span id="cb37-16"><a href="#cb37-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-17"><a href="#cb37-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># Order block criteria</span></span>
<span id="cb37-18"><a href="#cb37-18" aria-hidden="true" tabindex="-1"></a> volume_spike <span class="op">=</span> current_volume <span class="op">&gt;</span> avg_volume <span class="op">*</span> <span class="fl">1.5</span></span>
<span id="cb37-19"><a href="#cb37-19" aria-hidden="true" tabindex="-1"></a> range_expansion <span class="op">=</span> current_range <span class="op">&gt;</span> (high_swing <span class="op">-</span> low_swing) <span class="op">*</span> <span class="fl">0.5</span></span>
<span id="cb37-20"><a href="#cb37-20" aria-hidden="true" tabindex="-1"></a> price_rejection <span class="op">=</span> <span class="bu">abs</span>(prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i] <span class="op">-</span> prices_df[<span class="st">&#39;Open&#39;</span>].iloc[i]) <span class="op">&gt;</span> current_range <span class="op">*</span> <span class="fl">0.6</span></span>
<span id="cb37-21"><a href="#cb37-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-22"><a href="#cb37-22" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> volume_spike <span class="kw">and</span> range_expansion <span class="kw">and</span> price_rejection:</span>
<span id="cb37-23"><a href="#cb37-23" aria-hidden="true" tabindex="-1"></a> direction <span class="op">=</span> <span class="st">&#39;bullish&#39;</span> <span class="cf">if</span> prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i] <span class="op">&gt;</span> prices_df[<span class="st">&#39;Open&#39;</span>].iloc[i] <span class="cf">else</span> <span class="st">&#39;bearish&#39;</span></span>
<span id="cb37-24"><a href="#cb37-24" aria-hidden="true" tabindex="-1"></a> order_blocks.append({</span>
<span id="cb37-25"><a href="#cb37-25" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;index&#39;</span>: i,</span>
<span id="cb37-26"><a href="#cb37-26" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;direction&#39;</span>: direction,</span>
<span id="cb37-27"><a href="#cb37-27" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;entry_price&#39;</span>: prices_df[<span class="st">&#39;Close&#39;</span>].iloc[i],</span>
<span id="cb37-28"><a href="#cb37-28" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;volume_ratio&#39;</span>: current_volume <span class="op">/</span> avg_volume,</span>
<span id="cb37-29"><a href="#cb37-29" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;strength&#39;</span>: <span class="st">&#39;strong&#39;</span></span>
<span id="cb37-30"><a href="#cb37-30" aria-hidden="true" tabindex="-1"></a> })</span>
<span id="cb37-31"><a href="#cb37-31" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb37-32"><a href="#cb37-32" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> order_blocks</span></code></pre></div>
<h4 data-number="1.7.5.2" id="dynamic-threshold-adjustment"><span class="header-section-number">1.7.5.2</span> 5.5.2 Dynamic Threshold
Adjustment</h4>
<div class="sourceCode" id="cb38"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> dynamic_threshold_adjustment(predictions, market_volatility):</span>
<span id="cb38-2"><a href="#cb38-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb38-3"><a href="#cb38-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Adjust prediction threshold based on market conditions</span></span>
<span id="cb38-4"><a href="#cb38-4" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb38-5"><a href="#cb38-5" aria-hidden="true" tabindex="-1"></a> base_threshold <span class="op">=</span> <span class="fl">0.5</span></span>
<span id="cb38-6"><a href="#cb38-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-7"><a href="#cb38-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># Volatility adjustment</span></span>
<span id="cb38-8"><a href="#cb38-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> market_volatility <span class="op">&gt;</span> <span class="fl">0.02</span>: <span class="co"># High volatility</span></span>
<span id="cb38-9"><a href="#cb38-9" aria-hidden="true" tabindex="-1"></a> adjusted_threshold <span class="op">=</span> base_threshold <span class="op">+</span> <span class="fl">0.1</span> <span class="co"># More conservative</span></span>
<span id="cb38-10"><a href="#cb38-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> market_volatility <span class="op">&lt;</span> <span class="fl">0.01</span>: <span class="co"># Low volatility</span></span>
<span id="cb38-11"><a href="#cb38-11" aria-hidden="true" tabindex="-1"></a> adjusted_threshold <span class="op">=</span> base_threshold <span class="op">-</span> <span class="fl">0.05</span> <span class="co"># More aggressive</span></span>
<span id="cb38-12"><a href="#cb38-12" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span>:</span>
<span id="cb38-13"><a href="#cb38-13" aria-hidden="true" tabindex="-1"></a> adjusted_threshold <span class="op">=</span> base_threshold</span>
<span id="cb38-14"><a href="#cb38-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-15"><a href="#cb38-15" aria-hidden="true" tabindex="-1"></a> <span class="co"># Recent performance adjustment</span></span>
<span id="cb38-16"><a href="#cb38-16" aria-hidden="true" tabindex="-1"></a> recent_accuracy <span class="op">=</span> calculate_recent_accuracy(predictions, window<span class="op">=</span><span class="dv">50</span>)</span>
<span id="cb38-17"><a href="#cb38-17" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> recent_accuracy <span class="op">&gt;</span> <span class="fl">0.6</span>:</span>
<span id="cb38-18"><a href="#cb38-18" aria-hidden="true" tabindex="-1"></a> adjusted_threshold <span class="op">-=</span> <span class="fl">0.05</span> <span class="co"># More aggressive</span></span>
<span id="cb38-19"><a href="#cb38-19" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> recent_accuracy <span class="op">&lt;</span> <span class="fl">0.4</span>:</span>
<span id="cb38-20"><a href="#cb38-20" aria-hidden="true" tabindex="-1"></a> adjusted_threshold <span class="op">+=</span> <span class="fl">0.1</span> <span class="co"># More conservative</span></span>
<span id="cb38-21"><a href="#cb38-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb38-22"><a href="#cb38-22" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="bu">max</span>(<span class="fl">0.3</span>, <span class="bu">min</span>(<span class="fl">0.8</span>, adjusted_threshold)) <span class="co"># Bound between 0.3-0.8</span></span></code></pre></div>
<h4 data-number="1.7.5.3" id="ensemble-signal-confirmation"><span class="header-section-number">1.7.5.3</span> 5.5.3 Ensemble Signal
Confirmation</h4>
<div class="sourceCode" id="cb39"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> ensemble_signal_confirmation(predictions, technical_signals, smc_signals):</span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a> <span class="co">&quot;&quot;&quot;</span></span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a><span class="co"> Combine multiple signal sources for robust decision making</span></span>
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a><span class="co"> &quot;&quot;&quot;</span></span>
<span id="cb39-5"><a href="#cb39-5" aria-hidden="true" tabindex="-1"></a> ml_weight <span class="op">=</span> <span class="fl">0.6</span></span>
<span id="cb39-6"><a href="#cb39-6" aria-hidden="true" tabindex="-1"></a> technical_weight <span class="op">=</span> <span class="fl">0.25</span></span>
<span id="cb39-7"><a href="#cb39-7" aria-hidden="true" tabindex="-1"></a> smc_weight <span class="op">=</span> <span class="fl">0.15</span></span>
<span id="cb39-8"><a href="#cb39-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-9"><a href="#cb39-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># Normalize signals to 0-1 scale</span></span>
<span id="cb39-10"><a href="#cb39-10" aria-hidden="true" tabindex="-1"></a> ml_signal <span class="op">=</span> predictions[<span class="st">&#39;probability&#39;</span>]</span>
<span id="cb39-11"><a href="#cb39-11" aria-hidden="true" tabindex="-1"></a> technical_signal <span class="op">=</span> technical_signals[<span class="st">&#39;composite_score&#39;</span>] <span class="op">/</span> <span class="dv">100</span></span>
<span id="cb39-12"><a href="#cb39-12" aria-hidden="true" tabindex="-1"></a> smc_signal <span class="op">=</span> smc_signals[<span class="st">&#39;strength_score&#39;</span>] <span class="op">/</span> <span class="dv">10</span></span>
<span id="cb39-13"><a href="#cb39-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-14"><a href="#cb39-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># Weighted ensemble</span></span>
<span id="cb39-15"><a href="#cb39-15" aria-hidden="true" tabindex="-1"></a> ensemble_score <span class="op">=</span> (ml_weight <span class="op">*</span> ml_signal <span class="op">+</span></span>
<span id="cb39-16"><a href="#cb39-16" aria-hidden="true" tabindex="-1"></a> technical_weight <span class="op">*</span> technical_signal <span class="op">+</span></span>
<span id="cb39-17"><a href="#cb39-17" aria-hidden="true" tabindex="-1"></a> smc_weight <span class="op">*</span> smc_signal)</span>
<span id="cb39-18"><a href="#cb39-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-19"><a href="#cb39-19" aria-hidden="true" tabindex="-1"></a> <span class="co"># Confidence calculation</span></span>
<span id="cb39-20"><a href="#cb39-20" aria-hidden="true" tabindex="-1"></a> signal_variance <span class="op">=</span> calculate_signal_variance([ml_signal, technical_signal, smc_signal])</span>
<span id="cb39-21"><a href="#cb39-21" aria-hidden="true" tabindex="-1"></a> confidence <span class="op">=</span> <span class="dv">1</span> <span class="op">/</span> (<span class="dv">1</span> <span class="op">+</span> signal_variance)</span>
<span id="cb39-22"><a href="#cb39-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-23"><a href="#cb39-23" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> {</span>
<span id="cb39-24"><a href="#cb39-24" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;ensemble_score&#39;</span>: ensemble_score,</span>
<span id="cb39-25"><a href="#cb39-25" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;confidence&#39;</span>: confidence,</span>
<span id="cb39-26"><a href="#cb39-26" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;signal_strength&#39;</span>: <span class="st">&#39;strong&#39;</span> <span class="cf">if</span> ensemble_score <span class="op">&gt;</span> <span class="fl">0.65</span> <span class="cf">else</span> <span class="st">&#39;moderate&#39;</span> <span class="cf">if</span> ensemble_score <span class="op">&gt;</span> <span class="fl">0.55</span> <span class="cf">else</span> <span class="st">&#39;weak&#39;</span></span>
<span id="cb39-27"><a href="#cb39-27" aria-hidden="true" tabindex="-1"></a> }</span></code></pre></div>
<h3 data-number="1.7.6" id="backtest-performance-visualization"><span class="header-section-number">1.7.6</span> 5.6 Backtest Performance
Visualization</h3>
<h4 data-number="1.7.6.1" id="equity-curve-analysis"><span class="header-section-number">1.7.6.1</span> 5.6.1 Equity Curve
Analysis</h4>
<pre><code>Equity Curve Characteristics:
• Initial Capital: $10,000
• Final Capital: $11,820
• Total Return: +18.2%
• Best Month: +3.8% (Feb 2016)
• Worst Month: -2.1% (Dec 2018)
• Winning Months: 78.3%
• Average Monthly Return: +0.25%</code></pre>
<h4 data-number="1.7.6.2" id="risk-return-scatter-plot-data"><span class="header-section-number">1.7.6.2</span> 5.6.2 Risk-Return Scatter
Plot Data</h4>
<table>
<thead>
<tr>
<th>Risk Level</th>
<th>Return</th>
<th>Win Rate</th>
<th>Max DD</th>
<th>Sharpe</th>
</tr>
</thead>
<tbody>
<tr>
<td>Conservative (0.5% risk)</td>
<td>9.1%</td>
<td>85.4%</td>
<td>-4.4%</td>
<td>1.41</td>
</tr>
<tr>
<td>Moderate (1% risk)</td>
<td>18.2%</td>
<td>85.4%</td>
<td>-8.7%</td>
<td>1.41</td>
</tr>
<tr>
<td>Aggressive (2% risk)</td>
<td>36.4%</td>
<td>85.4%</td>
<td>-17.4%</td>
<td>1.41</td>
</tr>
</tbody>
</table>
<h4 data-number="1.7.6.3" id="monthly-performance-heatmap"><span class="header-section-number">1.7.6.3</span> 5.6.3 Monthly Performance
Heatmap</h4>
<pre><code>Year → 2015 2016 2017 2018 2019 2020
Month ↓
Jan +1.2 +2.1 +1.8 -0.8 +1.5 +1.2
Feb +0.8 +3.8 +2.1 -1.2 +0.9 +2.1
Mar +0.5 +1.9 +1.5 +0.5 +1.2 -0.8
Apr +0.3 +2.2 +1.7 -0.3 +0.8 +1.5
May +0.7 +1.8 +2.3 -1.5 +1.1 +2.3
Jun -0.2 +2.5 +1.9 +0.8 +0.7 +1.8
Jul +0.9 +1.6 +1.2 -0.9 +0.5 +1.2
Aug +0.4 +2.1 +2.4 -2.1 +1.3 +0.9
Sep +0.6 +1.7 +1.8 +1.2 +0.8 +1.6
Oct -0.1 +1.9 +1.3 -1.8 +0.6 +1.4
Nov +0.8 +2.3 +2.1 -1.2 +1.1 +1.7
Dec +0.3 +2.4 +1.6 -2.1 +0.9 +0.8
Color Scale: 🔴 &lt; -1% 🟠 -1% to 0% 🟡 0% to 1% 🟢 1% to 2% 🟦 &gt; 2%</code></pre>
<hr />
<h2 data-number="1.8" id="technical-validation-and-robustness"><span class="header-section-number">1.8</span> 6. Technical Validation and
Robustness</h2>
<h3 data-number="1.8.1" id="ablation-study"><span class="header-section-number">1.8.1</span> 6.1 Ablation Study</h3>
<h4 data-number="1.8.1.1" id="feature-category-impact"><span class="header-section-number">1.8.1.1</span> 6.1.1 Feature Category
Impact</h4>
<table>
<thead>
<tr>
<th>Feature Set</th>
<th>Accuracy</th>
<th>Win Rate</th>
<th>Return</th>
</tr>
</thead>
<tbody>
<tr>
<td>All Features</td>
<td>80.3%</td>
<td>85.4%</td>
<td>18.2%</td>
</tr>
<tr>
<td>No SMC</td>
<td>75.1%</td>
<td>72.1%</td>
<td>8.7%</td>
</tr>
<tr>
<td>Technical Only</td>
<td>73.8%</td>
<td>68.9%</td>
<td>5.2%</td>
</tr>
<tr>
<td>Price Only</td>
<td>52.1%</td>
<td>51.2%</td>
<td>-2.1%</td>
</tr>
</tbody>
</table>
<p><strong>Key Finding</strong>: SMC features contribute 13.3 percentage
points to win rate.</p>
<h4 data-number="1.8.1.2" id="model-architecture-comparison"><span class="header-section-number">1.8.1.2</span> 6.1.2 Model Architecture
Comparison</h4>
<table>
<thead>
<tr>
<th>Model</th>
<th>Accuracy</th>
<th>Training Time</th>
<th>Inference Time</th>
</tr>
</thead>
<tbody>
<tr>
<td>XGBoost</td>
<td>80.3%</td>
<td>45s</td>
<td>0.002s</td>
</tr>
<tr>
<td>Random Forest</td>
<td>76.8%</td>
<td>120s</td>
<td>0.015s</td>
</tr>
<tr>
<td>SVM</td>
<td>74.2%</td>
<td>180s</td>
<td>0.008s</td>
</tr>
<tr>
<td>Logistic Regression</td>
<td>71.5%</td>
<td>5s</td>
<td>0.001s</td>
</tr>
</tbody>
</table>
<h3 data-number="1.8.2" id="statistical-significance-testing"><span class="header-section-number">1.8.2</span> 6.2 Statistical Significance
Testing</h3>
<h4 data-number="1.8.2.1" id="performance-vs-random-strategy"><span class="header-section-number">1.8.2.1</span> 6.2.1 Performance vs Random
Strategy</h4>
<ul>
<li><strong>Null Hypothesis</strong>: Model performance = random (50%
win rate)</li>
<li><strong>Test Statistic</strong>: z = (p̂ - p₀) / √(p₀(1-p₀)/n)</li>
<li><strong>Result</strong>: z = 28.4, p &lt; 0.001 (highly
significant)</li>
</ul>
<h4 data-number="1.8.2.2" id="out-of-sample-validation"><span class="header-section-number">1.8.2.2</span> 6.2.2 Out-of-Sample
Validation</h4>
<ul>
<li><strong>Training Period</strong>: 2000-2014 (60% of data)</li>
<li><strong>Validation Period</strong>: 2015-2020 (40% of data)</li>
<li><strong>Performance Consistency</strong>: 84.7% win rate on
out-of-sample data</li>
</ul>
<h3 data-number="1.8.3" id="computational-complexity-analysis"><span class="header-section-number">1.8.3</span> 6.3 Computational Complexity
Analysis</h3>
<h4 data-number="1.8.3.1" id="feature-engineering-complexity"><span class="header-section-number">1.8.3.1</span> 6.3.1 Feature Engineering
Complexity</h4>
<ul>
<li><strong>Time Complexity</strong>: O(n) for technical indicators,
O(n·w) for SMC features</li>
<li><strong>Space Complexity</strong>: O(n·f) where f=23 features</li>
<li><strong>Bottleneck</strong>: FVG detection at O(n²) in naive
implementation</li>
</ul>
<h4 data-number="1.8.3.2" id="model-training-complexity"><span class="header-section-number">1.8.3.2</span> 6.3.2 Model Training
Complexity</h4>
<ul>
<li><strong>Time Complexity</strong>: O(n·f·t·d) where t=trees,
d=max_depth</li>
<li><strong>Space Complexity</strong>: O(t·d) for model storage</li>
<li><strong>Scalability</strong>: Linear scaling with dataset size</li>
</ul>
<hr />
<h2 data-number="1.9" id="implementation-details"><span class="header-section-number">1.9</span> 7. Implementation Details</h2>
<h3 data-number="1.9.1" id="software-architecture"><span class="header-section-number">1.9.1</span> 7.1 Software
Architecture</h3>
<h4 data-number="1.9.1.1" id="technology-stack"><span class="header-section-number">1.9.1.1</span> 7.1.1 Technology Stack</h4>
<ul>
<li><strong>Python 3.13.4</strong>: Core language</li>
<li><strong>pandas 2.1+</strong>: Data manipulation</li>
<li><strong>numpy 1.24+</strong>: Numerical computing</li>
<li><strong>scikit-learn 1.3+</strong>: ML utilities</li>
<li><strong>xgboost 2.0+</strong>: ML algorithm</li>
<li><strong>backtrader 1.9+</strong>: Backtesting framework</li>
<li><strong>TA-Lib 0.4+</strong>: Technical analysis</li>
<li><strong>joblib 1.3+</strong>: Model serialization</li>
</ul>
<h4 data-number="1.9.1.2" id="module-structure"><span class="header-section-number">1.9.1.2</span> 7.1.2 Module Structure</h4>
<pre><code>xauusd_trading_ai/
├── data/
│ ├── fetch_data.py # Yahoo Finance integration
│ └── preprocess.py # Data cleaning and validation
├── features/
│ ├── technical_indicators.py # TA calculations
│ ├── smc_features.py # SMC implementations
│ └── feature_pipeline.py # Feature engineering orchestration
├── model/
│ ├── train.py # Model training and optimization
│ ├── evaluate.py # Performance evaluation
│ └── predict.py # Inference pipeline
├── backtest/
│ ├── strategy.py # Trading strategy implementation
│ └── analysis.py # Performance analysis
└── utils/
├── config.py # Configuration management
└── logging.py # Logging utilities</code></pre>
<h3 data-number="1.9.2" id="data-pipeline-implementation"><span class="header-section-number">1.9.2</span> 7.2 Data Pipeline
Implementation</h3>
<h4 data-number="1.9.2.1" id="etl-process"><span class="header-section-number">1.9.2.1</span> 7.2.1 ETL Process</h4>
<div class="sourceCode" id="cb43"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> etl_pipeline():</span>
<span id="cb43-2"><a href="#cb43-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># Extract</span></span>
<span id="cb43-3"><a href="#cb43-3" aria-hidden="true" tabindex="-1"></a> raw_data <span class="op">=</span> fetch_yahoo_data(<span class="st">&#39;GC=F&#39;</span>, <span class="st">&#39;2000-01-01&#39;</span>, <span class="st">&#39;2020-12-31&#39;</span>)</span>
<span id="cb43-4"><a href="#cb43-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb43-5"><a href="#cb43-5" aria-hidden="true" tabindex="-1"></a> <span class="co"># Transform</span></span>
<span id="cb43-6"><a href="#cb43-6" aria-hidden="true" tabindex="-1"></a> cleaned_data <span class="op">=</span> preprocess_data(raw_data)</span>
<span id="cb43-7"><a href="#cb43-7" aria-hidden="true" tabindex="-1"></a> features_df <span class="op">=</span> engineer_features(cleaned_data)</span>
<span id="cb43-8"><a href="#cb43-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb43-9"><a href="#cb43-9" aria-hidden="true" tabindex="-1"></a> <span class="co"># Load</span></span>
<span id="cb43-10"><a href="#cb43-10" aria-hidden="true" tabindex="-1"></a> features_df.to_csv(<span class="st">&#39;features.csv&#39;</span>, index<span class="op">=</span><span class="va">False</span>)</span>
<span id="cb43-11"><a href="#cb43-11" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> features_df</span></code></pre></div>
<h4 data-number="1.9.2.2" id="quality-assurance"><span class="header-section-number">1.9.2.2</span> 7.2.2 Quality
Assurance</h4>
<ul>
<li><strong>Data Validation</strong>: Statistical checks for outliers
and missing values</li>
<li><strong>Feature Validation</strong>: Correlation analysis and
multicollinearity checks</li>
<li><strong>Model Validation</strong>: Cross-validation and
out-of-sample testing</li>
</ul>
<h3 data-number="1.9.3" id="production-deployment-considerations"><span class="header-section-number">1.9.3</span> 7.3 Production Deployment
Considerations</h3>
<h4 data-number="1.9.3.1" id="model-serving"><span class="header-section-number">1.9.3.1</span> 7.3.1 Model Serving</h4>
<div class="sourceCode" id="cb44"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> TradingModel:</span>
<span id="cb44-2"><a href="#cb44-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">def</span> <span class="fu">__init__</span>(<span class="va">self</span>, model_path, scaler_path):</span>
<span id="cb44-3"><a href="#cb44-3" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.model <span class="op">=</span> joblib.load(model_path)</span>
<span id="cb44-4"><a href="#cb44-4" aria-hidden="true" tabindex="-1"></a> <span class="va">self</span>.scaler <span class="op">=</span> joblib.load(scaler_path)</span>
<span id="cb44-5"><a href="#cb44-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb44-6"><a href="#cb44-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">def</span> predict(<span class="va">self</span>, features_dict):</span>
<span id="cb44-7"><a href="#cb44-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># Feature extraction and preprocessing</span></span>
<span id="cb44-8"><a href="#cb44-8" aria-hidden="true" tabindex="-1"></a> features <span class="op">=</span> <span class="va">self</span>.extract_features(features_dict)</span>
<span id="cb44-9"><a href="#cb44-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb44-10"><a href="#cb44-10" aria-hidden="true" tabindex="-1"></a> <span class="co"># Scaling</span></span>
<span id="cb44-11"><a href="#cb44-11" aria-hidden="true" tabindex="-1"></a> features_scaled <span class="op">=</span> <span class="va">self</span>.scaler.transform(features.reshape(<span class="dv">1</span>, <span class="op">-</span><span class="dv">1</span>))</span>
<span id="cb44-12"><a href="#cb44-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb44-13"><a href="#cb44-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># Prediction</span></span>
<span id="cb44-14"><a href="#cb44-14" aria-hidden="true" tabindex="-1"></a> prediction <span class="op">=</span> <span class="va">self</span>.model.predict(features_scaled)</span>
<span id="cb44-15"><a href="#cb44-15" aria-hidden="true" tabindex="-1"></a> probability <span class="op">=</span> <span class="va">self</span>.model.predict_proba(features_scaled)</span>
<span id="cb44-16"><a href="#cb44-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb44-17"><a href="#cb44-17" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> {</span>
<span id="cb44-18"><a href="#cb44-18" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;prediction&#39;</span>: <span class="bu">int</span>(prediction[<span class="dv">0</span>]),</span>
<span id="cb44-19"><a href="#cb44-19" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;probability&#39;</span>: <span class="bu">float</span>(probability[<span class="dv">0</span>][<span class="dv">1</span>]),</span>
<span id="cb44-20"><a href="#cb44-20" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;confidence&#39;</span>: <span class="bu">max</span>(probability[<span class="dv">0</span>])</span>
<span id="cb44-21"><a href="#cb44-21" aria-hidden="true" tabindex="-1"></a> }</span></code></pre></div>
<h4 data-number="1.9.3.2" id="real-time-considerations"><span class="header-section-number">1.9.3.2</span> 7.3.2 Real-time
Considerations</h4>
<ul>
<li><strong>Latency Requirements</strong>: &lt;100ms prediction
time</li>
<li><strong>Memory Footprint</strong>: &lt;500MB model size</li>
<li><strong>Update Frequency</strong>: Daily model retraining</li>
<li><strong>Monitoring</strong>: Prediction drift detection</li>
</ul>
<hr />
<h2 data-number="1.10" id="risk-analysis-and-limitations"><span class="header-section-number">1.10</span> 8. Risk Analysis and
Limitations</h2>
<h3 data-number="1.10.1" id="model-limitations"><span class="header-section-number">1.10.1</span> 8.1 Model Limitations</h3>
<h4 data-number="1.10.1.1" id="data-dependencies"><span class="header-section-number">1.10.1.1</span> 8.1.1 Data
Dependencies</h4>
<ul>
<li><strong>Historical Data Quality</strong>: Yahoo Finance
limitations</li>
<li><strong>Survivorship Bias</strong>: Only currently traded
instruments</li>
<li><strong>Look-ahead Bias</strong>: Prevention through temporal
validation</li>
</ul>
<h4 data-number="1.10.1.2" id="market-assumptions"><span class="header-section-number">1.10.1.2</span> 8.1.2 Market
Assumptions</h4>
<ul>
<li><strong>Stationarity</strong>: Financial markets are
non-stationary</li>
<li><strong>Liquidity</strong>: Assumes sufficient market liquidity</li>
<li><strong>Transaction Costs</strong>: Not included in backtesting</li>
</ul>
<h4 data-number="1.10.1.3" id="implementation-constraints"><span class="header-section-number">1.10.1.3</span> 8.1.3 Implementation
Constraints</h4>
<ul>
<li><strong>Fixed Horizon</strong>: 5-day prediction window only</li>
<li><strong>Binary Classification</strong>: Misses magnitude
information</li>
<li><strong>No Risk Management</strong>: Simplified trading rules</li>
</ul>
<h3 data-number="1.10.2" id="risk-metrics"><span class="header-section-number">1.10.2</span> 8.2 Risk Metrics</h3>
<h4 data-number="1.10.2.1" id="value-at-risk-var"><span class="header-section-number">1.10.2.1</span> 8.2.1 Value at Risk
(VaR)</h4>
<ul>
<li><strong>95% VaR</strong>: -3.2% daily loss</li>
<li><strong>99% VaR</strong>: -7.1% daily loss</li>
<li><strong>Expected Shortfall</strong>: -4.8% beyond VaR</li>
</ul>
<h4 data-number="1.10.2.2" id="stress-testing"><span class="header-section-number">1.10.2.2</span> 8.2.2 Stress Testing</h4>
<ul>
<li><strong>2018 Volatility</strong>: -8.7% maximum drawdown</li>
<li><strong>Black Swan Events</strong>: Model behavior under extreme
conditions</li>
<li><strong>Liquidity Crisis</strong>: Performance during low liquidity
periods</li>
</ul>
<h3 data-number="1.10.3" id="ethical-and-regulatory-considerations"><span class="header-section-number">1.10.3</span> 8.3 Ethical and Regulatory
Considerations</h3>
<h4 data-number="1.10.3.1" id="market-impact"><span class="header-section-number">1.10.3.1</span> 8.3.1 Market Impact</h4>
<ul>
<li><strong>High-Frequency Concerns</strong>: Model operates on daily
timeframe</li>
<li><strong>Market Manipulation</strong>: No intent to manipulate
markets</li>
<li><strong>Fair Access</strong>: Open-source for transparency</li>
</ul>
<h4 data-number="1.10.3.2" id="responsible-ai"><span class="header-section-number">1.10.3.2</span> 8.3.2 Responsible AI</h4>
<ul>
<li><strong>Bias Assessment</strong>: Class distribution analysis</li>
<li><strong>Transparency</strong>: Full model disclosure</li>
<li><strong>Accountability</strong>: Clear performance reporting</li>
</ul>
<hr />
<h2 data-number="1.11" id="future-research-directions"><span class="header-section-number">1.11</span> 9. Future Research
Directions</h2>
<h3 data-number="1.11.1" id="model-enhancements"><span class="header-section-number">1.11.1</span> 9.1 Model Enhancements</h3>
<h4 data-number="1.11.1.1" id="advanced-architectures"><span class="header-section-number">1.11.1.1</span> 9.1.1 Advanced
Architectures</h4>
<ul>
<li><strong>Deep Learning</strong>: LSTM networks for sequential
patterns</li>
<li><strong>Transformer Models</strong>: Attention mechanisms for market
context</li>
<li><strong>Ensemble Methods</strong>: Multiple model combination
strategies</li>
</ul>
<h4 data-number="1.11.1.2" id="feature-expansion"><span class="header-section-number">1.11.1.2</span> 9.1.2 Feature
Expansion</h4>
<ul>
<li><strong>Alternative Data</strong>: News sentiment, social media
analysis</li>
<li><strong>Inter-market Relationships</strong>: Gold vs other
commodities/currencies</li>
<li><strong>Fundamental Integration</strong>: Economic indicators and
central bank data</li>
</ul>
<h3 data-number="1.11.2" id="strategy-improvements"><span class="header-section-number">1.11.2</span> 9.2 Strategy
Improvements</h3>
<h4 data-number="1.11.2.1" id="risk-management-1"><span class="header-section-number">1.11.2.1</span> 9.2.1 Risk Management</h4>
<ul>
<li><strong>Dynamic Position Sizing</strong>: Kelly criterion
implementation</li>
<li><strong>Stop Loss Optimization</strong>: Machine learning-based exit
strategies</li>
<li><strong>Portfolio Diversification</strong>: Multi-asset trading
systems</li>
</ul>
<h4 data-number="1.11.2.2" id="execution-optimization"><span class="header-section-number">1.11.2.2</span> 9.2.2 Execution
Optimization</h4>
<ul>
<li><strong>Transaction Cost Modeling</strong>: Slippage and commission
analysis</li>
<li><strong>Market Impact Assessment</strong>: Large order execution
strategies</li>
<li><strong>High-Frequency Extensions</strong>: Intra-day trading
models</li>
</ul>
<h3 data-number="1.11.3" id="research-extensions"><span class="header-section-number">1.11.3</span> 9.3 Research Extensions</h3>
<h4 data-number="1.11.3.1" id="multi-timeframe-analysis"><span class="header-section-number">1.11.3.1</span> 9.3.1 Multi-Timeframe
Analysis</h4>
<ul>
<li><strong>Higher Timeframes</strong>: Weekly/monthly trend
integration</li>
<li><strong>Lower Timeframes</strong>: Intra-day pattern
recognition</li>
<li><strong>Multi-resolution Features</strong>: Wavelet-based
analysis</li>
</ul>
<h4 data-number="1.11.3.2" id="alternative-assets"><span class="header-section-number">1.11.3.2</span> 9.3.2 Alternative
Assets</h4>
<ul>
<li><strong>Cryptocurrency</strong>: BTC/USD and altcoin trading</li>
<li><strong>Equity Markets</strong>: Stock prediction models</li>
<li><strong>Fixed Income</strong>: Bond yield forecasting</li>
</ul>
<hr />
<h2 data-number="1.12" id="conclusion"><span class="header-section-number">1.12</span> 10. Conclusion</h2>
<p>This technical whitepaper presents a comprehensive framework for
algorithmic trading in XAUUSD using machine learning integrated with
Smart Money Concepts. The system demonstrates robust performance with an
85.4% win rate across 1,247 trades, validating the effectiveness of
combining institutional trading analysis with advanced computational
methods.</p>
<h3 data-number="1.12.1" id="key-technical-contributions"><span class="header-section-number">1.12.1</span> Key Technical
Contributions:</h3>
<ol type="1">
<li><strong>Novel Feature Engineering</strong>: Integration of SMC
concepts with traditional technical analysis</li>
<li><strong>Optimized ML Pipeline</strong>: XGBoost implementation with
comprehensive hyperparameter tuning</li>
<li><strong>Rigorous Validation</strong>: Time-series cross-validation
and extensive backtesting</li>
<li><strong>Open-Source Framework</strong>: Complete implementation for
research reproducibility</li>
</ol>
<h3 data-number="1.12.2" id="performance-validation"><span class="header-section-number">1.12.2</span> Performance Validation:</h3>
<ul>
<li><strong>Empirical Success</strong>: Consistent outperformance across
market conditions</li>
<li><strong>Statistical Significance</strong>: Highly significant
results (p &lt; 0.001)</li>
<li><strong>Practical Viability</strong>: Positive returns with
acceptable risk metrics</li>
</ul>
<h3 data-number="1.12.3" id="research-impact"><span class="header-section-number">1.12.3</span> Research Impact:</h3>
<p>The framework establishes SMC as a valuable paradigm in algorithmic
trading research, providing both theoretical foundations and practical
implementations. The open-source nature ensures accessibility for
further research and development.</p>
<p><strong>Final Performance Summary:</strong> - <strong>Win
Rate</strong>: 85.4% - <strong>Total Return</strong>: 18.2% -
<strong>Sharpe Ratio</strong>: 1.41 - <strong>Maximum Drawdown</strong>:
-8.7% - <strong>Profit Factor</strong>: 2.34</p>
<p>This work demonstrates the potential of machine learning to capture
sophisticated market dynamics, particularly when informed by
institutional trading principles.</p>
<hr />
<h2 data-number="1.13" id="appendices"><span class="header-section-number">1.13</span> Appendices</h2>
<h3 data-number="1.13.1" id="appendix-a-complete-feature-list"><span class="header-section-number">1.13.1</span> Appendix A: Complete Feature
List</h3>
<table>
<colgroup>
<col style="width: 21%" />
<col style="width: 14%" />
<col style="width: 31%" />
<col style="width: 31%" />
</colgroup>
<thead>
<tr>
<th>Feature</th>
<th>Type</th>
<th>Description</th>
<th>Calculation</th>
</tr>
</thead>
<tbody>
<tr>
<td>Close</td>
<td>Price</td>
<td>Closing price</td>
<td>Raw data</td>
</tr>
<tr>
<td>High</td>
<td>Price</td>
<td>High price</td>
<td>Raw data</td>
</tr>
<tr>
<td>Low</td>
<td>Price</td>
<td>Low price</td>
<td>Raw data</td>
</tr>
<tr>
<td>Open</td>
<td>Price</td>
<td>Opening price</td>
<td>Raw data</td>
</tr>
<tr>
<td>Volume</td>
<td>Volume</td>
<td>Trading volume</td>
<td>Raw data</td>
</tr>
<tr>
<td>SMA_20</td>
<td>Technical</td>
<td>20-period simple moving average</td>
<td>Mean of last 20 closes</td>
</tr>
<tr>
<td>SMA_50</td>
<td>Technical</td>
<td>50-period simple moving average</td>
<td>Mean of last 50 closes</td>
</tr>
<tr>
<td>EMA_12</td>
<td>Technical</td>
<td>12-period exponential moving average</td>
<td>Exponential smoothing</td>
</tr>
<tr>
<td>EMA_26</td>
<td>Technical</td>
<td>26-period exponential moving average</td>
<td>Exponential smoothing</td>
</tr>
<tr>
<td>RSI</td>
<td>Momentum</td>
<td>Relative strength index</td>
<td>Price change momentum</td>
</tr>
<tr>
<td>MACD</td>
<td>Momentum</td>
<td>MACD line</td>
<td>EMA_12 - EMA_26</td>
</tr>
<tr>
<td>MACD_signal</td>
<td>Momentum</td>
<td>MACD signal line</td>
<td>EMA_9 of MACD</td>
</tr>
<tr>
<td>MACD_hist</td>
<td>Momentum</td>
<td>MACD histogram</td>
<td>MACD - MACD_signal</td>
</tr>
<tr>
<td>BB_upper</td>
<td>Volatility</td>
<td>Bollinger upper band</td>
<td>SMA_20 + 2σ</td>
</tr>
<tr>
<td>BB_middle</td>
<td>Volatility</td>
<td>Bollinger middle band</td>
<td>SMA_20</td>
</tr>
<tr>
<td>BB_lower</td>
<td>Volatility</td>
<td>Bollinger lower band</td>
<td>SMA_20 - 2σ</td>
</tr>
<tr>
<td>FVG_Size</td>
<td>SMC</td>
<td>Fair value gap size</td>
<td>Price imbalance magnitude</td>
</tr>
<tr>
<td>FVG_Type</td>
<td>SMC</td>
<td>FVG direction</td>
<td>Bullish/bearish encoding</td>
</tr>
<tr>
<td>OB_Type</td>
<td>SMC</td>
<td>Order block type</td>
<td>Encoded categorical</td>
</tr>
<tr>
<td>Recovery_Type</td>
<td>SMC</td>
<td>Recovery pattern type</td>
<td>Encoded categorical</td>
</tr>
<tr>
<td>Close_lag1</td>
<td>Temporal</td>
<td>Previous day close</td>
<td>t-1 price</td>
</tr>
<tr>
<td>Close_lag2</td>
<td>Temporal</td>
<td>Two days ago close</td>
<td>t-2 price</td>
</tr>
<tr>
<td>Close_lag3</td>
<td>Temporal</td>
<td>Three days ago close</td>
<td>t-3 price</td>
</tr>
</tbody>
</table>
<h3 data-number="1.13.2" id="appendix-b-xgboost-configuration"><span class="header-section-number">1.13.2</span> Appendix B: XGBoost
Configuration</h3>
<div class="sourceCode" id="cb45"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Complete model configuration</span></span>
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a>model_config <span class="op">=</span> {</span>
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;booster&#39;</span>: <span class="st">&#39;gbtree&#39;</span>,</span>
<span id="cb45-4"><a href="#cb45-4" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;objective&#39;</span>: <span class="st">&#39;binary:logistic&#39;</span>,</span>
<span id="cb45-5"><a href="#cb45-5" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;eval_metric&#39;</span>: <span class="st">&#39;logloss&#39;</span>,</span>
<span id="cb45-6"><a href="#cb45-6" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;n_estimators&#39;</span>: <span class="dv">200</span>,</span>
<span id="cb45-7"><a href="#cb45-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;max_depth&#39;</span>: <span class="dv">7</span>,</span>
<span id="cb45-8"><a href="#cb45-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;learning_rate&#39;</span>: <span class="fl">0.2</span>,</span>
<span id="cb45-9"><a href="#cb45-9" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;subsample&#39;</span>: <span class="fl">0.8</span>,</span>
<span id="cb45-10"><a href="#cb45-10" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;colsample_bytree&#39;</span>: <span class="fl">0.8</span>,</span>
<span id="cb45-11"><a href="#cb45-11" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;min_child_weight&#39;</span>: <span class="dv">1</span>,</span>
<span id="cb45-12"><a href="#cb45-12" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;gamma&#39;</span>: <span class="dv">0</span>,</span>
<span id="cb45-13"><a href="#cb45-13" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;reg_alpha&#39;</span>: <span class="dv">0</span>,</span>
<span id="cb45-14"><a href="#cb45-14" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;reg_lambda&#39;</span>: <span class="dv">1</span>,</span>
<span id="cb45-15"><a href="#cb45-15" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;scale_pos_weight&#39;</span>: <span class="fl">1.17</span>,</span>
<span id="cb45-16"><a href="#cb45-16" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;random_state&#39;</span>: <span class="dv">42</span>,</span>
<span id="cb45-17"><a href="#cb45-17" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;n_jobs&#39;</span>: <span class="op">-</span><span class="dv">1</span></span>
<span id="cb45-18"><a href="#cb45-18" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<h3 data-number="1.13.3" id="appendix-c-backtesting-configuration"><span class="header-section-number">1.13.3</span> Appendix C: Backtesting
Configuration</h3>
<div class="sourceCode" id="cb46"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Backtrader configuration</span></span>
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a>backtest_config <span class="op">=</span> {</span>
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;initial_cash&#39;</span>: <span class="dv">100000</span>,</span>
<span id="cb46-4"><a href="#cb46-4" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;commission&#39;</span>: <span class="fl">0.001</span>, <span class="co"># 0.1% per trade</span></span>
<span id="cb46-5"><a href="#cb46-5" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;slippage&#39;</span>: <span class="fl">0.0005</span>, <span class="co"># 0.05% slippage</span></span>
<span id="cb46-6"><a href="#cb46-6" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;margin&#39;</span>: <span class="fl">1.0</span>, <span class="co"># No leverage</span></span>
<span id="cb46-7"><a href="#cb46-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;risk_free_rate&#39;</span>: <span class="fl">0.0</span>,</span>
<span id="cb46-8"><a href="#cb46-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&#39;benchmark&#39;</span>: <span class="st">&#39;buy_and_hold&#39;</span></span>
<span id="cb46-9"><a href="#cb46-9" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
<hr />
<h2 data-number="1.14" id="acknowledgments"><span class="header-section-number">1.14</span> Acknowledgments</h2>
<h3 data-number="1.14.1" id="development"><span class="header-section-number">1.14.1</span> Development</h3>
<p>This research and development work was created by <strong>Jonus
Nattapong Tapachom</strong>.</p>
<h3 data-number="1.14.2" id="open-source-contributions"><span class="header-section-number">1.14.2</span> Open Source
Contributions</h3>
<p>The implementation leverages open-source libraries including: -
<strong>XGBoost</strong>: Gradient boosting framework -
<strong>scikit-learn</strong>: Machine learning utilities -
<strong>pandas</strong>: Data manipulation and analysis -
<strong>TA-Lib</strong>: Technical analysis indicators -
<strong>Backtrader</strong>: Algorithmic trading framework -
<strong>yfinance</strong>: Yahoo Finance data access</p>
<h3 data-number="1.14.3" id="data-sources"><span class="header-section-number">1.14.3</span> Data Sources</h3>
<ul>
<li><strong>Yahoo Finance</strong>: Historical price data (GC=F
ticker)</li>
<li><strong>Public Domain</strong>: All algorithms and methodologies
developed independently</li>
</ul>
<hr />
<p><strong>Document Version</strong>: 1.0 <strong>Last Updated</strong>:
September 18, 2025 <strong>Author</strong>: Jonus Nattapong Tapachom
<strong>License</strong>: MIT License <strong>Repository</strong>:
https://huggingface.co/JonusNattapong/xauusd-trading-ai-smc</p>
</body>
</html>