array variables availability in ProRealTime – examples and discussions

Viewing 15 posts - 31 through 45 (of 255 total)
  • Author
    Posts
  • #121027 quote
    JMat45
    Participant
    Senior

    Hi Nicolas, is it ready yet for trading accounts (V11) with Interactive Brokers?

    #121029 quote
    Nicolas
    Keymaster
    Master

    I don’t think it is available presently for that type of account, but very soon. Best way to verify is by typing one of the array instruction (or by copy/paste one of the examples of that topic) and check if there is a syntax error 😉

    #121087 quote
    Vonasi
    Moderator
    Master

    I created a little code that uses arrays to create a seasonality curve. It might be of interest to anyone reading this topic so here is the link to that indicator:

    Seasonality Curve using arrays.

    #121118 quote
    Nicolas
    Keymaster
    Master

    Another example posted by Roberto, the Meander Bands updated with ARRAYS

    #121355 quote
    Nicolas
    Keymaster
    Master

    Example with a price gap levels indicator coded by @grivoire

    #122026 quote
    Nicolas
    Keymaster
    Master

    Example #7: calculate the Average Daily Range (ADR)

    A simple example on how to store a value in an array while the history is loaded. Each new day, the $drange variable increase its index to save the previous day range (High-Low). Once the array length is sufficient (has enough values) to calculate the average period, the calculation is made. Therefore, we only use a quick loop through the array and not through the global data history to fetch the last X days range to calculate the ADR.

    // https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/
    // (please do not remove the link above for future reference)
    // Example #7: Average Daily Range 
    
    //--- settings 
    adrperiod = 20
    //--- end of settings 
    
    sum = 0
    if day<>day[1] then
     $drange[lastset($drange)+1]=dhigh(1)-dlow(1)
     if lastset($drange)>=adrperiod  then
      for i = lastset($drange) downto lastset($drange)-adrperiod do
       sum = sum+$drange[i]
      next
      adr = sum/adrperiod
     endif
    endif
    
    return adr as "Average Daily Range"
    Vonasi, Bel, Kovit, Zinc and abel1986 thanked this post
    #122079 quote
    Rory Dryden
    Participant
    New

    Thanks Nicolas.

    Zinc thanked this post
    #123165 quote
    Fabian
    Participant
    Master

    Hi Nicolas,

    I’ve a question for the expert.
    Is it possible with the new array function (or without) to calculate live price projection targets in the chart with the corresponding probability?
    And if so, would it be possible to create a template in which we enter our conditions?

    Thank you.

    Fabian

    #123172 quote
    Nicolas
    Keymaster
    Master

    Yes, that would be possible. You just have to deal with the probability calculation.

    Fabian thanked this post
    #123419 quote
    Vonasi
    Moderator
    Master

    I developed my seasonality curve indicator that uses arrays further and it might be of interest for anyone studying the use of arrays.

    Find it here:

    Seasonality Curve using arrays.

    #123815 quote
    nonetheless
    Participant
    Master

    Are arrays only used for data? ie external to the code. Or could they somehow be used to select indicator variables within the code? I’m thinking of something like this

    //PRC_Stochastic RSI | indicator
    lengthRSI = lr //RSI period
    lengthStoch = ls //Stochastic period
    smoothK = sk //Smooth signal of stochastic RSI
    smoothD = sd //Smooth signal of smoothed stochastic RSI
    myRSI = RSI[lengthRSI](close)
    MinRSI = lowest[lengthStoch](myrsi)
    MaxRSI = highest[lengthStoch](myrsi)
    StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
    K = average[smoothK](stochrsi)*100
    D = average[smoothD](K)
     
    c1 = K>D
    c2 = K<D

    where the 4 variables result in hundreds or thousands of workable combinations.

    #123834 quote
    Vonasi
    Moderator
    Master

    You can store any value you like in an array. So you could say recognise a set of candle price action on the chart and then store all the periods of an indicator that were within a certain range at this time.

    For example you could have an array with storage locations from 1 to 200 and when price does something you like add one to each location if the price was above that period average. So for example:

    if (my event happens) then
    for a = 2 to 200
    if close > average[a] then
    $avg[a] = $avg[a] + 1
    endif
    next
    endif

    So now we have a store of which averages were correct the most often.

    nonetheless thanked this post
    #123837 quote
    nonetheless
    Participant
    Master

    Thanks Vonasi, it seems a hugely powerful tool. I’ll have to do some serious homework to get my head around it.

    #123873 quote
    Nicolas
    Keymaster
    Master

    Think of arrays as dynamic variables. You can create as many variables as you want, on the fly. Store everything in arrays and use them later (or not) in your code.

    #123889 quote
    nonetheless
    Participant
    Master

    If the variables are dynamic, is it self-optimizing? In the StochasticRSI example, if each variable had an array of 2-20 would the code then select the most effective combination? Or is it recording what would have been the best combination for future reference?

Viewing 15 posts - 31 through 45 (of 255 total)
  • You must be logged in to reply to this topic.

array variables availability in ProRealTime – examples and discussions


ProBuilder support

New Reply
Author
author-avatar
Nicolas @nicolas Keymaster
Summary

This topic contains 254 replies,
has 50 voices, and was last updated by robertogozzi
1 year, 3 months ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 02/06/2020
Status: Active
Attachments: 59 files
Logo Logo
Loading...