using arrays in ProOrder

Forums ProRealTime English forum ProOrder support using arrays in ProOrder

Viewing 13 posts - 1 through 13 (of 13 total)
  • #230827

    Hi everyone, I have programmed an array that stores past supports and resistances and I would like to use them as conditions for triggering orders. A simple example would be that way:

    in my current strategy a “buy” order is triggered if condition A is fulfilled. I would like to restrict it the the case when condition A is fulfilled AND the price crosses over (or under) any value of the resistance (or support) array.

    Of course I can’t just write it

    IF conditionA=true AND close crosses over $res

    because “$res” is the name of the array ; I can’t write

    IF conditionA=true AND close crosses over $res[a] (with a being any value)

    because I have to define “a” beforehand

    I could write

    But I’m unsure whether it is the most straightforward thing to do. Any ideas? Thanks!

    #230846

    This will do:

     

     

    1 user thanked author for this post.
    #230864

    Building upon Juld63’s idea, how would this be applied in the instance of multiple arrays containing levels of support or resistance?

    For example $res1, $res2, $res3 etc?

    Kind regards

    Stuart

     

    #230934

    Is this what you mean?

     

    #230938

    More or less, yes. I’d rather have it scan the array from ArrayMax to ArrayMin for supports and from ArrayMin to ArrayMax for resistances so that it tests the values in the order it should be encountering them, rather than in the historical order they are stored, so as to make the code more efficient. I just wonder if there wouldn’t be a simpler way.

    #230959

    You can use the arraysort command to reorder your array if you wish:

    https://www.prorealcode.com/documentation/arraysort/

    1 user thanked author for this post.
    #231325

    Hello everyone,

    I have coded and array indicator that gives me past supports and resistances not engulfed by subsenquent ranges. It works in Probuilder, meaning it displays as it should.

    Now that this is done, I want to be able to call the values in this array to test if my remarkable candle shapes intersect with any of those values or not.

    However, I have absolutely idea of how to call an array, its the various $array[n] … Of course I can just duplicate the whole indicator into the trading system’s code, but it becomes cumbersome.

    This is what I have down the line, if only I can manage to call $res and $sup (“candlenb” being used for identifying how many candles make up a shape)

     

    Any help will be much appreciated !

    #231328

    Also, to avoid scanning the whole array if the candle(s) is(are) between two values in the array, after it has failed to check if value “a” is inside a candle or group of candles, I want it to check whether it doesn’t reach the next value of the array in increasing order. My poor attempt is writing this value as “a+1” but of course it will return the value of “a” plus 1 point, not, if we’re starting from ArrayMin($res), the second smallest value of the array. Any idea how to get this, the nth smallest (or biggest) value of a given array beyond the absolute smallest (ArrayMin) and the absolute biggest (ArrayMax)? Thanks !

    #231329
    JS

    Hi,

    You can use “ArraySort”, for example “ArraySort($Res,Descend)…

    The entire array is now sorted from highest to lowest, so your highest value is now $Res[0] and the next highest values are: $Res[1], $Res[2], $Res[3], and so on

    The number between the bracket of the array is always the index of the array (not the value of the array)…

    #231334

    Thanks a lot! And to use it do I just need to CALL my array indicator at the beginning of the code?

    #231337

    I have tried to just CALL my array (res = CALL “res sup version longue”) but it tells me that it returns zero values…

    #231343

    Hi..  As far as I know you can not ‘call’ an array as a whole entity, with the call function from another file.

    Below is 1 example of what you can do.

    Example builds a replica array in the ‘Main’ file from values fetched  from the ‘data’  file with the call instruction.

    It does this replication on the first bar, fetching each array elements value individually.

    For this to work, the index value for the required value is sent  with the ‘call’ which means that variable ‘ idx’ requires setting up as a dynamic variable in the ‘data’ file.

    The return value is stored in ‘Main’ in local array at same index. The local array accessed as required via a index  value …  arr [idx].

    Also if you add additional res/sup lines to the ‘data’ arrays, since the size is calculated from how elements exists, these should ripple through to main, in indicators, not sure what effects with proOrder/bot. Not tried!

    #JS brings up a good point, if you sort the array in ascending or descending order, then finding the ‘nth’ highest/ lowest, would be easy to determine from chosen array index value.

    Also in practise you really probable only need to know if you have reached the next higher or lower res line from last position, you then could use a narrow loop range rather than looking through whole array.

    druby

     

     

     

    #231413

    Hello,

    Thanks for your help. In the meanwhile I’ve found a simpler way around: in the indicator where the array is calculated I call the other indicator and have it code whether the candle shapes are across a value of the array, and then I call the results of the array indicator not as array values but as a simple boolean operator, and then I can just call the value of this operator in my robot with a CALL instruction.

    1 user thanked author for this post.
Viewing 13 posts - 1 through 13 (of 13 total)

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