EA doesnt trade

Back to topics list To post a new topic, please log in or register
avatar
34
Stan4o1 2015.12.25 22: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
avatar
Moderator
3404
GumRai 2015.12.25 23: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? 

avatar
34
Stan4o1 2015.12.26 09: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 
avatar
Moderator
3404
GumRai 2015.12.26 13: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. 

 

 

avatar
34
Stan4o1 2015.12.26 14: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?
avatar
120
DeanDeV 2015.12.26 16: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
avatar
34
Stan4o1 2015.12.26 18:41 #
 
Thanks ;)
avatar
Moderator
3404
GumRai 2015.12.26 21: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
avatar
34
Stan4o1 2015.12.27 10:15 #
 
This is good to know, Thank you
Back to topics list  

To add comments, please log in or register