Output array with label AFTER sort?

Forums ProRealTime English forum ProBuilder support Output array with label AFTER sort?

Viewing 15 posts - 16 through 30 (of 31 total)
  • #236316

    I can’t see anything wrong. I am afraid I completed your code incorrrctly as Copy & Paste could not work.

    Please attach your code as a complete text files or, which is preferred, the ITF you used.

     

    #236318

    HI Roberto,

    please find attached. One itf with the bubble sort, and one without the bubble sort. These are the exact files that I used to make the previous pics showing the difference in $da[k].

    The exact same code is present in both to fill up $da[k].

    I did my testing on Brent Crude Oil Full1024 with daily bars, and I am using a PRT demo account.

    I had a bit of a play around, and it doesn’t seem to be the duplicate removal portion of the code from what I can tell that’s causing the problem, so it must have something to do with the bubble sort process?

    Cheers,

    Finning

     

    #236336

    I could finally get the hang of it… the BUBBLE SORT code is incorrect. These are the correct lines:

    sorry for the inconvenience!

    1 user thanked author for this post.
    #236344

    Hi Roberto,

    thank you for that!! Just travelling at the moment, will have a look at it as soon as I can.

    Cheers,

    Finning

    #236368

    Hi Roberto,

    I copied that code into the itf that I sent you with the bubble sort present and tired it, and it doesn’t look like it has worked? The same issue is still there.

    Maybe there isn’t a problem with the bubble sort?

    Maybe the summation of the array $da[k] isn’t working because of the loops in the bubble sort are throwing it out?

    #236372

    Try this modified version, with the new bubble sort and a few more changes:

     

     

    1 user thanked author for this post.
    #236394

    Hi Rob,

    I imported your ITF file, tried it, and the same problem is still there. The bubble sort is still having the effect of corrupting the array fill.

    The duplicate removal feature still works if you remove the bubble sort component, and it will remove duplicate values out of $da[k], even if it’s not bubble sorted.

    I’ve attached 2 pics so you can see what I’m seeing of your code. With your original unmodified code, and, with the bubble sort deleted (the duplication removal is still present).

    The bubble sort code is interfering with storage of the correct values in $da[k]. That’s what is happening, or that is at least what looks to be happening.

    What must be happening is that the bubble sort is scrambling the values – sorting them – and when $da[k] is looping in its summation process, it is writing it’s values into the wrong index, so then summing up incorrectly. The bubble sort sorts it every bar, and then the array summation of $da[k] puts it in the wrong index again. This might then explain why the results with the bubble sort are semi-homogenous and slightly trending up too.

    It’s sort of like you need to copy $da[k] (and $la[k]) into a new disposable array(s) – each bar – the bubble sort sorts those temp arrays – and that is your answer. And when I mean temporary disposable array(s), I mean before the bubble sort process, to be clear, because the bubble sort process itself uses temporary arrays, not to be mistaken with them.

    The first part of the code can keep on producing $da[k], and the bubble sort never “sees” it, it only works on copied disposable arrays that would need to be created each bar.

    I don’t think it’s a problem necessarily with the bubble sort code itself, but how the bubble sort is interacting with the filling of $da[k] when an array summation as per below is used in its creation.

     

     

    Many thanks Rob for your perseverance and patience,

    Finning

    #236412

    There are two issues:

    1. arrays are not historicized, so $var[1] is element 1 of the array $var, not the previous value of $var; this implies, unlike variables, that elements are updated each tick and, if conditions are not met at the closing of a bar, their original value cannot be restored because it’s lost
    2. the same conditions is added multiple times while a bar is formed, thus retaining incorrect values.

    I have added a new 1-element array to be used as a flag to detect any change in the opening time of a bar, so we can tell when a new bar has formed to update the array (lines 7, 8 and 9). The IF in line 8 is closesd in line 69.

    Give it a try.

    1 user thanked author for this post.
    #236536

    Hi Rob,

    sorry have been on the road again the last few days.

    First of all, yes I am aware that arrays are not historicized – though the array values are kept from bar to bar, unless something is done to change them.

    As to your 2nd point Rob, I tried your code above, with the timeflag, and when I got rid of drawonlastbaronly = true, it showed that the timeflag = 0 for all bars. It seemed to be that there was no problem with a time change in the opening of the bar, when this timeflag array was plotted against just the straight opentime for that bar, of which all results for all bars said 0.

    I’ve continued my line of enquiry with the theory I had above, how the looping of the bubble sort was damaging the initial $da[k], and how if a temporary $da[k] was used, this might negate that problem.

    In short, it looks like the idea of a temporary array has worked to solve this problem. I’ve attached an ITF of how I got it to work. The other thing with it too, I unset the array at the start of every bar, so the temp array gives an up to date version of the cross count values in the $da[k] array.

    Many thanks for the ideas Rob. Great to have someone to talk to about this stuff, it’s a bit hard on your own.

    Cheers,

    Finning.

    1 user thanked author for this post.
    #236603

    Hi Rob,

    with the duplicate removal tool, is there any way that it can be made to store the smallest of the duplicate values?

    For example, in the data above, moving average periods 15, 16, and 20, all have 11 crossovers.

    The current duplicate removal code keeps the 20 period.

    Is there any way that it could keep the 15 period value instead? So 15 would show up from the duplicate removal, and not 20.

    I tried

    but it only returned the largest singular value of the bubble sort.

    Any ideas?

    Thanks,

    Finning

     

    #236606

    Add this snippet at the end, just before RETURN:

     

    #236607

    Hi Roberto,

    no that didn’t seem to work.

    Another way of saying the above, what I was looking for, is to keep the lower duplicate value (based on the $la[k] array) from the duplicate removal process.

    The duplicate removal process currently keeps the higher $la[k] array and corresponding $da[k].

    Have attached another pic to show this, crossing out the higher values, and keeping the lower values.

    Thanks,

    Finning

    #236658

    Try these lines (I am attaching the ITF file, as well):

    it seems to work for me.

     

     

    #236673

    Hi Rob,

    I tried your code, and it didn’t give the intended result. Please see attached pic of me running this code.

    Rob, I’m sorry if I haven’t explained myself properly.

    With the bubble sort result, if you have a look at the numbers in the brackets [x], these are the periods that the moving average crossovers were recorded in.

    The number to the right of them, is the count of the number of moving average crossovers.

    What is happening in the duplicate removal, is that it is keeping the result with the highest number in the brackets [x].

    The problem that I am trying to solve is I need the duplicate removal code to give the smallest [x] value for duplicates.

    So, instead of the duplicate removal keeping the highest duplicates, I need it to keep the lowest duplicates.

    If I run both of these duplicate removal processes together, I will have a highest and a lowest value (I am only interested in the biggest values of the bubble sort too), and I can then take a midpoint of these two numbers for use as a variable.

    Please find the attached pic to explain this.

    Thanks,

    Finning.

     

    #237007

    Hi Rob,

    did you have any further luck in looking at this?

    Thanks..

Viewing 15 posts - 16 through 30 (of 31 total)

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