Code two indicators conditions one before the other one
Forums › ProRealTime English forum › ProOrder support › Code two indicators conditions one before the other one
- This topic has 6 replies, 2 voices, and was last updated 7 years ago by Nufstad.
-
-
01/10/2017 at 8:35 AM #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?
01/10/2017 at 10:37 AM #20403You can refer to a past conditions with periods offset under bracket:
1IF C3[2] AND C4 THENIn 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.
01/10/2017 at 11:52 AM #2043601/10/2017 at 4:31 PM #2054601/11/2017 at 1:28 PM #20708If 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?
01/11/2017 at 2:09 PM #20715That’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:
123X = 10 //define how much bars in the past we look if the stochastic were under level 20C3 = summation[x](sto<20)>0Where ‘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.
01/11/2017 at 2:15 PM #20718 -
AuthorPosts
Find exclusive trading pro-tools on