Does ATR indicator include the current bar

Does ATR indicator include the current bar

Manage alerts

Loading saved threads...

Woody1193 · External communityPost link
External question — Stack Overflow Stack Exchange Author: Woody1193 Original post: https://stackoverflow.com/questions/74597058 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I understand from the MQL4 documentation on the ATR indicator , that it can return the the value of the indicator for the current bar if 0 is used for the shift argument. However, when looking at the MQL5 documentation for the indicator, I notice that there doesn't appear to be any way to determine this. Possibly, this is because the indicator is intended to be used in conjunction with CopyBuffer like so: // Note that error handling has been omitted in this code double values[]; int handle = iATR(Symbol(), PERIOD_D1, 10); CopyBuffer(handle, 0, 0, 1, values); In this example, I'm retrieving the daily ATR for a period of 10 days and copying the first value of this buffer into an array. So, is values[0] the ATR value for the current day, or the ATR value for the previous day?
Quote
Report
Woody1193 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Woody1193 Original post: https://stackoverflow.com/a/74635435 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. According to @PaulB, index 0 always represents the current bar. Ergo, this code: double values[]; int handle = iATR(Symbol(), PERIOD_D1, 10); CopyBuffer(handle, 0, 0, 1, values); was retrieving the Daily ATR for the current day, which includes the current bar. In order to fix this, I simply had to change the shift from 0 to 1, like so: double values[]; int handle = iATR(Symbol(), PERIOD_D1, 10); CopyBuffer(handle, 0, 1, 1, values); which retrieves the daily ATR for the previous day.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Woody1193 Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/74597058 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I understand from the MQL4 documentation on the ATR indicator , that it can return the the value of the indicator for the current bar if 0 is used for the shift argument. However, when looking at the MQL5 documentation for the indicator, I notice that there doesn't appear to be any way to determine this. Possibly, this is because the indicator is intended to be used in conjunction with CopyBuffer like so: // Note that error handling has been omitted in this code double values[]; int handle = iATR(Symbol(), PERIOD_D1, 10); CopyBuffer(handle, 0, 0, 1, values); In this example, I'm retrieving the daily ATR for a period of 10 days and copying the first value of this buffer into an array. So, is values[0] the ATR value for the current day, or the ATR value for the previous day?

Cancel quote

Checking account access…