118

Hi guys im here with the typical problem again im trying some code but the EA doesnt trade when the
`Rsi1<=70`
code is in.
```double Rsi0 = iRSI(NULL,0,14,PRICE_CLOSE,0);
double Rsi1 = iRSI(NULL,0,14,PRICE_CLOSE,1);

if (Rsi0>70 && Rsi1<=70 &&  Bid<Close[1] && Close[1]<Open[1])
```
if the code i said before is in the if statement it does not trade, if it isnt it trades. I have  a similar if construction for buy orders , in it i have  similar code like the one bellow, but it trades and I wonder why My code doesnt trade with the mentioned code, I still dont figure out why, i used print but everything is ok , Can u help me ?
`Rsi1>=30`
Moderator
10617

`if (Rsi0>70 && Rsi1<=70 &&  Bid<Close[1] && Close[1]<Open[1])`

As this condition requires the RSI to cross above the 70 level at the same time as price falls, the condition will not be met often.

What is the code for the buycondition?

118

```if (Rsi0<30 && Rsi1>=30  && Close[1]>Open[1] && Ask>Close[1] )
```
This is the buy code. The sell code`s purpose is to open position  when the Rsi reverses and the price bellow the close of the previous one. The buy code has the same structure but it trades.  Thanks for the help GumRai
Moderator
10617

Depending on whether you are checking these conditions only at the open of a new bar or not, then your buy condition is more likely to be true than the sell condition.

`Bid<Close[1]`
`Ask>Close[1]`

In both conditions, Close[1] is the Bid price, in the first you are comparing Bid with Bid, in the 2nd Ask with Bid.

As Ask is always larger than the Bid, the 2nd condition is more likely to be true.

118

Im not trying to check only at the beginning of the new bar, but whenever the price breaks above the close of the previous bar(if the close is above the open) for buy and the oppposite for sell, How to change the code to achieve that?
330

Stan4o1:
Im not trying to check only at the beginning of the new bar, but whenever the price breaks above the close of the previous bar(if the close is above the open) for buy and the oppposite for sell, How to change the code to achieve that?

Rather use Ask for sell orders and Bid for buy orders as triggers to accommodate for the spread... Haven't checked, but it should trade if those conditions are met.

```if(Rsi1<=70 && Rsi0>70)

if(Rsi1>=30 && Rsi0<30)
118

Thanks ;)
Moderator
10617

DeanDeV:

Rather use Ask for sell orders and Bid for buy orders as triggers to accommodate for the spread... Haven't checked, but it should trade if those conditions are met.

In my opinion, it is illogical to compare Ask with any chart price as the chart price is always Bid, Therefore all chart price comparisons should be with Bid
118

This is good to know, Thank you