Change chart parameters and see result in AFL code?

I'm an Amibroker noob; apologies for that in advance. I linked to my IB account and backfilled 180 days of 1 minute bars. So far so good. Then I right-clicked the chart, selected Parameters, and replaced the default values for MA and Long MA, and clicked 'Ok'. Then I right-clicked the chart again and selected 'Edit Formula'. I was expecting to see my changes in the associated AFL code; however, I see the old/original numbers , not the new numbers I entered in the chart parameters fields. The AFL file associated with the chart is price.afl and appears to be the default because I did not create that file manually. I did quite a bit of searching for answers and can't seem to find one. Or... maybe I'm just blinded by noobness.

UI Parameter settings do not modify AFL code.
It is the other way around... AFL Param* code lines define values of Parameter UI window (e.g. default, min, max, step of Param() -> see picture below). The value you have set in Parameter window is part of min/max range of your Param code line.
If you want to set e.g. new default value for Param() (2nd argument of that function) then you have to edit Param* AFL code line. And after being finished click Apply button of formula editor to update and save. Same applies for other Param* modifications.

14


Also see this one for resetting (single) Param*.

So... to make sure I understand... it appears that the chart GUI interface provides the ability to change chart attributes in real time and see those changes are reflected in the chart. So I could play with moving average numbers until I found crossovers that look good to me. Then, if I want to make the change permanent I would use the Formula Editor to enter the moving average numbers in the AFL code. Does that sound about right?

For backtesting... is it true that backtesting uses the AFL code and thus changes to the Parameter fields in the GUI would have no impact on backtesting?

Theirs a parameter function in the analysis window(where backtest are performed) .

The value you set in Parameter window is permanent in the chart layout already (and saved for layout if layout saving is enabled in Tools - Preferences - Miscellaneous - Autosave).
So you do not need to modify formula all the time.
But if you want to save some "magic" value as new default value to formula then do so as written in 2nd post.

Yes.

No, they do have impact on backtesting (if further used in signal code).
The value you set in Parameter window is assigned to variable of code.
But again parameter window does not modify code itself.
Param* functions just return the current value you have set in Parameter window.

1 Like

Thanks! Very helpful :slight_smile:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.