//+------------------------------------------------------------------+ // Expert…
- User
//+------------------------------------------------------------------+ //| Expert initialization | //+------------------------------------------------------------------+ #property strict
// Entradas configuráveis conforme a imagem input int MagicNumber = 123456; // Número mágico input double LotSize = 0.01; // Tamanho do lote padrão input bool UseBalanceForLot = false; // Usar lote baseado no saldo input double BalancePercentageForLot = 0.0; // Percentual do saldo para determinar o lote input bool UseTakeProfit = true; // Usar Take Profit input double TakeProfitPips = 10.0; // Take Profit em pips input bool UseStopLoss = true; // Usar Stop Loss input double StopLossPips = 30.0; // Stop Loss em pips input double MaxDailyGainUSD = 10.0; // Meta de ganhos diária em USD input double MaxDailyLossUSD = 10.0; // Meta de perdas diária em USD input double MaxDrawdownPercentage = 10.0; // Máximo de drawdown permitido em porcentagem input bool PauseForNews = false; // Pausar para notícias input int MinutesBeforeNews = 20; // Minutos antes da notícia para pausar input int MinutesAfterNews = 20; // Minutos após a notícia para retomar
// Configurações de indicadores input int MACD_FastEMA = 10; // Configuração ajustada conforme imagem input int MACD_SlowEMA = 21; input int MACD_SignalSMA = 1; input double RenkoFilter = 21.0; // Tamanho do bloco Renko ajustado para 21 (conforme "MaPeriod")
// Handles para indicadores int handleEMA8; int handleEMA21; int handleMACD; double EMA8[], EMA21[]; double MACD_Main[], MACD_Signal[];
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // Criação das EMAs handleEMA8 = iMA(NULL, PERIOD_H1, 8, 0, MODE_EMA, PRICE_CLOSE); handleEMA21 = iMA(NULL, PERIOD_H1, 21, 0, MODE_EMA, PRICE_CLOSE);
// Criação do MACD handleMACD = iMACD(NULL, PERIOD_H1, MACD_FastEMA, MACD_SlowEMA, MACD_SignalSMA, PRICE_CLOSE);
if (handleEMA8 == INVALID_HANDLE || handleEMA21 == INVALID_HANDLE || handleMACD == INVALID_HANDLE) { Print("Erro ao criar indicadores."); return INIT_FAILED; }
return INIT_SUCCEEDED; }
//+------------------------------------------------------------------+ //| Expert deinit function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { IndicatorRelease(handleEMA8); IndicatorRelease(handleEMA21); IndicatorRelease(handleMACD); }
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // Verificar se temos dados suficientes if (BarsCalculated(handleEMA8) < 2 || BarsCalculated(handleEMA21) < 2 || BarsCalculated(handleMACD) < 2) return;
- Assistant