Works like a charm

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
Hello,
I would like to know if this code is correct to close an opened position with lot size = LOT :
What I did is that I removed SL and TP arameter so that it close at the latest bid price.
Thank you
//--- Putting all together
if(Sell_Condition_1)
{
// any opened Buy position?
if(Buy_opened)
{
Alert("We already have a Buy Position!!!");
ZeroMemory(mrequest);
mrequest.action=TRADE_ACTION_DEAL; // immediate order execution
mrequest.price = NormalizeDouble(latest_price.bid,_Digits); // latest Bid price
//mrequest.sl = NormalizeDouble(latest_price.bid + STP *_Point,_Digits); // Stop Loss
//mrequest.tp = NormalizeDouble(latest_price.bid - TKP *_Point,_Digits); // Take Profit
mrequest.symbol = _Symbol; // currency pair
mrequest.volume = Lot; // number of lots to trade
mrequest.magic = EA_Magic; // Order Magic Number
mrequest.type= ORDER_TYPE_SELL; // Sell Order
mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type
mrequest.deviation=100; // Deviation from current price
//--- send order
OrderSend(mrequest,mresult);
// get the result code
if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed
{
Alert("SELL.sl ", mrequest.sl - mrequest.price);
Alert("A Sell order has been successfully placed with Ticket#:",mresult.order,"!!");
}
else
{
Alert("The Sell order request could not be completed -error:",GetLastError());
ResetLastError();
return;
}
}
}
return;
}