Array programming

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #38732 quote
    Hasardeur
    Participant
    Average

    Hallo to all,

    I would like to ask, if it is possible to use arrays by the code programming?

    Due to the fact that the original code is much more complex (frequenz analysis) i have given a simple sample below.

    FOR i= 0 TO 50 DO
    Z= 1+i
    IF  Z > 30 THEN
    test[i]= 1.25*close
    ENDIF
    NEXT

     

    In case that arrays are not usable, is there any alternative?

    Many thanks for your support.

    Best Regards

    Hasardeur

    #38743 quote
    Nicolas
    Keymaster
    Master

    Sorry but it is not possible to build variables arrays, we must know in advance how much variables we need in our codes, I know it somewhat limited our way of programming .. I hope it will be possible soon or later in the future ..! 😐

    #38776 quote
    Hasardeur
    Participant
    Average

    Good morinng Nicolas,

    many thanks for your explanation.
    In the men time i have struggled out the forum for arrays.
    Sorry I should have to check the forum first before posting, SORRY.
    Is there any possibility to program the array syntax without using the array function?
    A possible programming sample would be helpful (I try to program frequenz analyser).

    Many thanks in advance.
    Best reagrds

    Hasardeur

    #38777 quote
    Nicolas
    Keymaster
    Master

    programming an array without the array functionnality? Hmmm… not possible 🙂 You’ll have to deal with different variables names instead.

    #38778 quote
    Pinny
    Participant
    Junior

    I needed this feature (array programming) last month when I coded a Wyckoff Wave indicator. Eventually I worked around this limitation (I can understand why PRT, from programming model aspects, do not open the option for this) with the set of graphical commands that PRT released in 10.3. Basically what I did was to identify the “current” bar, i.e. the “newest” bar, and do all my calculations at that point. Then, I used the graphical commands, DrawSegment and DrawRectangle, to actually draw the wave on the price chart. This way I have all the history stored in a read only array and I can access it readily. To express this is other words – you can read a “historical” point of data but you cannot write to it – so I “wrote” in a form of graphics on the chart 🙂

    There are few advantages to this method, mainly speed as the indicator is calculated on all the bar set only once, and few limitations (like scaling) that I found to be workable.

    Pinny

    #38781 quote
    Nicolas
    Keymaster
    Master

    @Pinny

    So you make a loop through history only on the last bar to find what your indicator needs to draw your figure? You are not building an array, right?

    #38782 quote
    Pinny
    Participant
    Junior

    Correct. As you noted I cannot build an array or, to be more exact, I cannot “write” to a past element of an array. But I can draw an element at any past point in time. In a sense it is an array but unlike all standard arrays in PRT (e.g. volume, price or any indicator) where you can read past points but cannot write to them, in this specific workaround, I write to past points but can’t read them (only re-calculate them) as the array cells are images on a graph.

    Derek thanked this post
    #38784 quote
    Nicolas
    Keymaster
    Master

    Ok, so this is not an Array Function as we are used to with other programming language 🙂 Of course we can read past datas of any variables! 🙂

    How do you find you are on the last bar of the chart? I know I shared something with you the other day, but I’m wondering if you find anything more relevant for this purpose?

    Derek thanked this post
    #38786 quote
    Pinny
    Participant
    Junior

    I use the hint you gave me (Date and Today commands) – I first identify the timeframe I am in by calculating (Date-Date[1]) and (Date[1]-Date[2]), this yield a fixed number: 1 for Daily, 7 for Weekly etc. Then I calculate (Today-Date) to see if the current bar is complete or partial – I work only on complete bars. The reason for doing both (Date-Date[1]) and (Date[1]-Date[2]) is to overcome the effects of weekends/yearends etc.  (will cause the difference to be more than 1 for daily and cause irregularities in year end etc)

    Hope this is clear, otherwise I’ll just send the code

    #38792 quote
    Nicolas
    Keymaster
    Master

    Yes, put the code here please, for future reference. Thanks.

    #38795 quote
    Pinny
    Participant
    Junior
    //Determining the Time Dimension
    If (date-date[1])=1 OR (date[1]-date[2])=1 Then
    a=1 // Daily
    Endif
    If (date-date[1])=7 OR (date[1]-date[2])=7 Then
    a=7 // Weekly
    Endif
    If (date-date[1])=99 OR (date[1]-date[2])=99 Then
    a=30 // Mothly
    Endif
    If (date-date[1])=299 OR (date[1]-date[2])=299 Then
    a=100 // Quarterly
    Endif
    If (date-date[1])>9500 Then
    a=200 // Year
    Endif
    
    // This condition determines whether we are at the "newest" bar
    If (a=1 AND date=today) OR (a=7 AND ((today-date)<=6 AND (Today-Date)>0)) OR (a=30 AND (today-date<=31)) then
    x=1 //this is just a blank statement to allow me to store and export the code
    EndIf
    Return x
    
    Nicolas, ALE and Rumjacks thanked this post
    #38960 quote
    Hasardeur
    Participant
    Average

    Hallo Nicolas,

    I would like to have the period / dominat cycle calculation of the autocorrelation code by John Ehlers.

    Is there any possibility to convert the code (using arrays) to PRT,

    or do you know a well working alternative period / dominat cycle measuring code (not Hilbert Transformation)?

    Many thanks for your replay in advanced.

    Best Regards

    Hasardeur

    #38964 quote
    Nicolas
    Keymaster
    Master

    There are a lot of John Ehler’s code in the forum and the library. I found this indicator for cycles (?) https://www.prorealcode.com/topic/can-anyone-code-john-ehlers-empirical-mode-decomposition/

    or

    https://www.prorealcode.com/prorealtime-indicators/ehlers-adaptive-cyber-cycle/

    #56481 quote
    robdav
    Participant
    Veteran

    Hi Nicolas,

    Do you happen to know if PRT have any plans to implement array functionality in their code?

    Thanks

    Rob

    #119595 quote
    Nicolas
    Keymaster
    Master

    Variables arrays should be available in a few weeks, more infos and examples, howto, in this topic: array variables availability in ProRealTime : examples and discussions

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

Array programming


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Hasardeur @hasardeur Participant
Summary

This topic contains 15 replies,
has 4 voices, and was last updated by robdav
6 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/21/2017
Status: Active
Attachments: No files
Logo Logo
Loading...