A few points . . . not all relevant to your issue but you need to be aware of them none the less . . .
Slippage isn't implemented in the Strategy Tester
You only need to use RefreshRates to refresh the Predefined variables
In your code above it seems you are using the OrderOpenPrice from a Buy (Ask) + (StopLoss * UsePoint) as the price you want to open at, when was it placed ? what has price done since then ?. . . to open a Sell . . . a Sell is placed at current Bid price. You also seem to be using the OrderOpenPrice for the StopLoss . . .
As a reminder . . . OrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit)
Try this . . .
int BuyHedge = OrderSend(Symbol(), OP_SELL, OrderLots(), Bid, UseSlippage, OrderOpenPrice() + StopLoss * UsePoint, 0, "ForexRebel", MagicNumber, 0, Green);
A few points . . . not all relevant to your issue but you need to be aware of them none the less . . .
Slippage isn't implemented in the Strategy Tester
You only need to use RefreshRates to refresh the Predefined variables
In your code above it seems you are using the OrderOpenPrice from a Buy (Ask) + (StopLoss * UsePoint) as the price you want to open at, when was it placed ? what has price done since then ?. . . to open a Sell . . . a Sell is placed at current Bid price. You also seem to be using the OrderOpenPrice for the StopLoss . . .
As a reminder . . . OrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit)
Try this . . .
Thanks RaptorUK for your efforts and time taken to help me solve my problem.
I realise that I used RefreshRates() unnecessary - but I was desperate to solve the problem and willing to try anything.
I think I understand now that I am using the OrderOpenPrice() operator which was applied to a previous Buy (Ask) transaction to place a Sell (Bid) transaction and that is where the problem could lie.
I don't understand why something like OrderOpenPrice() + StopLoss * UsePoint is acceptable as the stoploss but not as the Sell price. Could you please explain?
I don't understand why something like OrderOpenPrice() + StopLoss * UsePoint is acceptable as the stoploss but not as the Sell price. Could you please explain?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am busy back testing an EA and keep on getting an "error 138 - Requote" although I have never before had this problem in back testing or in live usage since I always build in a healthy slippage in all my OrderSend() commands.
I have changed the Price from the one in the OrderSend command line as shown below in the code to be simply just "Ask' or "Bid", but it makes no difference.
I hope that somebody can help me discover the problem.