What does the below code does in AFL

What does the below code does in AFL

dist = 1.1 * ATR( 15 );

@Siddhesh, as a first step, you should always look at the function documentation:

ATR() - Average True Range

Then, if you are not familiar with a certain technical indicator I suggest to search for it on Google.

Technical Indicators and Overlays » Average True Range (ATR)

For this kind of stuff, StockCharts ChartSchool, IMHO, is a very good reference.

1 Like

@beppe,
He probably is asking what that line of afl code is doing in the context of plottext.

@Siddhesh,
It helps you to dictate the distance at which the TEXT to be plotted on the chart by referencing the ATR distance at the relevant bar.

1 Like

I beg to differ here a little bit.

The variable of the single code line posted by OP is without any context.
All it (the code line alone) says there in post #1 is assign all of the right side of the equal sign to the left side of the equal sign. Here in AFL the equal sign ("=") is an assignment operator. Next, one could add that the right side of the equal sign is array of ATR with a set look-back period of 15 bars multiplied by some numeric value "1.1". Variable "dist" itself is type array also.

Anything else as to what is variable "dist" used for is guessing work as long as OP does not add further question(s) or code showing how dist is further implemented in the code he is using. We simply do not know where he is using "dist" as he is not showing it.

He just said

Short answer to upper text:

The code line stores something to a variable with name "dist" and variable "dist" being an array variable. Variable "dist" returns the result of "1.1 * ATR(15)" applied on entire array at once. That is basically all it does.

5 Likes

@fxshrat,
Yes now i feel bad (after reading your post above) that atleast i should have waited for the OP's further input instead of guessing.
Sorry.
Sorry @beppe, i was over enthusiastic.

@NowToLook no need to apologize. My answer too was a bit rushed: I supposed that the OP question was simply about the result of ATR(15).

@fxshrat is right: without any context, his formal answer (decomposing and analyzing the individual statement elements) is the most appropriate!

1 Like

@fxshrat is correct, the OP may have just been asking what the '=' operator accomplishes...

Now I see how some of my earlier noob questions may have been irritating to senior forum members. :monkey_face:

1 Like