My position doens't close
Gouveiaa:
Hi, so instead of putting a Take profit in points, I used another expression And I have this, I have no Take Profit, but I have a Stop LossThe expert recognizes the Stop Loss but the position, when open, doesn't close when
Hi, so instead of putting a Take profit in points, I used another expression And I have this, I have no Take Profit, but I have a Stop LossThe expert recognizes the Stop Loss but the position, when open, doesn't close when
Can someone help me? Regards
Hi
Try this
PositionSelect(_Symbol);if(LongPositionOpen() == true && rate[1].close > BBMidle[1]) { trade.PositionClose(_Symbol);
}
PedroQuina:
Can't do that, I have my fuction like this Hi
Try this
}
bool LongPositionOpen() { MqlTradeRequest request; // Will be used for trade requests MqlTradeResult result; // Will be used for results of trade requests ZeroMemory(request); ZeroMemory(result); double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask price double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); string position_symbol=PositionGetString(POSITION_SYMBOL); double positionOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN); double sl=PositionGetDouble(POSITION_SL); // Stop Loss of the position ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); if(!PositionSelect(_Symbol)) { request.action = TRADE_ACTION_DEAL; // Immediate order execution request.price = NormalizeDouble(ask,_Digits); // Lastest Ask price request.symbol=position_symbol; request.sl = NormalizeDouble(ask - STP*_Point,_Digits); // Stop Loss request.tp = 0; // Take Profit request.symbol = _Symbol; // Symbol request.volume = Lot; // Number of lots to trade request.magic = 0; // Magic Number request.type = ORDER_TYPE_BUY; // Buy Order request.type_filling = ORDER_FILLING_FOK; // Order execution type request.deviation=5; // Deviation from current price return(OrderSend(request,result)); // Send order } return (false); }
Anyone?
Can someone help me? Regards