Check last 100 bars
-
Although I could create 100 condition blocks to check if every one of the last 100 bars were greater, I feel there must be a better way. I've tried using the method here: http://fxdreema.com/shared/h4P3JghMb. What I've tried to do is create a feed-back loop which I thought might work, but doesn't seem to.
I'm sure there must be a way to do this, but I can't figure it out! Help!
Grateful thanks, as always.
-
What about "Indicator moves within limits" block?

-
Ah! That's it! Thank you so much, once again!
-
Actually, no. Sorry. I don't think that's going to work. I don't know what range my indicator will be in during the 100 bar period. All I know is that in that time the particular buffer must not close on 0, so it could close less than or greater than 0, but not 0.
Thus:
*
bar 6 -1.5
bar 5 -1
bar 4 -0.5
bar 3 -0.2
bar 2 0.3
bar 1 1.03
etc...[/list:u:zyeluhrg]I'm working on whole bars, so the Candle ID will be 1 or greater.
Thanks again.

-
mmmm what?
-
Yes, sorry. I'm not explaining myself well! I'll try again.

I'm trying to do something like this: http://fxdreema.com/shared/OdnOMKJuc
Therefore; "over the last 100 bars, indicator != 0".
Is there a way of checking for this condition without creating 100 separate condition blocks? At bar close, the indicator value range in this time period of 100 blocks can range from positive to negative, or the other way, but at close never be 0.
Sorry for the confusion!
-
No, don't create 100 blocks only for this. As a code this is something relatively simple, and there is a block "Free loop..." that makes the next blocks to execute N times.... but it's not a good idea to try it because there is no way to break the cycle when needed (and if you check all 100 candles on every tick, even if the first one failed, this will eat the speed of the EA). But this block "Indicator moves within limits"... what if you put 2 of it, one for the positive side (indicator is above 0, lower level 0) and one for the negative side (indicator is below 0, higher level 0). I didn't tried it, but it sounds fine. Otherwise I can make a block to do exactly what you want... but a little bit later, because now I have something to do

-
I don't think that will work. Each of the two "Indicator moves within limits" blocks will check for "100 bars > 0" or "100 bars < 0" respectively. But if the range of values in the 100 bar cycle moves from negative to positive (but is never 0), then the signal will be missed.
So, a 6 bar example:
bar 6 = -1.5
bar 5 = -1
bar 4 = -0.5
bar 3 = -0.2
bar 2 = +0.3
bar 1 = +1.03
[/list:u:dtspltyy]The range in the above example moves from negative (bar 6) to positive (bar 1), but never equals 0. 4 of the bars are negative, and 2 positive, but none are 0. The number of negative and positive bars would vary from signal to signal, but no bar would be 0.
Therefore what I'm trying to find is; "over the last 100 bars, indicator != 0".
Or have I misunderstood the "Indicator moves within limits" block?!

-
I can see that you are using MACD now, and this indicator has values very very close to 0. But I don't understand what you want to detect actually. At least I can't see how for 500 candles MACD can be above 0 or below 0 only, this indicator goes in the other direction every few candles. The other thing is that this indicator is an oscillator, so the exact value 0 does not mean something very special to it. If there is an indicator that can have values -1, 0 or 1 it is a different story. But I don't understand why you want to check if MACD had a value 0 (exact 0) in it's last 500 candles, what is that mean? And is it possible for MACD to have value 0 actually, I think (not sure) that this indicator is either positive or negative, so it's probably never 0 by nature and to check if in the last 500 candles it is !=0 will probably give you always the answer Yes. So... do you want to detect MACD crossover with 0 or something else?
-
In this screenshot, you'll see two oscillators:

I've zoomed out to show a fairly short run of bars.
Looking at the long run of blue bars in the upper oscillator, I'd like to capture the "over the last n bars, indicator buffer 1 != 0" condition. If the bars are blue, then buffer 1 != 0, even if its value moves from negative to positive. Had there been a red bar in that time, the condition would have failed since buffer 1 would have become 0, and buffer 0 would have held a non-zero figure. The values held in buffers 0 and 1 is the MACD figure. I originally included the MACD to try to explain, but didn't do a good job - sorry! The blue and red bars basically are a bearish/bullish indicator. If bullish, then buffer 1 is filled with the non-zero MACD value, and a blue bar is painted. If bearish, then buffer 1 = 0, and buffer 0 = a non-zero MACD value.
And yes, I don't think the MACD value (bar ID 1 or more) is ever 0 - or at least I've never found it so!
Hope this helps! Sorry for not being clearer in my explanations.
......
Clipboard02.jpg -
Now this explains things. Notice "Indicator is visible" block. What this block does now is to check if the indicator is different than 0 and different than EMPTY_VALUE (in the present moment only). I can add something like "For how many candles" option in it, does this count?
-
Yes. I think that might do it!
Thank you so much, as always! 
-
It's ready to be tested.
-
That's great! I'll test it over the next day or so.
The service you provide to us, your users, is excellent! Well done, and thank you.

-
Have had a look a this now. It seems to work on the "indicators (built in)", but not on "indicators (my indicators)". See http://fxdreema.com/shared/9DEU4BIG. Values don't seem to be picked up from the buffers.
Either that or I've done something wrong... again! 
-
Actually you can test indicator's buffers with "Levels tester" block directly and realtime. So, are you sure that this indicator actually returns something to it's buffers?
-
Yes, it does. I've tested it in 044.
-
I found the problem, fixed.
-
OK. That's great. It seems to be working as expected. Thank you.
Now, another little challenge!


In the above screenshot you'll see that this bullish run also contains some bearish bars. Would it be possible to introduce a "fuzziness" factor whereby n number of bearish bars are ignored if the overall movement of the whole bar range is bullish by x amount? Or something similar to this? And the reverse, of course, for a bearish run?......
Clipboard03.jpg