GetAppInfo(aioptimizing) doesn't work?

Questions about MultiCharts and user contributed studies.
User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

GetAppInfo(aioptimizing) doesn't work?

Postby lingwuchung » 20 Jun 2021

Hi all,

I execute the following code and time one iteration of normal chart display and optimization (the optmizing variables are dummy and won't affect the strategy execution). I know that GVGetNamedXXX is slow, that's why I want to skip it during optimization. However the result is unexpected:

As is:
chart - 38s
optimization - 60s

With "GVGet 1" commented out
chart - 32s
optimization - 44s

With both "GVGet 1" and "GVGet 2" commented out
chart - 27s
optimization - 40s

QUESTION: But why isn't the iteration time of optimization remains constant (at 40s as if GVGetNamedxxx isn't called) since I don't expect the code inside the if loop to be executed at all during optimization.

Code: Select all

Inputs: level(Numeric), s(string); Var: errorCode(0), printDir(0), content(""); if GetAppInfo(aioptimizing) = 0 then begin // GVGet 1 printDir = GVGetNamedInt(Text(lwcSymbol(),"GV_PrintDir"), errorCode); // GVGet 2 if (level <= GVGetNamedDouble(Text(lwcSymbol(),"GV_PrintLevel"), errorCode) or level = 0) then begin content = Text(FormatDate("yyyy-MM-dd", DateTime), " ", FormatTime("HH:mm", DateTime), " ", s); if printDir = 1 then begin Print(File(Text("c:\temp\lwc_debug_",CurrentDate+19000000:0:0,"_",lwcSymbol(),".txt")), content); end; end; end; // aioptimizing

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby TJ » 20 Jun 2021

I have formated your code for easy reading.
You should indent the BEGIN to match the END, so that you can see which loop is operating.

What do you see?

Code: Select all

Inputs: level(Numeric), s(string); Var: errorCode(0), printDir(0), content(""); if GetAppInfo(aioptimizing) = 0 then begin {B1} // GVGet 1 printDir = GVGetNamedInt( . . . etc ); // GVGet 2 if (level <= GVGetNamedDouble( . . . etc ) then begin {B2} content = Text(FormatDate( . . . etc); if printDir = 1 then begin {B3} Print(File(Text(" . . . etc )), content); end; {E3} end; {E2} end; {E1} // aioptimizing

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby lingwuchung » 20 Jun 2021

Hi TJ,

Thanks for the reply. I see that all codes within the first begin/end, including the two "GVGetName" should not be executed during optimization (when GetAppInfo(aioptimizing) = 0).

Sorry, I don't know what you are trying to point out.
I have formated your code for easy reading.
You should indent the BEGIN to match the END, so that you can see which loop is operating.

What do you see?

Code: Select all

Inputs: level(Numeric), s(string); Var: errorCode(0), printDir(0), content(""); if GetAppInfo(aioptimizing) = 0 then begin {B1} // GVGet 1 printDir = GVGetNamedInt( . . . etc ); // GVGet 2 if (level <= GVGetNamedDouble( . . . etc ) then begin {B2} content = Text(FormatDate( . . . etc); if printDir = 1 then begin {B3} Print(File(Text(" . . . etc )), content); end; {E3} end; {E2} end; {E1} // aioptimizing

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby TJ » 21 Jun 2021

Hi TJ,

Thanks for the reply. I see that all codes within the first begin/end, including the two "GVGetName" should not be executed during optimization (when GetAppInfo(aioptimizing) = 0).

Sorry, I don't know what you are trying to point out.
Your codes says if GetAppInfo(aioptimizing) = 0 then do it . . .

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby lingwuchung » 21 Jun 2021

Correct. That's my intention. This is a print log function. I only want to do it while NOT in optimization.

Quote: "aiOptimizing — returns a value of 1 if the calling application is currently performing an optimization, and a value of 0 in all other cases."

https://www.multicharts.com/trading-sof ... GetAppInfo
Hi TJ,

Thanks for the reply. I see that all codes within the first begin/end, including the two "GVGetName" should not be executed during optimization (when GetAppInfo(aioptimizing) = 0).

Sorry, I don't know what you are trying to point out.
Your codes says if GetAppInfo(aioptimizing) = 0 then do it . . .

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby TJ » 21 Jun 2021

Correct. That's my intention. This is a print log function. I only want to do it while NOT in optimization.

Quote: "aiOptimizing — returns a value of 1 if the calling application is currently performing an optimization, and a value of 0 in all other cases."

https://www.multicharts.com/trading-sof ... GetAppInfo
OK, you better send the code to support@multicharts.com and let them give it a run.

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby lingwuchung » 23 Jun 2021

OK and thanks. At least you're telling me I am not missing something obvoius or stupid. :P

Attached images are another test:
1. original without comments out takes 3m20s to complete 216 iterations.
2. comment out everything inside "GetAppInfo(aioptimizing) = 0" only takes 2m4s - 1/3 faster!

Let me trim and mail the strategy to support. Thanks.
Correct. That's my intention. This is a print log function. I only want to do it while NOT in optimization.

Quote: "aiOptimizing — returns a value of 1 if the calling application is currently performing an optimization, and a value of 0 in all other cases."

https://www.multicharts.com/trading-sof ... GetAppInfo
OK, you better send the code to support@multicharts.com and let them give it a run.
Attachments
comment-out.jpg
(70.36 KiB) Not downloaded yet
without-comment-out.jpg
(70.34 KiB) Not downloaded yet

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: GetAppInfo(aioptimizing) doesn't work?

Postby Svetlana MultiCharts » 11 Aug 2021

Hello lingwuchung,

Please attach the following files so that we would be able to investigate it:
1. The workspace where the issue is reproduced.
2. The exported scripts with all dependent functions that are used on the workspace.


Return to “MultiCharts”