STEP9 – How to build a real buy order

Now that we know how a buy order works, let’s create one

I do also store the AccountEquity after I open a trade in a variable called LastEquity. That way I can compare the current equity with the equity after a trade and decide if I want to take another trade.

Here is the code

void OpenBuyOrder()
{
MqlTradeRequest myrequest;
MqlTradeResult myresult;
ZeroMemory(myrequest);
myrequest.action = TRADE_ACTION_DEAL;
myrequest.type = ORDER_TYPE_BUY;
myrequest.symbol = _Symbol;
myrequest.volume = LotSize; // fill in a double value
myrequest.type_filling = ORDER_FILLING_FOK;
myrequest.price = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
myrequest.sl = 0 ;
myrequest.tp = 0 ;
myrequest.deviation =60;
OrderSend (myrequest,myresult);
LastEquity=AccountInfoDouble(ACCOUNT_EQUITY);
}