Hoping to get some help to code a close condition.
Just making my own moving average crossover EA. My first close condition says if 5 EMA crosses 21 EMA, but now I want to add another condition, so I have an "OR" condition. Now what I want is the EA to count how many SAR dots are formed since the orders opening. If it's a buy order, if there are 10 dots in a row below the prices, then once the current price touches the previous SAR dot, close the order. Vice Versa for sell. Basic logic would look something like:
// Close Buy Rules
if( 5 EMA > 21 EMA && 5 EMA < 21 EMA )
(wait for 10 SAR dots to form below the prices, then after the 10th dot from orderopen, if close < SAR)
I'm wondering if a "FOR" loop would be used here, and I'm hoping so as I have never used one before. It should basically look back after the 10th formed dot (or 10th bar I guess), and if they are all below the prices, there are 10 consecutive "BUY" dots formed, then once the current SAR changes direction, close the order. The standard 0.02 0.2 SAR can be used. Any ideas? Thanks a lot,