array variables availability in ProRealTime – examples and discussions

Forums ProRealTime English forum ProBuilder support array variables availability in ProRealTime – examples and discussions

Viewing 15 posts - 106 through 120 (of 209 total)
  • #153246

    Hello Nicolas,

    For the Volume indicator example you gave in the first page , I try to adapt it  for my need without success.

    I try to reset the array after every new bar in order to separate the volume of each bar.

    I tried with “Barindex”, “intradaybarindex” without success.

    Here is my last code

    Do you have any advice ?

    Regards

    #153248

    I don’t know why but Intrabarindex is not working for the barindex comparison, I replaced it with BARINDEX:

    It works correctly now, the values are reset on each new bar.

    1 user thanked author for this post.
    #153251

    Perfect, thank you very much Nicolas

    #153605

    Hi Nicholas

    I tried your code at the first page “Example #3: separate buy/sell volumes on the same candle” but the result is completly different? Have you got any idea?

    Thanks

     

    #153638

    It is not different, it needs real time data to correctly get the buy/sell pressure, it is not possible to do the same back in history.

    #154066

    Many thanks dear Nicolas for your never ending zest and passion in what you do and thereby helping others.

     

    1 user thanked author for this post.
    #156011

    Hi, is it possible to define an array with multiple values? For example, if you want to save the array with known data.

     

    For example:

     

    $array = {“1”, “2”, “3”}

     

    Or do you have to assign values to the array one by one?

    #156023

    Multi dimensional arrays are not currently available in PRT but they are hopefully in the pipeline.

    At the moment the only work around is to use for example location 123 to be location (1,2,3) and then use multiplication,division and rounding as required to get the info stored at that location.

     

    #156027

    Thanks a lot for the quick response. I am not sure I understand this workaround, at least the retrieving part doesn’t make much sense as you are rewriting the mylocation value. However, in my query I was referring to one-dimension arrays, i.e. I want to be able to define them at the beginning of the script, with the first positions filled in, kind of like a known table of values that I can use later on and loop through it.

    A second, related question is, I noticed you cannot pass arrays as arguments to functions, correct? I am trying to do a simple moving average of an array that I have defined, but it throws a syntax error. For example:

     

     

    #156028

    pablolo – Please be more careful when posting to follow the forum rules so that we keep a nice tidy forum. I tidied up your post.

    • Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.

     

    An array is just a variable with multiple storage locations for values. You can get an average of the values at any location over the last p bars however what you are doing is not valid.

     

    #156033

    Sorry if these are all basic questions, but I can’t understand your last example.

     

    I get an error when using parenthesis in your last example:

    Shouldn’t it be like this?

    And, if I am right, what’s the point of calculating an average of $myarray[12], when it is going to be the same value for all bars?

    I am still not clear of how I can calculate an average of the last 52 values of my array. I’m guessing Average function only averages across bars, not array values, is that the case?

     

    #156034

    Moreover, if I use “[” in this example , I get a syntax error, that it is expecting a positive whole number for “SRC”, which I am not sure what it refers to, as I do not have any variable called “SRC”.

     

     

    #156044

    Yes my typo mistake – the correct syntax is with []

    Yes AVERAGE[52] just takes the average value over the last 52 bars of whatever you put after the instruction.

    One thing you have to consider if you are using arrays in indicators is that the latest bar is formed on the fly and will continuously fill your array every time a condition to add a value is met until the bar finally closes.

    If you simply want to get an average of the last 52 values when a condition was met then forget arrays and use loops.

     

     

    #156088

    I am actually trying to replicate the programming of the RSCMansfield indicator, as there is a limitation in probuilder and I cannot use the inbuilt function, because I want to compare an equity to an index, such as S&P 500, and that apparently is not allowed.

    Given that you also cannot import external data in PRT, I am defining an array with the last 52 weekly close prices for S&P500 and wanted to calculate the RSCMansfield formula, as per https://www.stageanalysis.net/blog/4266/how-to-create-the-mansfield-relative-performance-indicator#:~:text=The%20formula%20for%20measuring%20relative,price%20of%20a%20market%20average.%22

     

    RP = ( stock_close / index_close ) * 100

    MRP = (( RP(today) / sma(RP(today), n)) - 1 ) * 100

    So, what I am doing first is populate the table with S&P500 close prices:

     

    I am struggling trying to replicate the simple moving average part (SMA) using arrays or loops.

     

    Any pseudo-code or idea on how I could achieve this? Or even better, the actual code of how PRT calculates this internally 🙂

     

    Thank you

    #156099

    Having the last 52 closes will only allow you to calculate your RSCMansfield indicator for the last bar on the chart. Trying to do more than this will require you to fill in every weekly closing price far enough back in history (+52 more bars) to draw a line as long as you want it. You could then loop back from the LASTSET array and add 52 values and divide by 52 to get your weekly average. Then step one more bar back and repeat. You would need to update the array by adding a new array location and close value each week.

    1 user thanked author for this post.
Viewing 15 posts - 106 through 120 (of 209 total)
Similar topics:

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