How to reset the constant name space?

Questions about MultiCharts and user contributed studies.
biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

How to reset the constant name space?

Postby biffhero » 21 Nov 2020

I have one signal that I am writing which has inputs. I am using it to supply Global Variables to other scripts. This helps a lot with keeping my programs separate from one another. This is a very nice feature in MultiCharts, thank you for implementing it, I'm sure it wasn't easy or cheap.

However, now I have a problem with this one "global variable provider signal".

I often go through and modify the defaults, re-compiling and testing.

For example, a some of them are minPrice, maxPrice, startDate, stopDate.

They are declared in my signal as Inputs, so they are constants.

When I modify the defaults on these constants, the script never gets it. I have verified this with "print debugging".

I have been considering what might be causing this, and I have decided that when the PowerLanguage Editor calls gcc, and gets a .o file, it signals the data loading side of the main strategy system to load it up. However, that doesn't overwrite the constant namespace in the main memory. It is like the data space and the logic space are not both loaded up each time.

If I change the logic in my script, the changes to the constants do not get reloaded.

If I disable and re-enable the signal, via the checkbox, this does not reset the constant namespace. I don't like this option anyway, since it would require that I go and click a whole bunch on many workspaces.

I tried by making the script invalid, putting a bad statement, so that it threw an error on compile. Then I remove the bad statement and recompile to have a proper script. This did not reset the constant namespace.

If I use a variable and not a constant, then it changes on each recompile. Of course, then I lose the ability to change the item from the clicky-clicky user interface, and I have to figure out another way to have my users "use" the signal. I think the Inputs are really great, by the way.

If I have one constant and one variable, and enable / disable one for the other, then I get the desired result. This requires two compiles, and two waiting for the Strategy Performance Report to re-run.

If I have one constant, and change the type, then I get the desired result. For instance, as constants, if I cycle from 'maxPrice(24)' to any of 'maxPrice("")' or 'maxPrice(true)' and then back to 'maxPrice(22)', then I get the new value of maxPrice. However, this causes the script to not compile, if I'm using that variable in any logic. This also requires two compiles, and two waiting for the Strategy Performance Report to re-run.

My question is this.

What is the MultiCharts recommended way meet the following requirements:

1. Use Inputs, so my users are able to use. I'm really worried about giving them access to the code.
2. Require one recompile, so my developers and QA people can work more efficiently. I suspect Selenium might be called for here, sigh. It is clear that the namespace isn't being cleared out on every recompile. In the linux world, I'd look to send a sigHUP, or some other defined signal, but I suspect that isn't a "thing" in the Windows world.

Thank you,
Rob

biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Re: How to reset the constant name space?

Postby biffhero » 23 Nov 2020

I have figured out a method that has worked 3 times in a row. To begin with, I set up the items which I want to use in their own block.

I then set up the following two lines above them:

//variables:
inputs:

Then, as I want to change any of the test variables, I "move" the items from being variables to inputs by modifying them and by removing the comment.

However, it isn't as simple as going one way or back. I must go both ways. So here are the steps.

1. change variable
2. enable variables
3. disable inputs
4. recompile
-- at this point, the Performance Report is inaccurate
5. disable variables
6. enable inputs
7. recompile
-- at this point, the Performance Report is accurate

So it is painful, but at least I have found some steps which (seem to) work.


Return to “MultiCharts”