Tutorial Loop [advanced?] - find and save specific value from indicator history
-
fast tutorial how to find specific value in indicator history
my tip is, use Loop blockoriginal project: 0_1488923868468_tutorial_loop.mq4
link: https://fxdreema.com/shared/CS0MvwQSchere was question, how to find atr max/min values in specific period
https://fxdreema.com/forum/topic/4507/indicator-average-value-ichimoku
so we will find atr max and min and save it into variables for further calculation-
create few inputs:

and variables:

values are saved into variables atrMax and atrMin
variable atrNew is needed for temporary saved atr value and variable incr is needed for incrementation candle ID
input lookBack is period where are you looking for values min max and atrPeriod is period of atr
-
next create this block connections:

firstly you need null variables before loop start, atrMax is 0 but atrMin is "nulled" into high value because for further comparison
block Loop have in parameter lookBack period - it is, how many times is this loop repeated

next is save atr value from candle ID (variable incr) into variable atrNew:

block Condition for comparing if atrNew is > as atrMax:

if that is true, save atrNew into atrMax (atrMax=atrNew)

the same logic is for atrMin with slightly change in Condition:

-
after that atrMax and atrMin are saved and if loop find on lookBack period new atr which is higher/lower as previous, it is saved ... in that case dont forget for candle ID incrementation which is done with incr variable in next block:

-
with Comment check if it is working:

see, it is working:

...
the same logic you can use for moving average, RSI, stochastic, macd, custom indicator and all others
-
-
-
hi miro1360. I'm trying to follow your explanation but I cannot fine the block loop back. I can find (loop) break and (loop) next but none of these have the feld cycle. where can I find it?
thanks -
hi nemo, dont be confused with names, because I slightly renamed blocks to be more specific about their function ... the first line in block name is original name, the second and next lines are renamed by me ... so the original block name is always first line Loop (pass "n" times)
-
I found it thank you. is there a way to Know body range size or candle size?
-
yes, Modify variable block, and somewhere in Candle properties exist this option ...
-
Thanks Miro for very clear example!
Question is using blocks VS custom MQL Code block which is better manage? -
I am not sure what do you mean ....
do you mean using custom code between fxdreema blocks? you dont need do it if block exist, if is not exist you can do it or even create own block (in fxdreema studio, check forum for some replies about that) ...or do you mean whole EA in own custom code?
here not exist one answer ... because custom code can be done wrong, veery wrong, and therefore very slow ... you must be very experienced when you want create something pure in code, otherwise you will lose time (in that case it is better to learn something else as MQL programming, lets say it is better to learn javascript and web programming)... fxdreema is using sophisticated system of blocks which are called logically in order/loops ... now it is in OOP, so technically it is really fast ... someone can tell you, that there is a lot of unnecessary code, but it does not matter, because unprofitable EA will create the same loss with both
... from my experience, fxdreema is the best tool for creating EAs ... -
@miro1360 What needs to be changed in the blocks for the indicator RSI?
-
meantime some functions were added, you can do it easily ... import RSI into My Indicators and set the Modify Variables block as this:

(I have not tested) .... -
Instant of look back candle is fix at 10. Can I determine the look back candle depending on parabolic sar? Example: if parabolic previously appears below candle is 15 candle before appear on top. My look back candle is 15.
-
you can do that with a few variables, it won't be so easy as one block ... at least a few blocks ...
-
I have no idea how to start it. Please show me.
-
as I told you, is not that simple ... something like this:
https://fxdreema.com/shared/GmgFkC3sd
(RSI must be imported in My Indicators)
it can be simplified into Custom Code block, this is only demonstration how it can be done from blocks

... note, that parabolic sar is repainted indicator, the previous spot is sometimes repainted - some inaccuracy can appears ...
maybe between blocks is some logical mistake, I have not tested it deeply



-
I got it. Thank you very much.
-
@miro1360 Hello, the topic is interesting. The question is: is it possible, based on your example, to find out the maximum size of a candle for a certain period (for example, 24 hours).
Thank you in advance. -
of course it is, just replace the atr with a candle size
-
@miro1360 said in Tutorial Loop [advanced?] - find and save specific value from indicator history:
замените atr на размер свечи
Thanks for the answer, but I don’t quite understand replacing atr with the size of the candle. You can show by example: https://fxdreema.com/shared/cOV5sHiM
Thanks again. -

-
@miro1360 Thanks, yes it works.