Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1540
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
If the average volatility is given by the ATR indicator, is there any way to represent or modernise ATR so that the period is arbitrary? After all, MT5 does not have periods shorter than a minute.
Make a tick ATR
Make a tick ATR
Thank you. But I want to see periods of time, not ticks.
And do I understand correctly that iATR(Symbol, Period, 0) gives the volatility of the current candle, i.e. the current volatility?
Thank you. But I would like to see periods of time, not ticks.
And do I understand correctly that iATR(Symbol, Period, 0) gives the volatility of the current candle, i.e. the current volatility?
1. From ticks you can make any periods of time.
2. Open the ATR code and look at its calculation.
After all, everything is within the reach of an outstretched hand.
What formula is used to calculate SYMBOL_PRICE_VOLATILITY?
If this doesn't help you either, then I don't know how else to help you (I found it on the MQL5 website):
Regards, Vladimir.
1. from ticks you can make any time periods.
2. open the ATR code and look at its calculation.
It's all within the reach of an outstretched hand.
Here I can find how ATR is calculated: https://www.mql5.com/ru/articles/10748.
There's an algorithm:
"First we need to calculate the true range, which will be the largest value of the following:
It turns out that to calculate the indicator we need data on the highs, lows and closing prices. After that, the average true range itself is calculated."
It does not say how the indicator behaves if the number of periods is equal to zero. Is it written somewhere else? Show it, if possible.
More. There is a line in the ATR code: "CopyBuffer(ATRDef,0,0,3,PriceArray)". Taken from the same place: https://www.mql5.com/ru/articles/10748. Can I ask why only 3 items are copied? How to determine the size of the indicator buffer and copy not three, but all elements? Or is it not necessary?
Here's how ATR is calculated: https://www.mql5.com/ru/articles/10748
There's an algorithm:
"First we need to calculate the true range, which will be the largest value of the following:
It turns out that to calculate the indicator you need data about the highs, lows and closing prices. After that, the average true range itself is calculated."
It does not say how the indicator behaves if the number of periods is equal to zero. Is it written somewhere else? Show me, if possible.
More. There is a line in the ATR code: "CopyBuffer(ATRDef,0,0,3,PriceArray)". Taken from the same place: https://www.mql5.com/ru/articles/10748. Can I ask why only 3 items are copied? How to determine the size of the indicator buffer and copy not three, but all elements? Or is it not necessary?
Open the editor.
Open the file at the path \MQL5\Indicators\Examples\ATR.mq5. There are examples for all indicators there. And it has been like this since the time of creation...
Study:
Here's how ATR is calculated: https://www.mql5.com/ru/articles/10748
There's an algorithm:
"First we need to calculate the true range, which will be the largest value of the following:
It turns out that to calculate the indicator you need data about the highs, lows and closing prices. After that, the average true range itself is calculated."
It does not say how the indicator behaves if the number of periods is equal to zero. Is it written somewhere else? Show me, if possible.
More. There is a line in the ATR code: "CopyBuffer(ATRDef,0,0,3,PriceArray)". Taken from the same place: https://www.mql5.com/ru/articles/10748. Can I ask why only 3 items are copied? How to determine the size of the indicator buffer and copy not three, but all elements? Or is it not necessary?
That's it! Don't suffer. Here is the code to get the ATR indicator values:
Further, be kind enough to do it yourself.
Regards, Vladimir.
That's it! Don't bother. Here is the code to get the ATR indicator values:
You'll have to do it yourself.
Regards, Vladimir
It is not correct.
You check the handle in OnInit() and exit the handler if the handle is not valid (and it is null at best. In the worst case - there is rubbish there, because Handle_ATR is not initialised). You create an indicator with assigning a valid value to the handle only in OnTick() - what's the point? In OnInit() create an indicator and get its handle. In OnTick(), use the handle to get indicator data.
Wrong.
You check the handle in OnInit() and exit the handler if the handle is not valid (and it is null at best. In the worst case - there is rubbish there, because Handle_ATR is not initialised). You create an indicator with assigning a valid value to the handle only in OnTick() - what's the point? In OnInit() create an indicator and get its handle. In OnTick(), use the handle to get indicator data.
Thank you, Artem. I'm not fully awake yet. )) I'll fix it now.
Regards, Vladimir.
P.S. Fixed the code.double atr_value=NormalizeDouble(atr_array_value[0], 5); // normalise ATR indicator values