Add more than two variables
-
I have created 15 variables which are the ranges (High minus low) of each of the last 15 candles. Now i want to get the average of the 15 ranges, that is, to add all 15 variables and divide by 15. This average value should be added to the lowest low of the last 15 candles, or minused from the highest high of the last 15 candles. And I need to draw a line for each of the average range lines (two lines, one up and one down), and use them as a support or resistance.
I only created the variables, I don't know how to preceed from there again. Someone please help!! -
@jaychyke isn't it the ATR what you are trying to calculate? Something like ATR 15?
-
@trader-philipps ATR? not necessarily. It's rather the average daily range ADR. But I want to customize it so I could use any timeframe and any number of previous candles. Hence my question. Many thanks for your reply.
-
This is what you need to calculate each median value per candle and store it on each of your variables:

This is just for candle ID 1. You need to do the same for all other candles (from Id 2 to ID 15). Then you would need a custom code block calculating the average value of all those stored numbers. Sadly, I don't know hot that custom cose should be, sorry.

-
You dont need individual variables for each candle, and that method is a bit difficult to scale anyway. First rule of coding is to never repeat yourself. (well thats what I have heard, it's not like I'm some professional coder)
Use an array! You will have to study a bit, but you really cannot avoid some work given that goal.
Google mql4 array for instructions.
https://docs.mql4.com/array -
Ok so I actually got very excited about this and figured out the whole thing:
https://fxdreema.com/shared/UeNF7iqdb
Seems to be working:

-
@l-andorrà Many thanks for your suggestion. I wish I could do custom codes
-
@roar WOW! I can't believe this. Thanks a trilion. Let me check this out
-
@roar Very good work!!! Please may I ask if the calculation is based on the last 15 candles? Again, which names will the upper and lower lines be identified with by the EA: "upper bound" as named, or upper range as coded?
-
@jaychyke said in Add more than two variables:
Please may I ask if the calculation is based on the last 15 candles?
Yes it's 15 by default, but you can change it from inputs:

Again, which names will the upper and lower lines be identified with by the EA: "upper bound" as named, or upper range as coded?
"Upper bound" is the name of that graphical object, "upper range" is the name of the numerical value the object is based on

-
@roar My platform is MT4. How do I copy your compilation as a part of my work in fxdreema, please. Let me know the steps. I'm not techophobic
-
@roar see what I've done so far, but the bot is not opening https://fxdreema.com/shared/1HWrUDuTc
-
@jaychyke Download the .mq4 and import it again to get the constants and variables done correctly.
Alternatively, just copy the blocks and set up these constants and variables manually:

