Code two indicators conditions one before the other one

Forums ProRealTime English forum ProOrder support Code two indicators conditions one before the other one

Viewing 7 posts - 1 through 7 (of 7 total)
  • #20387

    Hello.

    I want to use to different indicators in a trading system. Stochastics and MACD. I want to buy when stochastics under <20 and MACD minus signal turns >0.0. First Stochastics and then MACD. Not simultaneously. They follow each other.

    Can anyone help me with the code?

    Now I have;

    IF C3 AND c4 THEN.

    Replace AND?

    #20403

    You can refer to a past conditions with periods offset under bracket:

    In this example, the C3 condition was met 2 bars ago and the C4 one, on the current candlestick.

    Please let us know if you have any other questions about testing conditions in the past data.

     

    #20436

    It partially worked.

    The code I am looking for is when one indicator is meet, for exampel Stochastic < 20 and regardless of the time, MACD minus signal is >0.

    #20546

    How much maximum bars in the past would you like to know if the stochastic was in the oversold area before your MACD condition happen?

    #20708

    If I understand this correct. When I use “AND” between to indicators, the to conditions has to happen simultaneously. This is not what I want. First one indicator and then the other, regardless of the time for the first one.

     

    If I use Stochastic < 20 and Stochastic %K crosses over Stochastic %D and I use “AND” between them, the crossover has to happen when Stochastic under < 20. But if I want the crossover to happen but not necessarily Stochastic <20. How do I code that?

    #20715

    That’s the reason why I asked you this question:

    How much maximum bars in the past would you like to know if the stochastic was in the oversold area before your MACD condition happen?

    For this purpose, we need to create a condition that will return “true” if the stochastic were at least 1 bar under level 20, X bars before now, but we have to define how much bars to lookback, otherwise we could fetch through the entire history! 🙂

    Your C3 condition could look like this:

    Where ‘sto’ is your stochastic variable of course. So if the stochastic was at least one bar under level 20 between now and 10 bars ago, C3 will be true. You can now easily adapt this code snippet to your stochastic %D and %K cross also.

     

    #20718

    Thanks. I will test it.

Viewing 7 posts - 1 through 7 (of 7 total)

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