Login Page - Create Account

Support Board


Date/Time: Wed, 04 Dec 2024 08:47:55 +0000



[Programming Help] - Programming help with setting the Trade Window Order Quantity in ASCIL

View Count: 109

[2024-12-01 03:17:45]
User61168 - Posts: 411
I just learnt about sc.TradeWindowOrderQuantity here >>> Position Sizing | Post: 159825

The most basic functionality for this would be to set the Trade Window Order Quantity and ACSIL does support that:
ACSIL - Variables and Arrays: sc.TradeWindowOrderQuantity

Could someone please create a custom ASCIL study which sets the trade window order quantity using a custom spreadsheet formula study? I already have money mgmt logic built using spreadsheet formula studies. I would appreciate it.
[2024-12-01 11:15:47]
User431178 - Posts: 549
Attached.
Zip file has source and compiled study.

Study sets sc.TradeWindowOrderQuantity based on formula result.
Calculated position size is output to subgraph.
Min/Max position size constraints (set in the study) are output to subgraph.

Example chart used for testing attached, see also image.
attachmentSpreadsheetFormulaPositionSize.Cht - Attached On 2024-12-01 11:10:13 UTC - Size: 4.09 KB - 5 views
imageSpreadsheetFormulaPositionSize.png / V - Attached On 2024-12-01 11:10:19 UTC - Size: 59.81 KB - 12 views
attachmentSpreadsheetFormulaPositionSize.zip - Attached On 2024-12-01 11:10:31 UTC - Size: 56.48 KB - 5 views
[2024-12-01 21:25:31]
User61168 - Posts: 411
Wow! Thanks User431178 for your generosity in sharing. I really appreciate it.
[2024-12-01 21:33:04]
User61168 - Posts: 411
I just tried to do remote build the source coed and it throws an error.

The build failed.
In function 'void scsf_SpreadsheetFormulaModified(SCStudyInterfaceRef)':
error: unable to find numeric literal operator 'operator""i64'
97 | auto formulaResult{ 0i64 };
| ^~~~
-- End of Build -- 16:26:17
[2024-12-01 22:04:58]
User431178 - Posts: 549
You can delete the "i64" part from the initialisation of formulaResult.
[2024-12-01 23:53:35]
User61168 - Posts: 411
Thanks. I tried

auto formulaResult {}; and it would error so tried

int formulaResult; which compiled fine and the study works great.

I just have to copy/paste the position sizing formula from my other spreadsheet formula study into your study... it works like magic.

if it is not too much hassle, could I request adding a "Update on bar open" (i.e. same as calculate once per bar at open) input criteria to spare load on CPU with updating on every tick.
[2024-12-02 09:52:34]
User431178 - Posts: 549

auto formulaResult {}; and it would error so tried

Yes, type deduction can't work if there is no type to deduce from.
Drop the i64 suffix, but keep the 0 (or replace i64 with ll).
Or do as you did and don't use type deduction.


auto formulaResult {0};


Updated code attached, you can now choose "always", "on close" or "on open".
Date Time Of Last Edit: 2024-12-02 09:52:58
attachmentSpreadsheetFormulaPositionSize.cpp - Attached On 2024-12-02 09:51:55 UTC - Size: 3.87 KB - 4 views

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account