Why does this code produce wrong SL half the time? - page 2

 
nadiawicket:

1. No minimum Stop Level with my broker.. How does this violate if that rule is for nonzero StopLevels?

2. I really don't understand why you are mentioning Take Profits at all? Maybe I'm missing your point or something.We are dealing with Stop Loss. ( which I'm using to effectively create a Trailing Stop)


Something else; no matter how I set the initial Stop Loss of my OrderSends, they bork out like 50 per cent of the time like its some glitch or I'm just not doing it right. If anyone could post the correct code for an OrderSend that puts the right Stop Loss from the get go without having to ordermodify afterwards, I'd really appreciate it.

For example the code above; whats wrong with it that it fails about 50 per cent of the times at setting the correct SL (10 points above) from the get go? They keep telling me to check return codes; however I get nothing with GetLastError() thats not a 0. What else can I check about "return codes"? The standard link doesn't say anything else I can make sense out of other than using the GetLastError()? Any other way to retrieve other return codes thats not GetlastError()?


Thanks a zillion.


Remember that 10 points is only 1 pip (on almost every broker).
 
honest_knave:

Example:

Ask: 1.10020

Bid: 1.10010

(spread 10 points)

If you set your SL on a sell order to 1.10010 (the Bid) then the closing price (Ask) is already above it. If this worked, your order would instantly close as the SL has been passed.

If you feed those numbers into the equation on the table:

A trade operation will not be performed if any of the following conditions is disrupted. 

SL - Ask ≥ StopLevel

1.10010 - 1.10020 = - 10 points

Even if your StopLevel is 0, a negative number is still less than 0.

I get that. Putting the SL at the Ask, and everywhere else, is unfortunately giving me the same issue.

However, I still need to ask:

Could anyone please post the correct code that places a sell order with a SL that works 100 per cent of the time? You can choose the SL. No matter what combination of values I try, the SL is always right only 50 per cent of fhe time.

How is

OrderSend(_Symbol,OP_SELL,.01,MarketInfo(_Symbol,MODE_BID),0,MarketInfo(_Symbol,MODE_ASK)+10*Point,0,NULL,0,0,clrNONE);

incorrect?

GetLastError() does not give me anything other than 0.

Need the SL to be as close to OpenOrderPrice() as can be for my next EA. Don't want to have to order modify every single trade.
 

Bah I think I got it. Was not looking at the right numbers. Answer was there in front of me the whole time.


Issue resolved. Thanks a zillion.

Reason: