How to make some code to run only once at the beginning?

Questions about MultiCharts .NET and user contributed studies.
r41866
Posts: 6
Joined: 03 Mar 2023

How to make some code to run only once at the beginning?

Postby r41866 » 18 Mar 2024

I want to initiate some variables at the beginning but I found I cannot put the code in Create() or StartCalc() because if I change time frame, the code in create() or in StartCalc() don't run again but I want the variables to be initiated again if there is time frame change. Because that's for the initiation of the variables, the code needs to be run once only and doesn't need to be run at each bar. How can I do it?

Thanks.

User avatar
Polly MultiCharts
Posts: 203
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 55 times

Re: How to make some code to run only once at the beginning?

Postby Polly MultiCharts » 19 Mar 2024

Hello r41866,

You need to do that in StartCalc().
If StartCalc() doesn’t work as expected in your setup, please send us a simplified code, the workspace where the issue is reproduced and step-by-step instructions on how to reproduce the issue to our support email, so that we could check it on our end.

HellGhostEvocatorX
Posts: 80
Joined: 10 Feb 2022
Has thanked: 52 times
Been thanked: 11 times

Re: How to make some code to run only once at the beginning?

Postby HellGhostEvocatorX » 20 Mar 2024

look at chapter 4
Attachments
MultiCharts.NET-ProgrammingGuide-v1.2.pdf
(1.77 MiB) Downloaded 19 times


Return to “MultiCharts .NET”