array variables availability in ProRealTime – examples and discussions
Forums › ProRealTime English forum › ProBuilder support › array variables availability in ProRealTime – examples and discussions
- This topic has 254 replies, 50 voices, and was last updated 1 month ago by robertogozzi.
-
-
07/15/2024 at 5:48 PM #235300
A strategy application, well that will take some time, I’ll have to sleep on that one.
Regarding volume, if you replace the ‘close’ on line 10, with volume,
that appears to display the volume values of the 1 tick chart I believe.
Dam, I told everyone, doh
07/17/2024 at 11:31 AM #235368Not sure how this will work out :
@Nicolas, page 15 of this topic presents a black screen. This is how the topic “don’t know what happened, but this was the ‘Array Post'” emerged (a continuation of the original topic).
I am now responding to page 14 – maybe that recovers page 15. But if not, I will post it in that 2nd topic (see below). And in that case ? can the Array Topic be repaired ?07/17/2024 at 11:34 AM #235370Not sure how this will work out :
@Nicolas, page 15 of this topic (see 2nd pic) presents a black screen. This is how the topic “don’t know what happened, but this was the ‘Array Post'” emerged (a continuation of the original topic).
I am now responding to page 14 – maybe that recovers page 15. But if not, I will post it in that 2nd topic (see below). And in that case ? can the Array Topic be repaired ?… so it did not work out. See the 2nd pic below for the topic which is stuck.
07/17/2024 at 11:36 AM #23537407/17/2024 at 11:58 AM #23537907/17/2024 at 12:32 PM #23538207/18/2024 at 7:25 AM #23545710/14/2024 at 1:39 PM #238980Recovering historical values of an array.
Compared to normal variables, arrays don’t create their historical values at the end of bar but retain their current value.Using simple maths:
A + B = C , which can be transposed to , C – A = B or C – B = A
Also, A – B = D which is the difference between A and B.Looking at the sequence of events, the first formula, takes value A then adds value B, which results in C.
The transposed formula, take the result , C and subtracts either A or B which gets the missing value.
Looking closer at this sequence, you could say the later value C, requires an earlier value, A or B, to find the missing value.So applying that to arrays, arr[0] =10, needs the value prior to it which could be store in arr-1[0] = 6.
Therefore, arr[0] – arr-1[0] = 10 – 6 = 4 the difference is the missing value, A – B = D.Looking at the history values of 1 element, with original values in arr.
See table 1.res = arr-arr-1 gives the difference between the current and prior value, A – B = D.
Instead of storing the original values, we store the sum of the values. Which is like adding the difference between new and current value. Therefore D – B = A or C – B = A if your following.
Here, D is the accumulated value and B is the prior accumulated value.
Doing this, encodes the original data values or information. In normal array operation, the current value, is lost when the original element values get overwritten. Or to put it another way, originally we have A = C where A and C don’t retain any information from the earlier values as they go forward and just represents the new value.Looking at the history values of 1 element, with an accumulated value in arr.
See table 2.Note: the difference value of Res=arr-arr-1 is now the same as the original arr values.
Magic…Using the two arrays, along with the accumulative values, allows, not only to find a specific prior value of an array, but depending on the range of element index for both arrays chosen, you can get a summed value over a range of array elements.
A few things to point out,
Using the barindex value for the array index, aligns the arrays with respect to the chart bars, which is helpful when trying to look-back to recover values. This also means that the arrays need to be updated each bar to keep the alignment.
Now the above is the Rule and I’m sure there could be exception to it, depending on application, type of data, and context.In simple example, the look-back value is retrieved from both CLOSE[LB] and from the arrays.
1234567891011121314151617181920212223242526272829303132// avoid changing text valuedefparam drawonlastbaronly = true// avoid look-back beyond bar 0if barindex > 0 then// copy last bars arr value to arrM1$arrM1[barindex] = $arr[barindex-1]else$arrM1[0]=-1 // define array by assigning a default valueendif// new arr value accumulated$arr[barindex] = $arrM1[barindex] + close// on current bar, look-back LB bars and recover the close valueif islastbarupdate thenLB = 5barMx = $arr[barindex-LB]-$arrM1[barindex-LB]closeLB = close[5]// display the look-back close valuedrawtext("arr { #LB#} = #barMx#",0,0)anchor(middle,xshift,yshift)drawtext("close [ #LB#] = #closeLB#",0,-40)anchor(middle,xshift,yshift)// identify the look-back bardrawVline(barindex-LB)endifreturn barindex as"barindex", close as"close", $arr[barindex] as "acc total"10/14/2024 at 2:00 PM #238982Hello moderators…
My above post, ‘Recovering historic values of an array’ was posted in wrong topic, should have gone in , see link
https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/
Additionally the rouge image above it, was my pathetic attempt to embed an image gone horribly wrong.
If possible, could you move the relevant post, and delete the rogue image along with this post.
Thankyou.
My bad… druby
10/16/2024 at 12:47 PM #23907510/18/2024 at 11:10 AM #239185Hi Roberto @robertogozzi,
A small reminder : the merge with the other topic was applied, but the merged posts in this topic you look at now, are still there.
Regards,
Peter10/18/2024 at 11:30 AM #23918910/18/2024 at 4:41 PM #239217Hi Roberto @robertogozzi,
A small reminder : the merge with the other topic was applied, but the merged posts in this topic you look at now, are still there.
Regards,
Peter
This is the topic where he wanted them to be, they come from elewhere, thanks 🙂
10/20/2024 at 8:33 AM #239265I was nicely confusing myself there. Plus I was addressing you, Roberto, while it should have been Nicolas.
I guess part of the confusion springs from the fact that that picture is still there in this other topic, plus that druby now (implicitly) links to the topic over here (a few posts back).Only justifying my “error” … 😉
1 user thanked author for this post.
10/20/2024 at 12:22 PM #239267I was addressing you, Roberto, while it should have been Nicolas.
Actually you were right, as I had made the SPLIT + MERGE, not Nicolas 🙂
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on