Define price zone via an indicator
Forums › ProRealTime English forum › ProBuilder support › Define price zone via an indicator
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by
robertogozzi.
-
-
08/25/2019 at 3:07 PM #105517
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
08/25/2019 at 3:48 PM #105519To sort 5 variables you’ll have to write:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879Var1=200Var2=150Var3=196Var4=207Var5=110//V1=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5)))))If V1=Var1 thenVar1=0ElsIf V1=Var2 thenVar2=0ElsIf V1=Var3 thenVar3=0ElsIf V1=Var4 thenVar4=0ElsIf V1=Var5 thenVar5=0Endif//V2=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5)))))If V2=Var1 thenVar1=0ElsIf V2=Var2 thenVar2=0ElsIf V2=Var3 thenVar3=0ElsIf V2=Var4 thenVar4=0ElsIf V2=Var5 thenVar5=0Endif//V3=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5)))))If V3=Var1 thenVar1=0ElsIf V3=Var2 thenVar2=0ElsIf V3=Var3 thenVar3=0ElsIf V3=Var4 thenVar4=0ElsIf V3=Var5 thenVar5=0Endif//V4=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5)))))If V4=Var1 thenVar1=0ElsIf V4=Var2 thenVar2=0ElsIf V4=Var3 thenVar3=0ElsIf V4=Var4 thenVar4=0ElsIf V4=Var5 thenVar5=0Endif//V5=max(Var1,max(Var2,max(Var3,max(Var4,max(Var5)))))If V5=Var1 thenVar1=0ElsIf V5=Var2 thenVar2=0ElsIf V5=Var3 thenVar3=0ElsIf V5=Var4 thenVar4=0ElsIf V5=Var5 thenVar5=0Endif//// V1...V5 are now sorted, in descending order//// should you need to have the original variables sorted, just write:Var1=V1Var2=V2Var3=V3Var4=V4Var5=V51 user thanked author for this post.
08/25/2019 at 4:39 PM #105523Thx very much robertogozzi, that’s already very valuable!
then I guess I can do:
12345678910111213141516Var1-var2<15 thenRect1=var1Rect2=var2EndifIf Var1-var3<15 thenRect1=var1Rect2=var3EndifIf var1-var4<15 thenRect1=var1Rect2=var4EndifIf var1-var5<15 thenRect1=var1Rect2=var5EndifAnd 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…
08/25/2019 at 6:05 PM #105526Yes, 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.
-
AuthorPosts
Find exclusive trading pro-tools on