Download MetaTrader 5
To add comments, please log in or register
Are you a good trader? Become a signals provider and make even more money!
Stan4o1
118
Stan4o1 2015.12.25 21:37 
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
Keith Watford
Moderator
7906
Keith Watford 2015.12.25 22:42  
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? 

Stan4o1
118
Stan4o1 2015.12.26 08:32  
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 
Keith Watford
Moderator
7906
Keith Watford 2015.12.26 12:56  

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. 

Stan4o1
118
Stan4o1 2015.12.26 13:39  
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?
DeanDeV
330
DeanDeV 2015.12.26 15:01  
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(Close[1]<Open[1] && Ask<Close[1])     //Sell orders

if(Rsi1>=30 && Rsi0<30)
 if(Close[1]>Open[1] && Bid>Close[1])     //Buy orders
Stan4o1
118
Stan4o1 2015.12.26 17:41  
Thanks ;)
Keith Watford
Moderator
7906
Keith Watford 2015.12.26 20:18  
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
Stan4o1
118
Stan4o1 2015.12.27 09:15  
This is good to know, Thank you
/
To add comments, please log in or register