Array programming
Forums › ProRealTime English forum › ProBuilder support › Array programming
- This topic has 15 replies, 4 voices, and was last updated 4 years ago by robdav.
-
-
06/21/2017 at 12:45 PM #38732
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.
123456FOR i= 0 TO 50 DOZ= 1+iIF Z > 30 THENtest[i]= 1.25*closeENDIFNEXTIn case that arrays are not usable, is there any alternative?
Many thanks for your support.
Best Regards
Hasardeur
06/21/2017 at 1:38 PM #38743Sorry 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 ..! 😐
06/22/2017 at 7:04 AM #38776Good 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 reagrdsHasardeur
06/22/2017 at 7:21 AM #3877706/22/2017 at 7:22 AM #38778I 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
06/22/2017 at 8:19 AM #3878106/22/2017 at 8:30 AM #38782Correct. 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.
1 user thanked author for this post.
06/22/2017 at 9:07 AM #38784Ok, 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?
1 user thanked author for this post.
06/22/2017 at 9:22 AM #38786I 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
06/22/2017 at 9:34 AM #3879206/22/2017 at 9:48 AM #38795TimeFrame and12345678910111213141516171819202122//Determining the Time DimensionIf (date-date[1])=1 OR (date[1]-date[2])=1 Thena=1 // DailyEndifIf (date-date[1])=7 OR (date[1]-date[2])=7 Thena=7 // WeeklyEndifIf (date-date[1])=99 OR (date[1]-date[2])=99 Thena=30 // MothlyEndifIf (date-date[1])=299 OR (date[1]-date[2])=299 Thena=100 // QuarterlyEndifIf (date-date[1])>9500 Thena=200 // YearEndif// This condition determines whether we are at the "newest" barIf (a=1 AND date=today) OR (a=7 AND ((today-date)<=6 AND (Today-Date)>0)) OR (a=30 AND (today-date<=31)) thenx=1 //this is just a blank statement to allow me to store and export the codeEndIfReturn x3 users thanked author for this post.
06/24/2017 at 2:58 PM #38960Hallo 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
06/24/2017 at 5:01 PM #38964There 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/
12/24/2017 at 10:32 AM #5648102/13/2020 at 5:46 PM #119595Variables arrays should be available in a few weeks, more infos and examples, howto, in this topic: array variables availability in ProRealTime : examples and discussions
-
AuthorPosts
Find exclusive trading pro-tools on