How to get the Average Value of the Indicator for nBars
-
Hi guys, I need help to get the Average Value of the Indicator (e.g ATR) for nBars.
Example:
I need to get the Average Value of ATR for 20 Candles.You can suggest how to do it using Custom Code or Blocks.
Thanks
-
This should do it: https://fxdreema.com/shared/HRxqOvjzc
-
@jstap thanks so much bro!!
-
@jstap hello bro, I just wanna ask about something on this code because i don't quite get it.on the For Loop, you put index on the end of iATR but on mt5 documentation it doesnt need candle index parameters but it works. Can you please enlighten me how this works? I don't get it from just the documentations
-
it sets the atr variable to 0, then loops through and add us the value from the last number or candles in the candle range, then it takes this total number, and divides it by the number or candles in the range giving you the average number over the range.
-
@jstap thank you sir! another question sir, what if my Range is based on time?? how do I get my average ATR for that range???
-
-
@jstap Just curious. Shouldn't the 'Comment' block be connected BELOW the custom code in order to see the updated value of the variable every tick? Your current setting is showing the value of the previous tick instead.
-
Comment blocks can be above or below, in fact any block works above or below, you just need to ensure what is above won't affect the block below. If a comment is below a no trade block, it won't work once a trade is placed, but above it will, it will work before the trade is open, and while it's open. Possibly it's 1 tick behind, but this is unnoticeable.
-
Ok. Thanks.