Adaptive Average in higher timeframes

Forums ProRealTime English forum ProOrder support Adaptive Average in higher timeframes

Viewing 15 posts - 1 through 15 (of 16 total)
  • #237176

    I thought I was going crazy, but it would appear that the AdaptiveAverage function just returns the value Close if used in higher timeframes! However it works as expected if used in the Default timeframe section in the same script (i.e. returning the Adaptive Average calculated over the last x bars’ closing value, according to the parameters specified).

    Can someone please test and verify that they see the same behaviour? If so, then consider this a bug report. Thanks.

    Using PRT v12.0 (via IG).

    #237185

    This code works like a charm to me. I used two DAX charts, 1-hour + Daily (as you can see from attached pic):

    The 1-hour adaptive average returns the same values on both the chart and the indicator.

    The Daily adaptive average returns almost the same values on both the chart and the indicator, the tiny difference (just a few decimals)  is probably due to a slightly different timing when updating the ticks on the charts.

     

     

    #237188

    My apologies, I neglected to mention that this was in ProBackTest and using GRAPH to output it.

    Also I was using UpdateOnClose both for 1 Minute and Default (which was running on a 10 Seconds chart).

    #237205

    Here’s an example of what I mean, this being a backtest run on a 10-second chart:

    Attached is a screenshot with the output of both GRAPH functions for that simple logic check. If it’s ‘1’ it (incorrectly) equals Close, and the one that is outputting ‘0’ is functioning correctly.

    Some other interesting observations:

    1. Swapping AdaptiveAverage for ExponentialAverage – or any other type of average that I can think of – results in both functioning correctly (output a constant ‘0’ for both).
    2. Changing the 1 minute timeframe to Default instead of UPDATEONCLOSE also results in it functioning correctly (outputting a constant ‘0’ in red).

    I think what I’ve stumbled upon is a corner case which triggers a bug in the AdaptiveAverage function. Unfortunately for me I require all of my higher timeframe code to be using UPDATEONCLOSE.

    #237233
    JS

    Hi,

    If you think that “Graph (kama1Fast = Close) Coloured(255,0,0)” is a simple logical check, that’s not true…

    The only thing that happens here is that you equate “kama1Fast” with the “Close” which has no meaning whatsoever…

    I don’t know what you want exactly, but the “adaptive averages” give the right results and if you want to show these results in a backtest, you can use:

    TIMEFRAME(1 Minute, UPDATEONCLOSE)

    kama1Fast = AdaptiveAverage[26,2,30](Close)

    GRAPH (kama1Fast) COLOURED(255,0,0) // Red

    TIMEFRAME(10seconds, UPDATEONCLOSE)

    kama10sFast = AdaptiveAverage[26,2,30](Close)

    GRAPH (kama10sFast) COLOURED(0,255,0) // Green

    #237234

    If you think that “Graph (kama1Fast = Close) Coloured(255,0,0)” is a simple logical check, that’s not true…

    Hi, I think you’ve misunderstood: that post was for debugging purposes. So what you see above is just debug code – to prove what is going on! (I’m a software engineer, so I am used to doing this kind of thing all the time.)

    As you can see from the screenshot, the constant result of ‘1’ in red in the GRAPH output shows that there is likely a bug in the underlying implementation of AdaptiveAverage.

    #237237
    JS

    Hi,

    In ProReal code, “Graph(kama1Fast=Close)” doesn’t have any meaning, and you certainly can’t conclude that if its output is equal to 1, there’s probably a “bug” in the underlying implementation of the “AdaptiveAverage”…

     

    #237238

    Perhaps it will help if I take you through the steps I’ve been through myself:

    1. I initially wrote functional code that had “meaning”
    2. I observed that the direct output of that AdaptiveAverage call in the higher timeframe looked very much like it was just the Close value of each higher timeframe (1min) candle
    3. I changed the GRAPH code to a simple debug-style Boolean equation to prove my hypothesis
    4. I showed the evidence here that it indeed does returns ‘true’ (‘1’) for each 1min candle, which it shouldn’t ever do
    5. I’m after someone to verify this bug so that it can be fixed in the next release of PRT

    Is that clearer now?

    #237240
    JS
    1. Okay
    2. No, the “AdaptiveAverage” in the higher timeframe doesn’t look like the “Close” at all… (see screenshot)
    3. No, it’s not a (simple) Boolean debug test… (kama1Fast=Close is not a test as you should know as a software engineer)

    A Boolean test might look like this:

    If kama1Fast = Close then

    Output=1

    Else

    Output=0

    EndIf

    1. See 3.
    2. There is no “bug”, the Adaptive Averages work as expected…
    #237242

    JS, I’m sorry but I actually know what I’m talking about re how to debug such things.

    (kama1Fast=Close) is indeed a Boolean test; inside a parenthesis it becomes a single statement which is evaluated before it is passed to the GRAPH function as a parameter. You can take shortcuts like that in most programming languages.

    In my example you can even see the differences between the two lines from the two timeframes. It literally proves my point, very clearly for anyone with a bit of understanding.

    And your screenshot is meaningless without code. Did you use a backtest script and the GRAPH code, like I did?

    No actually please stop replying so this thread doesn’t get any more muddied by it. This was supposed to be a simple, clear-cut bug report for the eyes of a PRT rep/moderator!

    #237246
    JS

    Okay, let’s see what the moderator, @robertogozzi, has to say about it…

    #237265
    JS

    Sorry Rob, I understand…

    #237267

    Hi there,

    Of course your test shows your “right”. Why it is so (wrong) is something else. My reasoning (FWIW) :

    UpdateOnClose vs Default may not give the AdaptiveAverage sufficient data to make any proper calculation. I did not test this (nor ran your code), but it feels logic to me. This includes any other (like ExponentialAverage) does working, which would be logic because it will be able to use the last data on its own, which AdaptiveAverage will (?) not.

    Again, this is by looking at your (debug) code, and things make sense to me. But :

    You should also apply JS’ test with the If / Else on Kama1Fast = Close; This is a little effort. Why do I say this ? because people like JS may check their statements before saying something. Bute merely :

     

    (kama1Fast=Close) is indeed a Boolean test; inside a parenthesis it becomes a single statement which is evaluated before it is passed to the GRAPH function as a parameter.  You can take shortcuts like that in most programming languages.

    Here you may make a mistake because ProBuilder or whatever it’s called is hardly a programming language; it is the product of people who apply “intelligence” in the parser which fails in a 1000 places (ask me for real and I may come up with 20 examples). Graph is a very first command to fail (ask me about that and I need 2 A4 pages to lay it all out). Anyway, I too would attest that your “=” would be a proper boolean test, but I would try the If/Else too.

    Of course you come up with this topic for a reason, and I am of the stance that I believe people first. For me to prove that they may be wrong. And thus so far you are correct. 🙂

    If the If/Else still gives you the same result, try to move the Graph outside of all TimeFrame command. Thus, reset it to the fastest TF at the bottom of your program and then do the Graph again (after possible adjustment because of moving it out of the TF commands). You may be surprised on the results (yes, Graph s*cks).
    You may try to use Print too (Print is decent, says me).
    Still no dice ? then try to “fit” the two TF’s within each other by different factors. Thus, change the 1 minute to 10 minutes and/or change the 10 second to 1 second or 20 seconds etc. You will start to learn what’s going on really and possibly may even come to the conclusion that your assumptions on how to use the PRT programming language must be adjusted a little (I am thinking of your real code and where this could fail, you working on the proof in the same direction – which is human).

    Let’s for fun bet on a nice beer that in the end you’ll say “ahhhh, like that !”. It happened to me a 100 times, just because I assume PRT to have/be a normal programming language which makes it a killing job to “live in”. People without the experience won’t notice. People with the experience will hate it. Or in the end, get used to it.
    I am used to it. 🙂

    #237275

    My apologies, I neglected to mention that this was in ProBackTest and using GRAPH to output it.

    Also I was using UpdateOnClose both for 1 Minute and Default (which was running on a 10 Seconds chart).

    I moved the topic to ProOrder support.

     

    #237288

    My apologies, I neglected to mention that this was in ProBackTest and using GRAPH to output it.

    Also I was using UpdateOnClose both for 1 Minute and Default (which was running on a 10 Seconds chart).

    I moved the topic to ProOrder support.

    Oops, thanks – as you can see I’m new to these forums (but not new to PRT, which I’ve been using for many years now)…

Viewing 15 posts - 1 through 15 (of 16 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login