Support Board
Date/Time: Wed, 12 Feb 2025 21:28:14 +0000
sc.MaximumPositionAllowed no longer works from sc.SetDefaults block
View Count: 684
[2020-11-14 17:47:31] |
ForgivingComputers.com - Posts: 1001 |
FYI: Setting sc.MaximumPositionAllowed from the sc.SetDefaults block used to work. On version 2092, it was OK to set this in the sc.SetDefaults block, on current versions the value reverts to 1. Now it only works outside of the SetDefaults block. Don't know if this was intentional, but some of my studies stopped working on one of the the newer versions. Can you look into this and return the functionality or explain why it should no longer work? |
[2020-11-14 18:27:54] |
Ackin - Posts: 1865 |
Can you look into this and return the functionality or explain why it should no longer work?
+1 |
[2020-11-14 20:44:45] |
Sierra Chart Engineering - Posts: 104368 |
This has been verified to be untrue. There simply is not a problem here. A thorough code review on how this works also shows there is not a possibility of a problem. This is the relevant line from the Set Defaults block where the maximum position quantity is set to a nondefault value: if (sc.SetDefaults)
{ //This must be equal to or greater than the order quantities you will be submitting orders for. sc.MaximumPositionAllowed = 4; } And this is what is received when submitting an order with a larger value: Auto-trade: Replay 10.00X: MESZ20-CME[M] 1 Min #1 | Trading Test 2 | BuyEntry | Bar start date-time: 2020-11-12 11:31:00.000 | BuyEntry signal is ignored because maximum Long Position quantity allowed has been reached or would be exceeded with new order. Max. Position allowed: 4. Resulting Position without working orders: 10. Resulting Position with all working orders except exits: 10. Resulting Position with Market working orders: 10 | 2020-11-14 15:43:36.628
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2020-11-14 20:46:03
|
[2020-11-14 22:47:02] |
ForgivingComputers.com - Posts: 1001 |
So I should not have any issues with this: #include "sierrachart.h"
SCDLLName("Custom Study DLL") SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Template Function"; sc.AutoLoop = 1; //Automatic looping is enabled. sc.MaximumPositionAllowed = 4; return; } s_SCPositionData PositionData; sc.GetTradePosition(PositionData); if (PositionData.PositionQuantity == 0) { s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 4; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; int result = sc.BuyEntry(NewOrder); } } Yet I get this with v2192: Auto-trade: Replay 60X: NQZ20-CME[M] 1 Min #1 | Template Function | BuyEntry | Bar start date-time: 2020-11-09 00:14:00.000 | BuyEntry signal is ignored because maximum Long Position quantity allowed has been reached or would be exceeded with new order. Max. Position allowed: 1. Resulting Position without working orders: 4. Resulting Position with all working orders except exits: 4. Resulting Position with Market working orders: 4 | 2020-11-14 16:40:05.883
There is no issue if the sc.MaximumPositionSize = 4; statement is after SetDefaults, or if I use v2092. |
MaxPosTest.cpp - Attached On 2020-11-14 22:46:46 UTC - Size: 566 B - 227 views Attachment Deleted. |
[2020-11-14 23:01:56] |
ForgivingComputers.com - Posts: 1001 |
I don't know if you have a return statement at the end of the sc.SetDefaults block. I did a test without it and I got your results. Am I doing it wrong or are you?
|
[2020-11-14 23:37:52] |
Sierra Chart Engineering - Posts: 104368 |
I don't know if you have a return statement at the end of the sc.SetDefaults block Yes in the actual test function there is a return statement.We will test your code above. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2020-11-15 10:41:17] |
Sierra Chart Engineering - Posts: 104368 |
There is absolutely nothing wrong with that study function. If you are getting the error the you are, then the code that is actually running, is not the code that you have posted above. This is the source of the problem. Here is a log, running the code that you gave: ActivityType DateTime Symbol OrderActionSource InternalOrderID OrderStatus ServiceOrderID OrderType Quantity BuySell Price Price2 FillPrice FilledQuantity TradeAccount OpenClose ParentInternalOrderID PositionQuantity FillExecutionServiceID HighDuringPosition LowDuringPosition Note AccountBalance ExchangeOrderID ClientOrderID
Orders 2020-11-13 14:30:25.005 [Sim]MESZ20_FUT_CME Auto-trade: Replay 10.00X: MESZ20_FUT_CME[M] 1 Min #1 | TradingTestFunction3 | BuyEntry | Bar start date-time: 2020-11-13 14:28:00.000 | Last: 3575.25 | AO=0 281444 Order Sent Market 4 Buy Sim1 Open 0.00 Orders 2020-11-13 14:30:25.006 [Sim]MESZ20_FUT_CME Simulated order accepted 281444 Open 281444 Market 4 Buy Sim1 Open 0.00 We also do not understand the basis of post #2. There is not a problem. If you have a problem, you are doing something wrong. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2020-11-15 10:43:02
|
[2020-11-15 10:53:42] |
Ackin - Posts: 1865 |
Sierra Chart Engineering) May I ask if there have been any changes in the core of this feature since version v2192 up? |
[2020-11-15 11:07:50] |
ForgivingComputers.com - Posts: 1001 |
If you are getting the error the you are, then the code that is actually running, is not the code that you have posted above.
This is really strange. Now it works. I didn't do anything different. Same code. How about for you Ackin? |
[2020-11-15 11:43:06] |
Ackin - Posts: 1865 |
I haven't tried it today, but the latest version of Sierrachart has changed more of my studies in its function, including my Autotrader, and now I'm looking for all the clues where there may be a problem.
|
[2020-11-15 23:05:43] |
Sierra Chart Engineering - Posts: 104368 |
May I ask if there have been any changes in the core of this feature since version v2192 up? No.but the latest version of Sierrachart has changed more of my studies in its function, including my Autotrader, and now I'm looking for all the clues where there may be a problem.
There are no changes other than the return types for the affected functions documented in the notes for version 2195 here:https://www.sierrachart.com/index.php?page=doc/Whats_New.php#SCVer2195 Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2020-11-15 23:49:35] |
Ackin - Posts: 1865 |
There are no changes other than the return types for the affected functions documented in the notes for version 2195 here:
Yes, I saw it when it was published, thanks ... I'll keep looking ....
|
To post a message in this thread, you need to log in with your Sierra Chart account: