fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Check last 100 bars

    Questions & Answers
    2
    35
    13038
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      james last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        What about "Indicator moves within limits" block? 🙂

        1 Reply Last reply Reply Quote 0
        • J
          james last edited by

          Ah! That's it! Thank you so much, once again!

          1 Reply Last reply Reply Quote 0
          • J
            james last edited by

            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. 🙂

            1 Reply Last reply Reply Quote 0
            • fxDreema
              fxDreema last edited by

              mmmm what?

              1 Reply Last reply Reply Quote 0
              • J
                james last edited by

                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!

                1 Reply Last reply Reply Quote 0
                • fxDreema
                  fxDreema last edited by

                  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 🙂

                  1 Reply Last reply Reply Quote 0
                  • J
                    james last edited by

                    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?! 🙂

                    1 Reply Last reply Reply Quote 0
                    • fxDreema
                      fxDreema last edited by

                      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?

                      1 Reply Last reply Reply Quote 0
                      • J
                        james last edited by

                        In this screenshot, you'll see two oscillators:

                        Clipboard02.jpg

                        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

                        1 Reply Last reply Reply Quote 0
                        • fxDreema
                          fxDreema last edited by

                          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?

                          1 Reply Last reply Reply Quote 0
                          • J
                            james last edited by

                            Yes. I think that might do it! 🙂 Thank you so much, as always! 🙂

                            1 Reply Last reply Reply Quote 0
                            • fxDreema
                              fxDreema last edited by

                              It's ready to be tested.

                              1 Reply Last reply Reply Quote 0
                              • J
                                james last edited by

                                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. 🙂

                                1 Reply Last reply Reply Quote 0
                                • J
                                  james last edited by

                                  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! 🙂

                                  1 Reply Last reply Reply Quote 0
                                  • fxDreema
                                    fxDreema last edited by

                                    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?

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      james last edited by

                                      Yes, it does. I've tested it in 044.

                                      1 Reply Last reply Reply Quote 0
                                      • fxDreema
                                        fxDreema last edited by

                                        I found the problem, fixed.

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          james last edited by

                                          OK. That's great. It seems to be working as expected. Thank you.

                                          Now, another little challenge! 🙂
                                          Clipboard03.jpg
                                          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

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          • First post
                                            Last post

                                          Online Users

                                          A
                                          E

                                          11
                                          Online

                                          146.7k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors