Hi
For starters, it looks as though the sell order has invalid stoploss and takeprofit (assuming the variables are positive). Try changing
OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Ask-stoploss*Point,Ask+takeprofit*Point,"JMBUYER",0,0,CLR_NONE);
to
OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Ask + stoploss*Point,Ask - takeprofit*Point,"JMBUYER",0,0,CLR_NONE);
Also, it is common to use the value returned by OrderSend() to check that the order was placed successfully. This short script demonstrates your error. You should see "ticket = -1, Error = 130," in the Experts tab of the terminal, which corresponds to invalid stops.
//+------------------------------------------------------------------+ //| TestOrderSend.mq4 | //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { int ticket; double Lots = 0.01; double stoploss = 100; double takeprofit = 100; ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Ask-stoploss*Point,Ask+takeprofit*Point,"JMBUYER",0,0,CLR_NONE); if( ticket <= 0 ) Print( "ticket = ", ticket, ", Error = ", GetLastError() ); return(0); } //+------------------------------------------------------------------+
Cheers
Jellybean
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I try to write an EA where two opposite instant orders of OP_BUY and OP_SELL COULD BE OPEN .I discover only one of the order keep opening, the other being ommited.Why?
int start(){
//----
if (time0 != Time[0]) {
OrderSend(Symbol(),OP_BUY,Lots,Ask,30,Bid-stoploss*Point,Bid+takeprofit*Point,"JMBUYER",0,0,CLR_NONE);
OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Ask-stoploss*Point,Ask+takeprofit*Point,"JMBUYER",0,0,CLR_NONE);
time0=Time[0];}
//----
return(0);
}
help look into it.Thanks