programming question?

1mathboy1
118
suppose I want to enter a trade when one condition just occured and another occured in the last 4 bars. how do I code that? for example, if I want to buy if stochastic crosses above 20, and RSI crossed 30 in the last 3 bars, do I need to define RSI for the last 3 bars and then code that? can I use a for loop instead? but I don't know how to code the boolean logic using the for loop.
Ian Venner
2400
Ian Venner  

test for the stochastic if it is above 20 test the RSI in a for loop. Use the shift parameter in iRSI() with the for loop.

kinda like this

if(iStocs >20)

{for(i=0 .. etc

 {if(iRSI(parameters,i) >30) 

  {bool flag=true;

}}} 

1mathboy1
118
1mathboy1  
Thanks! one more thing-what if I need a crossover? For example, if stochastic crossed with its signal line in the last 3 bars, we wont enter a buy.
William Roeder
25880
William Roeder  
1mathboy1: what if ...
Code it.