Capture price when one indicator equals another but not if it happens subsequent
Forums › ProRealTime English forum › ProBuilder support › Capture price when one indicator equals another but not if it happens subsequent
- This topic has 8 replies, 2 voices, and was last updated 6 years ago by robdav.
-
-
02/06/2018 at 6:58 PM #61768
Hi
I’m trying to write an indicator that captures the price when one indicator becomes the same value as another.
This condition might then continue to happen over the next few bars but I need to capture the price when it first happened and not when it happens subsequently.
I’ve tried using ONCE but doesn’t seem to do it.
Does anyone have any ideas please?
Thanks
Rob
02/07/2018 at 11:24 AM #61845Does it occurs inside the bar? Does it needs to be the exact same value?
Because, we can’t store something in a variable inside a bar, variables are reset at every new tick received. So the best we can do is to test a range of values. I could post an example, but I have no idea of what indicators you are willing to compare?
02/07/2018 at 11:43 AM #61848Hi Nicolas
It doesn’t need to be exact. If I can know what bar it occurred in I could potentially use the close of the previous candle but the closer the better.
It’s actually two Donchian channels of period 19 and 20, as an example.
Thanks
Rob
02/07/2018 at 4:13 PM #6187202/08/2018 at 12:12 PM #6200002/08/2018 at 1:20 PM #62015Thinking about it, would it be possible to capture the amount of bars back it happened from the current bar?
I could then use something like:
1lowest[numberofbarsback](lower)to capture the value.
If not, then I guess the close would be best but I would like the periods to be configurable. 20 and 30 would be a good example.
Thanks Nicolas for any help as it’s stumped me a bit which is why I’m thinking bars back when it happened would be good.
02/08/2018 at 1:28 PM #6201702/08/2018 at 2:38 PM #62024With this code snippet, you’ll find how many bars ago a 19 and 20 periods upper donchian channel has crossed (bars variable), and I also store the Close of the candlestick when it happened (value variable).
1234567891011121314hh1 = highest[19](high)hh2 = highest[20](high)x = 100 //how much bars in the past for finding the the donchian crossfor i = 0 to x doif hh1[i]=hh2[i] and hh1[i+1]<>hh2[i+1] thenbars = ivalue = close[i] //or any other value you want to store herebreakendifnextreturn bars as "donchian crossed x bars ago", value as "=Close X bars ago"You can adapt it to find the same thing for a lower donchian channel cross.
1 user thanked author for this post.
02/08/2018 at 3:44 PM #62033 -
AuthorPosts
Find exclusive trading pro-tools on