The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.
An order call queues an order; the broker emulator fills it on a later price. The account holds one net position (strategy.position_size: positive long, negative short) made of open entries, which close oldest first.
On historical bars the emulator steps through each bar’s prices (open, then high and low, then close; high first when the open is nearer the high), filling queued orders at each step. The script runs once, at the close, so an order placed on bar N is first tested on bar N+1:
A market order fills at the open of bar N+1. With process_orders_on_close=true, an order placed on a confirmed bar also fills at that bar’s close.
A limit order fills at the first step at the limit or better (long: at or below). A stop order fills at the first step at the stop or worse (long: at or above). A stop-limit order arms at the stop, then fills by the limit rule.
The fill price is that step’s price, not the limit or stop level: a long limit at 99 on a bar that opens at 98 fills at 98.
Take-profit (limit) and stop-loss (stop) for the open position or for the entry from_entry. profit and loss are distances in ticks (syminfo.minmove) from the entry price; given with a price, the nearer level wins.
strategy.close(id, qty, comment)
Closes the entry named id at market, all or qty.
strategy.close_all(comment)
Closes the whole position at market.
strategy.cancel(id), strategy.cancel_all()
Remove the queued orders with that id, or all; nothing happens if there are none.
qty defaults to default_qty_value. For entry and order, a qty of zero or less counts as not given; for close it means the entry’s whole open quantity; for exit it stops the script with Invalid order quantity, as does a default size that cannot be worked out.
Reversal:strategy.entry against the open position closes it and opens the other side in one fill.
Pyramiding: an entry is ignored, without an error, when pyramiding entries are already open in its direction.
Same id:entry or order with an id still queued replaces that order; flipping its direction stops the script (Entry order direction cannot be changed...).
Exit: ignored when the position is flat at the call, or when no limit, stop, profit or loss is given, so call it on bars where you are already in the trade, not on the entry bar. It queues two orders and a fill removes the other; a new call with the same id replaces both. qty defaults to the whole open quantity.
OCA:oca_name works only with oca_type: strategy.oca_cancel removes the group’s other orders on a fill, strategy.oca_reduce reduces their quantity.
Direction is a plain string: "buy" compiles, then stops the script: invalid strategy direction "buy".
GoCharting is a charting and analytics tool. This is not investment advice. Trading and investing carry a high risk of loss and are not suitable for everyone. You can lose some or all of your money.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"GoCharting","description":"GoCharting documentation. This site currently covers Lipi Script, GoCharting's scripting language: the v2 manual and the language reference. The platform user guide and the Charting SDK documentation are at https://gocharting.com/docs.","colors":{"primary":"#ffaa01","light":"#ffaa01","dark":"#ffaa01"},"logo":{"light":"https://mintcdn.com/go-charting-inc/JBs2pgZxOIEv87rH/logo/light.svg?fit=max\u0026auto=format\u0026n=JBs2pgZxOIEv87rH\u0026q=85\u0026s=e11aff4c1906dd58c9f7eceeea946e41","dark":"https://mintcdn.com/go-charting-inc/JBs2pgZxOIEv87rH/logo/dark.svg?fit=max\u0026auto=format\u0026n=JBs2pgZxOIEv87rH\u0026q=85\u0026s=9072a8977cf3d186f5b38de87d18af44","href":"https://gocharting.com"},"favicon":"https://mintcdn.com/go-charting-inc/JBs2pgZxOIEv87rH/favicon.svg?fit=max\u0026auto=format\u0026n=JBs2pgZxOIEv87rH\u0026q=85\u0026s=ae9441a870f9461b51bfedbae2718f20","appearance":{"default":"dark","strict":true},"background":{"color":{"light":"#1a1923","dark":"#1a1923"}},"navbar":{"links":[{"href":"https://gocharting.com/","label":"Products"},{"href":"https://gocharting.com/pricing","label":"Pricing"},{"href":"https://gocharting.com/education","label":"Resources"},{"href":"https://gocharting.com/sign-in","label":"Sign in"}],"primary":{"type":"button","label":"Open GoCharting","href":"https://gocharting.com"}},"footer":{"socials":{"x":"https://x.com/GoCharting","youtube":"https://youtube.com/@GoCharting","linkedin":"https://linkedin.com/company/gocharting","facebook":"https://facebook.com/GoCharting","instagram":"https://instagram.com/gocharting_official"}},"seo":{"metatags":{"canonical":"https://gocharting.com/docs","og:image":"https://gocharting.com/og/docs.png","twitter:image":"https://gocharting.com/og/docs.png"}},"fonts":{"heading":{"family":"Satoshi","weight":500,"source":"https://go-charting-inc.mintlify.site/docs/fonts/satoshi-latin-500-normal.woff2","format":"woff2"},"body":{"family":"Inter","weight":400,"source":"https://go-charting-inc.mintlify.site/docs/fonts/inter-latin-wght-normal.woff2","format":"woff2"}},"styling":{"codeblocks":{"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}},"latex":false},"integrations":{"gtm":{"tagId":"GTM-TF6Q9FJ"},"intercom":{"appId":"nrxfha2b"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","add-mcp","cursor","vscode"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"go-charting-inc","hasAudioNarration":false,"actualSubdomain":"go-charting-inc","customDomains":["gocharting.com"],"gitSource":{"type":"github","owner":"gochartinginc","repo":"gocharting-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"latestBuiltDeploymentHistoryId":"6ae8736c6bec035f345955c1","collectionId":"a401a759-5d3e-4d31-8933-4ad42a1a15b3","liveDeploymentHistoryId":"6ae8736c6bec035f345955c1","schemaVersion":"v3"},"feedback":{"agentFeedback":true,"edits":false,"issues":false,"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae8736c6bec035f345955c1","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"default","tag":"Lipi Script","count":147},{"language":"default","tag":"Manual","count":72},{"language":"default","tag":"Reference","count":70},{"language":"default","tag":"How to","count":21},{"language":"default","tag":"Functions","count":18},{"language":"default","tag":"Language map","count":18},{"language":"default","tag":"Constants","count":14},{"language":"default","tag":"Variables","count":14},{"language":"default","tag":"Writing Lipi","count":11},{"language":"default","tag":"Putting results on the chart","count":8}],"searchSettings":{"showContentSnippets":true}},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"support@gocharting.com"}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":":root{--gc-bg:#1a1923;--gc-header-bg:#05060e;--gc-elevated:#232128;--gc-accent:#ffaa01;--gc-on-accent:#1a1923;--gc-positive:#009d54;--gc-negative:#ca4a4a;--gc-border:rgba(255, 255, 255, 0.08);--gc-radius:12px}#navbar,#navbar>div{background-color:var(--gc-header-bg);border-color:var(--gc-border)}#navbar a[href][class*=rounded]{background-color:var(--gc-accent);color:var(--gc-on-accent);border-radius:var(--gc-radius)}code,pre{font-family:\"IBM Plex Mono\",ui-monospace,Consolas,monospace}"}],"page":{"pagePath":"scripting/strategies/orders-and-positions","slug":"/scripting/strategies/orders-and-positions","pageMetadata":{"title":"Orders and positions","description":"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.","canonical":"https://gocharting.com/docs/scripting/strategies/orders-and-positions","href":"/scripting/strategies/orders-and-positions"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`An order call queues an order; the broker emulator fills it on a later price. The account holds one net position (`,_jsx(_components.code,{children:`strategy.position_size`}),`: positive long, negative short) made of open entries, which close oldest first.`]}),`\n`,_jsx(Heading,{level:`2`,id:`when-orders-fill`,children:`When orders fill`}),`\n`,_jsx(_components.p,{children:`On historical bars the emulator steps through each bar’s prices (open, then high and low, then close; high first when the open is nearer the high), filling queued orders at each step. The script runs once, at the close, so an order placed on bar N is first tested on bar N+1:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`A market order fills at the open of bar N+1. With `,_jsx(_components.code,{children:`process_orders_on_close=true`}),`, an order placed on a confirmed bar also fills at that bar’s close.`]}),`\n`,_jsx(_components.li,{children:`A limit order fills at the first step at the limit or better (long: at or below). A stop order fills at the first step at the stop or worse (long: at or above). A stop-limit order arms at the stop, then fills by the limit rule.`}),`\n`,_jsx(_components.li,{children:`The fill price is that step’s price, not the limit or stop level: a long limit at 99 on a bar that opens at 98 fills at 98.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-order-calls`,children:`The order calls`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Call`}),_jsx(_components.th,{children:`What it does`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`strategy.entry(id, direction, qty, limit, stop, oca_name, oca_type, comment)`})}),_jsxs(_components.td,{children:[`Opens or adds to a position. `,_jsx(_components.code,{children:`direction`}),` is `,_jsx(_components.code,{children:`strategy.long`}),` or `,_jsx(_components.code,{children:`strategy.short`}),`. `,_jsx(_components.code,{children:`limit`}),` and/or `,_jsx(_components.code,{children:`stop`}),` make it wait; otherwise market.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`strategy.order(id, direction, qty, limit, stop, oca_name, oca_type, comment)`})}),_jsxs(_components.td,{children:[`A raw net order: long adds, short subtracts, whatever the position. Can open, add, reduce or reverse; `,_jsx(_components.code,{children:`pyramiding`}),` does not apply.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`strategy.exit(id, from_entry, qty, profit, limit, loss, stop, oca_name, comment)`})}),_jsxs(_components.td,{children:[`Take-profit (`,_jsx(_components.code,{children:`limit`}),`) and stop-loss (`,_jsx(_components.code,{children:`stop`}),`) for the open position or for the entry `,_jsx(_components.code,{children:`from_entry`}),`. `,_jsx(_components.code,{children:`profit`}),` and `,_jsx(_components.code,{children:`loss`}),` are distances in ticks (`,_jsx(_components.code,{children:`syminfo.minmove`}),`) from the entry price; given with a price, the nearer level wins.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`strategy.close(id, qty, comment)`})}),_jsxs(_components.td,{children:[`Closes the entry named `,_jsx(_components.code,{children:`id`}),` at market, all or `,_jsx(_components.code,{children:`qty`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`strategy.close_all(comment)`})}),_jsx(_components.td,{children:`Closes the whole position at market.`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`strategy.cancel(id)`}),`, `,_jsx(_components.code,{children:`strategy.cancel_all()`})]}),_jsxs(_components.td,{children:[`Remove the queued orders with that `,_jsx(_components.code,{children:`id`}),`, or all; nothing happens if there are none.`]})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`qty`}),` defaults to `,_jsx(_components.code,{children:`default_qty_value`}),`. For `,_jsx(_components.code,{children:`entry`}),` and `,_jsx(_components.code,{children:`order`}),`, a `,_jsx(_components.code,{children:`qty`}),` of zero or less counts as not given; for `,_jsx(_components.code,{children:`close`}),` it means the entry’s whole open quantity; for `,_jsx(_components.code,{children:`exit`}),` it stops the script with `,_jsx(_components.code,{children:`Invalid order quantity`}),`, as does a default size that cannot be worked out.`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Reversal:`}),` `,_jsx(_components.code,{children:`strategy.entry`}),` against the open position closes it and opens the other side in one fill.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Pyramiding:`}),` an entry is ignored, without an error, when `,_jsx(_components.code,{children:`pyramiding`}),` entries are already open in its direction.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Same id:`}),` `,_jsx(_components.code,{children:`entry`}),` or `,_jsx(_components.code,{children:`order`}),` with an id still queued replaces that order; flipping its direction stops the script (`,_jsx(_components.code,{children:`Entry order direction cannot be changed...`}),`).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Exit:`}),` ignored when the position is flat at the call, or when no `,_jsx(_components.code,{children:`limit`}),`, `,_jsx(_components.code,{children:`stop`}),`, `,_jsx(_components.code,{children:`profit`}),` or `,_jsx(_components.code,{children:`loss`}),` is given, so call it on bars where you are already in the trade, not on the entry bar. It queues two orders and a fill removes the other; a new call with the same `,_jsx(_components.code,{children:`id`}),` replaces both. `,_jsx(_components.code,{children:`qty`}),` defaults to the whole open quantity.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`OCA:`}),` `,_jsx(_components.code,{children:`oca_name`}),` works only with `,_jsx(_components.code,{children:`oca_type`}),`: `,_jsx(_components.code,{children:`strategy.oca_cancel`}),` removes the group’s other orders on a fill, `,_jsx(_components.code,{children:`strategy.oca_reduce`}),` reduces their quantity.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Direction`}),` is a plain string: `,_jsx(_components.code,{children:`\"buy\"`}),` compiles, then stops the script: `,_jsx(_components.code,{children:`invalid strategy direction \"buy\"`}),`.`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`GoCharting is a charting and analytics tool. This is not investment advice. Trading and investing carry a high risk of loss and are not suitable for everyone. You can lose some or all of your money.`})}),`\n`,_jsx(CodeBlock,{filename:``,wrap:`true`,numberOfLines:`10`,language:`lipi`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`lipi`,children:_jsxs(_components.code,{language:`lipi`,numberOfLines:`10`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`//@lipi=2`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`strategy`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Breakout with exit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, overlay`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`hh `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` talib.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`highest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`high`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`20`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` close`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` hh[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`and`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` strategy.position_size`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` strategy.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`entry`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Long\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`strategy.long`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` strategy.position_size`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` >`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` strategy.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`exit`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Exit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, from_entry`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Long\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, stop`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`strategy.position_avg_price`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0.97`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, limit`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`strategy.position_avg_price`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1.06`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`plot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(hh, title`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"20-bar high\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}},"config":{},"pageMetadata":{"title":"Orders and positions","description":"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.","canonical":"https://gocharting.com/docs/scripting/strategies/orders-and-positions","href":"/scripting/strategies/orders-and-positions"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"When orders fill","slug":"when-orders-fill","depth":2,"children":[]},{"title":"The order calls","slug":"the-order-calls","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"go-charting-inc","siteName":"GoCharting","title":"Orders and positions - GoCharting","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-28T14:12:32.678Z","originalFileLocation":"scripting/strategies/orders-and-positions.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"dark\";if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\">\u003cmeta data-mint-head name=\"application-name\" content=\"GoCharting\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Orders and positions - GoCharting\">\u003cmeta data-mint-head property=\"og:description\" content=\"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"GoCharting\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://gocharting.com/docs/scripting/strategies/orders-and-positions\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://gocharting.com/og/docs.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Orders and positions - GoCharting\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://gocharting.com/og/docs.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/go-charting-inc/Kr_zHwHt63dK5kAC/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"GoCharting\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#ffaa01\">\u003clink data-mint-head rel=\"canonical\" href=\"https://gocharting.com/docs/scripting/strategies/orders-and-positions\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/scripting/strategies/orders-and-positions.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://gocharting.com/#organization\",\"name\":\"GoCharting\",\"url\":\"https://gocharting.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/go-charting-inc/JBs2pgZxOIEv87rH/logo/light.svg?fit=max\u0026auto=format\u0026n=JBs2pgZxOIEv87rH\u0026q=85\u0026s=e11aff4c1906dd58c9f7eceeea946e41\"}},{\"@type\":\"WebSite\",\"@id\":\"https://gocharting.com/docs#website\",\"name\":\"GoCharting\",\"url\":\"https://gocharting.com/docs\",\"publisher\":{\"@id\":\"https://gocharting.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions#webpage\",\"url\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions\",\"name\":\"Orders and positions\",\"description\":\"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\",\"dateModified\":\"2026-10-28T14:12:32.678Z\",\"isPartOf\":{\"@id\":\"https://gocharting.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Manual\",\"item\":\"https://gocharting.com/docs/scripting/getting-started/first-script\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Strategies\",\"item\":\"https://gocharting.com/docs/scripting/strategies/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Orders and positions\",\"item\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions#article\",\"headline\":\"Orders and positions\",\"name\":\"Orders and positions\",\"description\":\"The order functions, when and at what price each order fills, how entries, exits and reversals change the position, and the errors orders can raise.\",\"url\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions\",\"mainEntityOfPage\":{\"@id\":\"https://gocharting.com/docs/scripting/strategies/orders-and-positions#webpage\"},\"image\":\"https://gocharting.com/og/docs.png\",\"dateModified\":\"2026-10-28T14:12:32.678Z\",\"publisher\":{\"@id\":\"https://gocharting.com/#organization\"},\"isPartOf\":{\"@id\":\"https://gocharting.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"GoCharting\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"GoCharting","nav":{"global":null,"tabs":[{"tab":"Lipi Script","pages":[{"title":"Scripting on GoCharting","href":"/scripting"},{"title":"Why Lipi exists","href":"/scripting/lipi-genesis"},{"group":"Manual","pages":[{"group":"Getting started","pages":[{"title":"Write your first script","href":"/scripting/getting-started/first-script"},{"title":"The Lipi editor","href":"/scripting/getting-started/editor"},{"title":"Reading someone else's script","href":"/scripting/getting-started/reading-scripts"},{"title":"What Lipi does not do","href":"/scripting/getting-started/not-supported"},{"title":"Moving a script from Lipi v1 to v2","href":"/scripting/getting-started/migrating-from-v1"}]},{"group":"Tutorials","pages":[{"title":"Add an input to your script","href":"/scripting/learn/add-an-input"},{"title":"Alert on your own condition","href":"/scripting/learn/alert-on-your-condition"},{"title":"Color a plot by condition","href":"/scripting/learn/color-by-condition"},{"title":"Read someone else's script","href":"/scripting/learn/read-someone-elses-script"},{"title":"Draw a level and a label","href":"/scripting/learn/draw-a-level-and-a-label"},{"title":"Keep the last values in an array","href":"/scripting/learn/keep-the-last-values-in-an-array"},{"title":"Backtest a moving-average crossover","href":"/scripting/learn/backtest-a-crossover"}]},{"group":"How to","pages":[{"title":"How to avoid a result that changes after the bar closes","sidebarTitle":"Avoid a result that changes after the bar closes","href":"/scripting/how-to/avoid-a-result-that-changes-after-the-bar-closes"},{"title":"How to color bars by a condition","sidebarTitle":"Color bars by a condition","href":"/scripting/how-to/color-bars-by-a-condition"},{"title":"How to draw a line between two pivots","sidebarTitle":"Draw a line between two pivots","href":"/scripting/how-to/draw-a-line-between-two-pivots"},{"title":"How to group and lay out your inputs","sidebarTitle":"Group and lay out your inputs","href":"/scripting/how-to/group-and-lay-out-your-inputs"},{"title":"How to keep a running total across bars","sidebarTitle":"Keep a running total across bars","href":"/scripting/how-to/keep-a-running-total-across-bars"},{"title":"How to let the chart user choose a color","sidebarTitle":"Let the chart user choose a color","href":"/scripting/how-to/let-the-chart-user-choose-a-color"},{"title":"How to plot a value on its own scale rather than over price","sidebarTitle":"Plot a value on its own scale rather than over price","href":"/scripting/how-to/plot-a-value-on-its-own-scale"},{"title":"How to plot only during part of the session","sidebarTitle":"Plot only during part of the session","href":"/scripting/how-to/plot-only-during-part-of-the-session"},{"title":"How to put a marker on a specific bar","sidebarTitle":"Put a marker on a specific bar","href":"/scripting/how-to/put-a-marker-on-a-specific-bar"},{"title":"How to reference a value from a previous bar","sidebarTitle":"Reference a value from a previous bar","href":"/scripting/how-to/reference-a-value-from-a-previous-bar"},{"title":"How to return more than one value from a function","sidebarTitle":"Return more than one value from a function","href":"/scripting/how-to/return-more-than-one-value-from-a-function"},{"title":"How to reuse a calculation with your own function","sidebarTitle":"Reuse a calculation with your own function","href":"/scripting/how-to/reuse-a-calculation-with-your-own-function"},{"title":"How to send a webhook when your condition fires","sidebarTitle":"Send a webhook when your condition fires","href":"/scripting/how-to/send-a-webhook-when-your-condition-fires"},{"title":"How to shade the area between two plots","sidebarTitle":"Shade the area between two plots","href":"/scripting/how-to/shade-the-area-between-two-plots"},{"title":"How to tell a forming bar from one that has closed","sidebarTitle":"Tell a forming bar from one that has closed","href":"/scripting/how-to/tell-a-forming-bar-from-one-that-has-closed"},{"title":"How to work around a name Lipi does not have","sidebarTitle":"Work around a name Lipi does not have","href":"/scripting/how-to/work-around-a-name-lipi-does-not-have"},{"title":"How to keep one label that moves with the last bar","sidebarTitle":"Keep one label that moves with the last bar","href":"/scripting/how-to/keep-one-label-that-moves"},{"title":"How to show a table of values","sidebarTitle":"Show a table of values","href":"/scripting/how-to/show-a-table-of-values"},{"title":"How to group values in your own type","sidebarTitle":"Group values in your own type","href":"/scripting/how-to/group-values-in-your-own-type"},{"title":"How to keep drawings under the limit","sidebarTitle":"Keep drawings under the limit","href":"/scripting/how-to/keep-drawings-under-the-limit"},{"title":"How to format a time as text","sidebarTitle":"Format a time as text","href":"/scripting/how-to/format-a-time-as-text"}]},{"group":"How scripts are evaluated","pages":[{"title":"Bar-by-bar evaluation","href":"/scripting/evaluation/bar-by-bar"},{"title":"Referencing previous bars","href":"/scripting/evaluation/referencing-past-bars"},{"title":"Values that persist across bars","href":"/scripting/evaluation/persistence"},{"title":"Recalculation and confirmation","href":"/scripting/evaluation/recalculation"},{"title":"Calls that must run on every bar","href":"/scripting/evaluation/call-contract"}]},{"group":"Writing Lipi","pages":[{"title":"Script anatomy","href":"/scripting/language/anatomy"},{"title":"Statements and lines","href":"/scripting/language/statements-and-lines"},{"title":"Values and types","href":"/scripting/language/values-and-types"},{"title":"const, input, simple and series","href":"/scripting/language/qualifiers"},{"title":"Operators and expressions","href":"/scripting/language/expressions"},{"title":"Branching","href":"/scripting/language/branching"},{"title":"Loops","href":"/scripting/language/repetition"},{"title":"Your own functions","href":"/scripting/language/custom-functions"},{"title":"Custom types and enums","href":"/scripting/language/custom-types"},{"title":"Arrays","href":"/scripting/language/arrays"},{"title":"Names and conventions","href":"/scripting/language/names-and-conventions"}]},{"group":"Market data a script can read","pages":[{"title":"Price and volume","href":"/scripting/market-data/price-and-volume"},{"title":"Orderflow: buying, selling and delta","href":"/scripting/market-data/orderflow"},{"title":"Open interest","href":"/scripting/market-data/open-interest"},{"title":"Sessions and intervals","href":"/scripting/market-data/sessions-and-intervals"},{"title":"Instrument properties","href":"/scripting/market-data/instrument"},{"title":"Data availability by market","href":"/scripting/market-data/availability"}]},{"group":"Putting results on the chart","pages":[{"title":"Plotting","href":"/scripting/chart-output/plotting"},{"title":"Color and transparency","href":"/scripting/chart-output/color"},{"title":"Fills and levels","href":"/scripting/chart-output/fills-and-levels"},{"title":"Bar coloring and background","href":"/scripting/chart-output/bars-and-background"},{"title":"Text and markers","href":"/scripting/chart-output/text-and-markers"},{"title":"Lines, labels, boxes and polylines","href":"/scripting/chart-output/drawings"},{"title":"Tables","href":"/scripting/chart-output/tables"},{"title":"Plots or drawings: which to use","href":"/scripting/chart-output/plots-or-drawings"}]},{"group":"Strategies","pages":[{"title":"Strategies and backtesting","description":"Declaring a strategy, the arguments that set its account, sizing and costs, and what a strategy does and does not do.","href":"/scripting/strategies/overview"},{"title":"Orders and positions","href":"/scripting/strategies/orders-and-positions"},{"title":"Reading a strategy's results","description":"The strategy variables for position, equity and profit, and the functions that read single open and closed trades.","href":"/scripting/strategies/strategy-results"}]},{"group":"Configuration","pages":[{"title":"Inputs","href":"/scripting/configuration/inputs"}]},{"group":"Alerts and automation","pages":[{"title":"Alerts","href":"/scripting/automation/alerts"},{"title":"Webhooks for algo trading","href":"/scripting/automation/webhooks"}]},{"group":"Distribution","pages":[{"title":"House style and naming","href":"/scripting/distribution/house-style"},{"title":"Limits","href":"/scripting/distribution/limits"},{"title":"Sharing scripts","href":"/scripting/distribution/sharing"}]}]},{"group":"Use Lipi with AI","pages":[{"title":"Use Lipi with AI","sidebarTitle":"Overview","href":"/scripting/ai/overview"},{"title":"The GoCharting Lipi skill","sidebarTitle":"Lipi skill","href":"/scripting/ai/skill"},{"title":"Docs for AI tools","href":"/scripting/ai/docs-for-ai-tools"}]},{"group":"Reference","pages":[{"title":"Lipi v2 reference","href":"/scripting/reference/index"},{"title":"Compiler messages","href":"/scripting/reference/errors"},{"group":"Functions","pages":[{"title":"Global functions","sidebarTitle":"Global","href":"/scripting/reference/functions/global"},{"title":"array functions","sidebarTitle":"array","href":"/scripting/reference/functions/array"},{"title":"box functions","sidebarTitle":"box","href":"/scripting/reference/functions/box"},{"title":"chartPoint functions","sidebarTitle":"chartPoint","href":"/scripting/reference/functions/chartpoint"},{"title":"color functions","sidebarTitle":"color","href":"/scripting/reference/functions/color"},{"title":"input functions","sidebarTitle":"input","href":"/scripting/reference/functions/input"},{"title":"interval functions","sidebarTitle":"interval","href":"/scripting/reference/functions/interval"},{"title":"label functions","sidebarTitle":"label","href":"/scripting/reference/functions/label"},{"title":"line functions","sidebarTitle":"line","href":"/scripting/reference/functions/line"},{"title":"linefill functions","sidebarTitle":"linefill","href":"/scripting/reference/functions/linefill"},{"title":"math functions","sidebarTitle":"math","href":"/scripting/reference/functions/math"},{"title":"orderflow functions","sidebarTitle":"orderflow","href":"/scripting/reference/functions/orderflow"},{"title":"polyline functions","sidebarTitle":"polyline","href":"/scripting/reference/functions/polyline"},{"title":"str functions","sidebarTitle":"str","href":"/scripting/reference/functions/str"},{"title":"strategy functions","sidebarTitle":"strategy","href":"/scripting/reference/functions/strategy"},{"title":"ta functions","sidebarTitle":"ta","href":"/scripting/reference/functions/ta"},{"title":"table functions","sidebarTitle":"table","href":"/scripting/reference/functions/table"},{"title":"talib functions","sidebarTitle":"talib","href":"/scripting/reference/functions/talib"}]},{"group":"Variables","pages":[{"title":"Global variables","sidebarTitle":"Global","href":"/scripting/reference/variables/global"},{"title":"barstate variables","sidebarTitle":"barstate","href":"/scripting/reference/variables/barstate"},{"title":"box variables","sidebarTitle":"box","href":"/scripting/reference/variables/box"},{"title":"chart variables","sidebarTitle":"chart","href":"/scripting/reference/variables/chart"},{"title":"interval variables","sidebarTitle":"interval","href":"/scripting/reference/variables/interval"},{"title":"label variables","sidebarTitle":"label","href":"/scripting/reference/variables/label"},{"title":"line variables","sidebarTitle":"line","href":"/scripting/reference/variables/line"},{"title":"linefill variables","sidebarTitle":"linefill","href":"/scripting/reference/variables/linefill"},{"title":"orderflow variables","sidebarTitle":"orderflow","href":"/scripting/reference/variables/orderflow"},{"title":"polyline variables","sidebarTitle":"polyline","href":"/scripting/reference/variables/polyline"},{"title":"session variables","sidebarTitle":"session","href":"/scripting/reference/variables/session"},{"title":"strategy variables","sidebarTitle":"strategy","href":"/scripting/reference/variables/strategy"},{"title":"syminfo variables","sidebarTitle":"syminfo","href":"/scripting/reference/variables/syminfo"},{"title":"table variables","sidebarTitle":"table","href":"/scripting/reference/variables/table"}]},{"group":"Constants","pages":[{"title":"Global constants","sidebarTitle":"Global","href":"/scripting/reference/constants/global"},{"title":"color constants","sidebarTitle":"color","href":"/scripting/reference/constants/color"},{"title":"dayofweek constants","sidebarTitle":"dayofweek","href":"/scripting/reference/constants/dayofweek"},{"title":"extend constants","sidebarTitle":"extend","href":"/scripting/reference/constants/extend"},{"title":"format constants","sidebarTitle":"format","href":"/scripting/reference/constants/format"},{"title":"label constants","sidebarTitle":"label","href":"/scripting/reference/constants/label"},{"title":"line constants","sidebarTitle":"line","href":"/scripting/reference/constants/line"},{"title":"math constants","sidebarTitle":"math","href":"/scripting/reference/constants/math"},{"title":"order constants","sidebarTitle":"order","href":"/scripting/reference/constants/order"},{"title":"position constants","sidebarTitle":"position","href":"/scripting/reference/constants/position"},{"title":"strategy constants","sidebarTitle":"strategy","href":"/scripting/reference/constants/strategy"},{"title":"text constants","sidebarTitle":"text","href":"/scripting/reference/constants/text"},{"title":"xloc constants","sidebarTitle":"xloc","href":"/scripting/reference/constants/xloc"},{"title":"yloc constants","sidebarTitle":"yloc","href":"/scripting/reference/constants/yloc"}]},{"title":"Lipi types","sidebarTitle":"Types","href":"/scripting/reference/types"},{"title":"Lipi keywords","sidebarTitle":"Keywords","href":"/scripting/reference/keywords"},{"title":"Lipi operators","sidebarTitle":"Operators","href":"/scripting/reference/operators"},{"title":"Lipi enums","sidebarTitle":"Enums","href":"/scripting/reference/enums"},{"group":"Language map","pages":[{"title":"Lipi language map","sidebarTitle":"Overview","href":"/scripting/reference/language-map/index"},{"title":"Execution and types across languages","sidebarTitle":"Execution and types","href":"/scripting/reference/language-map/execution-and-types"},{"title":"History and state across languages","sidebarTitle":"History and state","href":"/scripting/reference/language-map/history-and-state"},{"title":"Control flow, functions and collections across languages","sidebarTitle":"Control flow, functions and collections","href":"/scripting/reference/language-map/control-flow-and-functions"},{"title":"Inputs across languages","sidebarTitle":"Inputs","href":"/scripting/reference/language-map/inputs"},{"title":"Plots and drawings across languages","sidebarTitle":"Plots and drawings","href":"/scripting/reference/language-map/plots-and-drawings"},{"title":"Strategies and alerts across languages","sidebarTitle":"Strategies and alerts","href":"/scripting/reference/language-map/strategies-and-alerts"},{"title":"Market data and time across languages","sidebarTitle":"Market data and time","href":"/scripting/reference/language-map/market-data-and-time"},{"title":"Math and strings across languages","sidebarTitle":"Math and strings","href":"/scripting/reference/language-map/math-and-strings"},{"title":"Arrays across languages","sidebarTitle":"Arrays","href":"/scripting/reference/language-map/arrays"},{"group":"Technical indicators","pages":[{"title":"Moving averages across languages","sidebarTitle":"Moving averages","href":"/scripting/reference/language-map/indicators/moving-averages"},{"title":"Oscillators across languages","sidebarTitle":"Oscillators","href":"/scripting/reference/language-map/indicators/oscillators"},{"title":"Volatility and bands across languages","sidebarTitle":"Volatility and bands","href":"/scripting/reference/language-map/indicators/volatility-and-bands"},{"title":"Volume across languages","sidebarTitle":"Volume","href":"/scripting/reference/language-map/indicators/volume"},{"title":"Extremes, pivots and statistics across languages","sidebarTitle":"Extremes, pivots and statistics","href":"/scripting/reference/language-map/indicators/extremes-and-pivots"},{"title":"Series helpers across languages","sidebarTitle":"Series helpers","href":"/scripting/reference/language-map/indicators/series-helpers"}]},{"title":"What Lipi does not have","sidebarTitle":"Not in Lipi","href":"/scripting/reference/language-map/not-in-lipi"},{"title":"How to convert a script to Lipi","sidebarTitle":"Convert a script","href":"/scripting/reference/language-map/convert-a-script"}]}]}]}]},"basePath":"","title":"Orders and positions - GoCharting","buildId":"dpl_Acry4NrQAgjcikyFgVE2eJ7XQCAv","deploymentId":"dpl_Acry4NrQAgjcikyFgVE2eJ7XQCAv","dynamics":[],"chunks":[]}