Question: I have a function:

```
cond14 = (df.SMA > df.EMA)
df['Cross'] = np.where(cond14, 100, 0)

```

I don't want the function to be too rigid i.e. I don't want the SMA to be precisely higher than EMA; a variation of 2% is ok. Say SMA = 59.12 & EMA = 59.75 should pass through the function.

Is there some way to add that flexibility? Little help will be dearly appreciated :)

THANKS!

Answer: 
Perhaps an easy way would be to filter them out via a simple threshold.

For example, you could say something like:

```
cond14 = (df.SMA + threshold > df.EMA)

```

where threshold can be calculated in accordance with your needs.
I suggest to add the tolerance margin explicitly:

```
margin = 0.02
cond14 = (df.SMA > df.EMA * (1-margin) )
df['Cross'] = np.where(cond14, 100, 0)

```