Are you factoring in the Spread ?
if (SignalBUY=="true") { if(HideSL == false && StopLoss > 0) {SL = Ask-StopLoss*Point ;}
You Buy at the Ask and Sell at the Bid.
So for a Buy, SL it is below the Bid (the Sell price)
if (SignalSELL=="true") { if(HideSL == false && StopLoss > 0) {SL = Bid+StopLoss*Point;}
So for a Sell, sL is above the Ask (the Buy price)- EA's should adjust for 4/5 digit brokers, TP, SL, AND slippage.
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket()...) Alert("OrderModify failed: ", GetLastError()); */
WHRoeder:
You Buy at the Ask and Sell at the Bid.
So for a Buy, SL it is below the Bid (the Sell price)
So for a Sell, sL is above the Ask (the Buy price)- EA's should adjust for 4/5 digit brokers, TP, SL, AND slippage.
thankyou
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 have this code before. The StopLoss is set at 30 points at the moment, but when a trade is placed, the stop loss on the trade is anything between 60 and 70 points. Seems very random and I cant work out what is causing this.
Can anyone help me with this please ?