Am I asking the default param to be default 12 or what ? why I get 16 ?
Am I asking the default param to be default 12 or what ? why I get 16 ?
@leob I tested it in a recent version of AmiBroker (both 32 and 64 bits), and the program works as expected:
Try to do the above. Check the value immediately after setting it (like I did in line 2):
If you still see this anomaly, please post all your code. (Report also the version you are using; I tested the snippet with 6.10.0 32-bit and 6.28.0 64-bit).
Maybe you are changing the value elsewhere, or some other part of your formula is the cause of what you are seeing.
Param line is missing the STEP increment . That may help.
shortslopePeriods = Param("short slope periods",12,6,50,1);
@Anthony, your observation is another hint for @leob to investigate.
I noted it too, and on purpose, I did my test without it (I saw no difference using it). Maybe in different versions of AmiBroker this could be relevant.
Looking at the Param() documentation - while the "step" DOES NOT seem to be an optional parameter - in the "Example" section there are two lines where the Param() function is invoked without it (in such cases the actual step is 1).
So I think this is only a minor discrepancy on the online/help documentation and that the step is actually optional and when omitted it defaults to 1. (If wrong, please, correct me).
@beppe I can only guess, because unfortunatelly @leob hasn't provided many details, but I think his problem is that after changing the default
Param() value - (in his case from 16 to 12), it was not updated in the debugger even after clicking "Reset all" in the Parameters window or re-Applying the code or even after restarting AmiBroker... It is probably due to the fact that: (a quote from: https://www.amibroker.com/guide/afl/param.html )
Param() functions cannot be used conditionally and their default parameters have to be CONSTANT. This is because these values are cached and are not re-read during subsequent formula evaluations.
My test Params weren't updated in the debugger either.
Nothing vodo here. Original poster just changed the Parameter value in the Analysis window and he is getting value set in Parameters. Or he is changing parameters elsewhere (like in Charts). Chart parameters are NOT used by the debugger.
It is important to understand that AFL editor and debugger run in ANALYSIS (Backtest) context and read parameters set in the Analysis window. Default value is initial value, ONLY used when formula is first applied. If it is changed in Parameters window, any subsequent edits of 'default' don't change the value UNLESS you press "Reset all" in the Parameters window.
BTW: Step parameter is optional and has nothing to do with that.
BTW2: As I wrote hundreds of times Param() must NEVER be called conditionally. NEVER. EVER.
Tomasz, maybe I'm missing something (I wouldn't be surprised) but in my case when I change the default value of some Param() in the AFL Editor, lets say from 1 to 2, the debugger is still showing 1 even after clicking "Reset all" in the Parameters window or re-Applying the code or restarting AmiBroker... My params are not used conditionaly. What should I do to update this value in the debugger?
AFTER changing the default you need to press "Reset All" button in the Analysis / Parameters window if you want default to be used AGAIN, i.e. param value re-initialized using the (new) default. Default is just INITIAL value used to initialize parameter value when it does not exist.
The video below shows that if you do NOT press "Reset all" it will use OLD value. But if you subsequently press "Reset all" it will use NEW value on next execution of course.
Thank you for trying help here.
I attached new screen shut.
The original poster, which is me, didn't change anything, the original poster just want to get the default value.
this screen shut take after reset all system.
really confused here.
static assignment "shortSlopPeriods = 12;" work ok.
But, I will not give up...
Careful reading is needed. Each word is important.
I wrote ANALYSIS window. You are using chart.
You should use Parameter in the ANALYSIS window.
You are using chart instead. Chart Parameters are INDEPENDENT from each other and from the editor and AFL editor does NOT use them.
It is not assumption. It is fact.
Your screenshot clearly shows that you are using Parameter window from CHART, not Analysis. How do I know? Simply because ONLY CHART has "Axes & Grid" tab.
this assumption is wrong.
The original poster didn't do that.
( the original poster is a programmer for more then 25 years.. )
first section of the "50" work fine.
second section of the "12" - not as expected.
from where this garbage "16" came from?
also I will add
Analysis -> Formula editor
Paste the script
@Loeb, to better understand the matter (useful for me since I too use a lot the degugger) I followed the @Tomasz answer directions and changed the parameter in the Analysis to 16.
Tested in the debugger and got 16.
Closed AmiBroker. Restarted.
Tested again in the debugger and got 16 (so the last used value used is stored somewhere).
Opened the Analysis tag.
Reset All the parameters from there (to 12) and then it worked (got 12 in the debugger).
Just to be sure, did you actually checked the value displayed in the Analysis parameter window after restarting AmiBroker?
(I mean this "sliders" icon )
For what it is worth @beppe - parameter values are not stored "somewhere" but simply in parameter store (broker.params file) so obviously their values are kept between AmiBroker executions. That is purpose of parameters (to keep their values).
As I explained in this thread already, parameters are stored per-chart ID. Each chart has its own chart ID, so each chart has separate params1. But chart params are NOT used by debugger.
Debugger uses parameters from Analysis window only (they have special chartID == 0). And you need to use Analysis window to modify/reset parameters seen under the debugger.
1 They are separate, unless you specifically create charts with same chart ID
Thank you beppe.
your screen shut help to get the misaligned between the run & test environment
and please don't get me wrong Mr. Tomasz,
I LOVE AMIBROKER!!!!
the flexibility and the performance of AMiBroker package it's unbeatable.
side effect with flexibility is some times misuse of the features.
Thank you AMiBroker and thanks to this great community.
@Tomasz thank you for the animated example and explanations!
As I wrote: I wouldn't be surprised if I missed something and that is the case. I was also using chart window's Params, I forgot about the Analysis(Backtest) context in which the debugger runs. Summing up - in this context I failed miserably
@Milosz my opinion is quite opposite. You are absolutely one of greatest contributors on this forum. And your participation is highly appreciated.
@Tomasz, because you can't have Param() inside If statements, is it then not possible to have separate Parameter Windows with different parameters? So one Parameter Window relative for chart and one Parameter Window relative for AA?
Parameters are related to formula. One formula should have one set of parameters.
If you want two different sets of parameters use two different formulas.