Are there any side effects using Param in both BackTest and Explore in Analysis Tool

I would like to apply Param() in the code for exploring and backtesting. However, I found 2 articles in below mention to how to apply Param() in code.
/changing-param-in-backtest : it isn't recommended.

change param rsi-70-and-rsi-30-with-exploration Seem to allow to do that.

In fact, I want to change day in ROC for exploring as the figure shown below.

as for as I know, for Backtest ,Optimize() is better.

So please clarify which function can apply using Param().

Thank you in advance.
Pongthorn Sangkaphet

@technqvi you should re-read very carefully the first thread you linked.

In particular, please, study the "summary of pitfalls" in this answer of @fxshrat; he explains well why using "params" in the Analysis tab "may" have some side-effects.

[Changing Param in Backtest]

If you always work with a single analysis tool (opening only one window), in general, it is not an issue, since the "parameters" that your code uses are the ones currently defined in the "Parameters" setting of the Analysis tab.

On the other hand, if you have many opened windows and run multiple explorations and/or backtest, the unwanted side effects (using "Param" values defined elsewhere) are truly a possibility.

So, when you are developing something new, after you have experimented/optimized(?) enough a formula (using the flexibility of the Param functionality - being aware of its limitations), as it was suggested, it is a good idea to comment out the "Param" lines and replace them with hard-coded values and use only this final version in any daily routine/scheduled batch process.


Thank you for your recommendation.

Completely understanding.
Completely understanding.
I will occasionally use it just experiment phase carefully and I am so cautious about how many window analyses are opening at the same time, it must be a single window. and once test completely, I will instantly comment parameter line and use actual value instead.

Lastly, as I come back to read such an article again, this is the crucial message to the reason why we don't apply parameter in window analysis. (Changing Param in Backtest) @fxshrat

refer: changing-param-in-backtes

Param functions are dependent on ChartID and in analysis ChartID is always zero for all analysis windows. Since all analysis have ChartID value zero it may lead to problems (even more so for beginners or technology illiterates) as parameters are shared. If you change param in one window it will effect param of any other analysis window. So they influence each other.

Summary about the main pitfalls of Param.. functions in analysis window (for which they were not designed for):

If params of Param.. functions have same parameter name then changing one param in one analysis window will set param with same parameter name of any other analysis window to same set value
If params of Param... functions have different parameter name then changing one param in one analysis window will reset any param of any other analysis window back to default value.
Set params of Param... functions are not saved to project files.
(And of course params are reset to default value if closing and reopen an analysis window. Well, that one is expected.)

Once again all Params between more than one analysis windows interfere with each other because all analysis windows have same chart id (0). Params were designed for charts originally. It is that simple.