Trouble in SL and TP
[...] I really can't see any error in this piece of code..
There are two errors. Firstly, you are placing a sell order, but you are setting the t/p above the entry price and the s/l below it. Correct for a buy order, but the wrong way round for a sell order.
Secondly, MODE_STOPLEVEL is going to be a value such as 3 or 30 (or even zero on some brokers). Let's say that it's 3. What your code is doing is adjusting the sl and tp variables to the value 3 if either of them is less than 3. Let's say that you're trying to place a sell order on EURUSD. The current price is about 1.4273, and therefore the code will adjust both the s/l and t/p to 3.
Hey all =)
I'm having some trouble with the stoploss and takeprofit in OrderSend(). it seemsto be correct, but when i run my ea, it says that i'm sending wrong parameters to SL and TP.
This is my code:
if(StopLoss<=0)sl = Bid-NormalizeDouble(50*Point,5);
if(sl<MarketInfo(Symbol(),MODE_STOPLEVEL))sl = MarketInfo(Symbol(),MODE_STOPLEVEL);
if(tp<MarketInfo(Symbol(),MODE_STOPLEVEL))tp = MarketInfo(Symbol(),MODE_STOPLEVEL);
int od =OrderSend(Symbol(),OP_SELL,Lots,Bid,0,sl,tp,"ACandle",Magico,0,Yellow);
I really can't see any error in this piece of code..