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

Viewing 9 posts - 1 through 9 (of 9 total)
  • #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

    #61845

    Does 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?

    #61848

    Hi 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

    #61872

    Hi Nicolas,

    I wasn’t being clear so I have tried to show it in a picture. Hopefully it will help.

    Thanks for any advice.

    Rob

    #62000

    Ok, so we can only “capture” the OHLC of the candlesticks where it happened, or the donchian values too of course. So what do you want? What are the periods of your 2 donchian channels?

    #62015

    Thinking 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:

    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.

    #62017

    Actually would you be able to capture the donchian values exactly where it happened or limited to the OHLC of the candle?  Exact would be ideal, otherwise bars back preferable.

    #62024

    With 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).

    You can adapt it to find the same thing for a lower donchian channel cross.

     

    1 user thanked author for this post.
    #62033

    Perfect, thank you Nicolas.

    If I can make any money with it I’ll be sending you some champagne!

    1 user thanked author for this post.
Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login