Download MetaTrader 5
To add comments, please log in or register
Log in to MQL5.community using OpenID. It is convenient!
ailanshi_7
13
ailanshi_7 2016.04.26 06:48 
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int period1 = 50;
extern int period2 =150;

void OnTick()
{
bool bill;
bill = rsi();
if (bill = 1)
{
ordersendbuy();
}
else if (bill = 0)
{
ordersendsell();
}
 
}
int rsi()
{
double ticket1=0 , ticket2=0;
 ticket1 = iRSI(Symbol(),0,period1,PRICE_CLOSE,0);
 Alert("the price of rsi 50= " , ticket1);
 ticket2 = iRSI(Symbol(),0,period2,PRICE_CLOSE,0);
 Alert("the price of rsi 150 =  " , ticket2);
 if (ticket1 >ticket2 )
 return(1);
 else if (ticket1 < ticket2)
 return(0);
 else
 return(EMPTY_VALUE);
}


void ordersendbuy()
{
int osd=0;
osd = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask+20*Point,Ask-30*Point);
}

void ordersendsell()
{
int obdt=0;
obdt = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask+20*Point,Ask-30*Point);

   }


I am just a beginner so i was just trying to execute basic programs but when

I  write this code and compile it no error were found in the compiler but when i test it there was a error 

" OrderSend error 130 " and in the least no order was placed

Can anyone help to resolve this problem.

Keith Watford
Moderator
7947
Keith Watford 2016.04.26 06:59  
osd = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask+20*Point,Ask-30*Point);

You cannot have SL higher than entry and TP lower than entry for a Buy

if (bill = 1)

else if (bill = 0)

These are not boolean tests, does it even compile?

Fernando Carreiro
1485
Fernando Carreiro 2016.04.26 08:22  

@ailanshi. Please do not double post. You already started the thread "}' - semicolon expected" to which I answered and now you post this one as a continuation, yet you have still not fixed all the errors I pointed out.

If you want people to help, then continue on the same thread and don't start a new one as a followup. Also, when the help that is given tells you how to fix it, please be so kind as to at least try them out to see it resolves you issue. Don't just ignore them.

whroeder1
13627
whroeder1 2016.04.26 12:59  
GumRai:
if (bill = 1)

else if (bill = 0)

These are not boolean tests, does it even compile?

Yes it compiles, but is bad style. Equivalent to
bill=1; if (bill)
else {bill=0; if (bill) ...
/
To add comments, please log in or register