Define price zone via an indicator
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › Define price zone via an indicator
Hello,
I’m looking for help in order to define price zone via a rectangle draw. Let’s say that in my indicator I calculate 5 price variables
variable1=200, variable2=150,variable3=196,variable4=207,variable5=110
do you have any idea how I can, sort and group variables together based on distance threshold (so in my exemple only variable1,3,4 would be grouped together because there is less than 15 point distance between them)? The idea finally would be to draw a rectangle between 196 and 207.
thx for your ideas
To sort 5 variables you’ll have to write:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
Var1=200 Var2=150 Var3=196 Var4=207 Var5=110 // V1=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5))))) If V1=Var1 then Var1=0 ElsIf V1=Var2 then Var2=0 ElsIf V1=Var3 then Var3=0 ElsIf V1=Var4 then Var4=0 ElsIf V1=Var5 then Var5=0 Endif // V2=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5))))) If V2=Var1 then Var1=0 ElsIf V2=Var2 then Var2=0 ElsIf V2=Var3 then Var3=0 ElsIf V2=Var4 then Var4=0 ElsIf V2=Var5 then Var5=0 Endif // V3=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5))))) If V3=Var1 then Var1=0 ElsIf V3=Var2 then Var2=0 ElsIf V3=Var3 then Var3=0 ElsIf V3=Var4 then Var4=0 ElsIf V3=Var5 then Var5=0 Endif // V4=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5))))) If V4=Var1 then Var1=0 ElsIf V4=Var2 then Var2=0 ElsIf V4=Var3 then Var3=0 ElsIf V4=Var4 then Var4=0 ElsIf V4=Var5 then Var5=0 Endif // V5=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5))))) If V5=Var1 then Var1=0 ElsIf V5=Var2 then Var2=0 ElsIf V5=Var3 then Var3=0 ElsIf V5=Var4 then Var4=0 ElsIf V5=Var5 then Var5=0 Endif // // V1...V5 are now sorted, in descending order // // should you need to have the original variables sorted, just write: Var1=V1 Var2=V2 Var3=V3 Var4=V4 Var5=V5 |
Thx very much robertogozzi, that’s already very valuable!
then I guess I can do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Var1-var2<15 then Rect1=var1 Rect2=var2 Endif If Var1-var3<15 then Rect1=var1 Rect2=var3 Endif If var1-var4<15 then Rect1=var1 Rect2=var4 Endif If var1-var5<15 then Rect1=var1 Rect2=var5 Endif |
And repeat that 4 more times (var2-var3<15 etc).and it should work.
problem maybe is that I have more than 50 variables, so it could become a very very long code.
So anyone has an idea in order to optimize that by first filtering all variables with price too far from the latest price? But then you add a level of complexity because you don’t know anymore how many variables do you have…
Yes, it’s very complex due to lack of arrays.
In a future major release they should be added, maybe before the end of 2020?
Anyway… your code is fine to find the boundaries of the rectangle.
You can move line 2 before line 1 and remove lines 6, 10 and 14, since the Rect1 will always be = Var1.
Also in my code lines 60 through 70 are useless, being the last variable.
Find exclusive trading pro-tools on