Login Page - Create Account

Support Board


Date/Time: Wed, 04 Dec 2024 18:56:33 +0000



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

View Count: 142

[2024-12-01 03:17:45]
User61168 - Posts: 413
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: 550
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 - 13 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: 413
Wow! Thanks User431178 for your generosity in sharing. I really appreciate it.
[2024-12-01 21:33:04]
User61168 - Posts: 413
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: 550
You can delete the "i64" part from the initialisation of formulaResult.
[2024-12-01 23:53:35]
User61168 - Posts: 413
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: 550

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 - 6 views
[2024-12-04 09:10:00]
User61168 - Posts: 413
Fantastic User431178. You have been such a great help. The revised code compiles without any issues and works great! I wish every study in SC came with a enable/disable and update mode of always/onOpen/onClose option.

I don't want to abuse your generosity so feel free to decline this request. I have accomplished almost everything I need via simple alerts except for these two:
1) ways to programmatically auto-connect and auto-disconnect the data feed (either at the individual chart level or chart book level or for entire platform) based on a value in spreadsheet formula study. Could this be done in ASCIL?
2) is there a way in ASCIL to programmatically "Force" a chart's graph draw type to be always Blank (or any option in the dropdown list under Chart Settings>Bar Period>Graph Draw Type). When running my autotrading algo, I prefer to forcefully hide all the bars and free my mind from over-thinking and let the algo run without my interference. Hope there is a way to do this.

Thanks again for your help.
[2024-12-04 10:37:05]
User431178 - Posts: 550
1) Only for the entire platform, as far as I am aware.
2) Yes it is possible.

See attached for solutions.

Either Connect or Disconnect based on formula result, the action is performed when formula result is non-zero.
You would need two copies of the study, one for each action.
I did not see a way to expose the live system date/time to spreadsheet/alert formula so made a study for this purpose.
attachmentSpreadsheetFormulaPositionSize.cpp - Attached On 2024-12-04 10:37:00 UTC - Size: 7.54 KB - 1 views

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

Login

Login Page - Create Account