deepseek_mql5_20250502_d5c8aa
deepseek_mql5_20250502_d5c8aa
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Verificar se já temos ordens abertas para não duplicar
if(OrdersTotal() > 0) return;
// Se já sabemos que não são todas iguais, podemos sair mais cedo
if(!allBullish && !allBearish) break;
}
if(UseBuyStopGreen)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK) + PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_BUY_STOP, entryPrice);
}
if(UseSellLimitGreen)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID) + PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_SELL_LIMIT, entryPrice);
}
if(UseSellStopGreen)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID) - PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_SELL_STOP, entryPrice);
}
}
// Se todas as velas são vermelhas (bearish)
else if(allBearish)
{
if(UseBuyLimitRed)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK) - PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_BUY_LIMIT, entryPrice);
}
if(UseBuyStopRed)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK) + PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_BUY_STOP, entryPrice);
}
if(UseSellLimitRed)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID) + PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_SELL_LIMIT, entryPrice);
}
if(UseSellStopRed)
{
double entryPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID) - PipsAway *
_Point;
PlacePendingOrder(ORDER_TYPE_SELL_STOP, entryPrice);
}
}
}
//+------------------------------------------------------------------+
//| Função para colocar ordens pendentes |
//+------------------------------------------------------------------+
void PlacePendingOrder(ENUM_ORDER_TYPE orderType, double entryPrice)
{
MqlTradeRequest request = {};
MqlTradeResult result = {};
request.action = TRADE_ACTION_PENDING;
request.symbol = _Symbol;
request.volume = LotSize;
request.type = orderType;
request.price = NormalizeDouble(entryPrice, _Digits);
request.deviation = Slippage;
request.magic = MagicNumber;
if(!OrderSend(request, result))
{
Print("Falha ao enviar ordem. Código de erro: ", GetLastError());
}
else
{
Print("Ordem enviada com sucesso. Ticket: ", result.order);
}
}