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
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 ..! 😐
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
programming an array without the array functionnality? Hmmm… not possible 🙂 You’ll have to deal with different variables names instead.
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
@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?
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.
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?
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
Yes, put the code here please, for future reference. Thanks.
//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
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
Hi Nicolas,
Do you happen to know if PRT have any plans to implement array functionality in their code?
Thanks
Rob
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