UT Alart Bot
- Indicadores
- Menaka Sachin Thorat
- Versión: 1.3
- Actualizado: 20 enero 2025
Para acceder a la versión MT4, haga clic en https://www.mql5.com/en/market/product/130055
- Esta es la conversión exacta de TradingView: "Ut Alart Bot Indicador".
- Usted puede mensaje en el chat privado para otros cambios que necesita.
Aquí está el código fuente de un simple Asesor Experto que opera sobre la base de señales de Ut Bot Indicador.
#property copyright "This EA is only education purpose only use it ur own risk" #property link "https://sites.google.com/view/automationfx/home" #property version "1.00" #include <Trade\Trade.mqh> CTrade trade; int indicator_handle; input group "EA Setting" input int magic_number = 123456; // Magic number input double fixed_lot_size = 0.01; // Fixed lot size input double AtrCoef = 2; // ATR Coefficient (Sensitivity) input int AtrLen = 10; // ATR Period input string IndicatorName = "Market/UT Alart Bot"; // Ind icator name // Buffers for indicator double BullBuffer[]; double BearBuffer[]; datetime timer = NULL; int OnInit() { trade.SetExpertMagicNumber(magic_number); // Load the custom indicator indicator_handle = iCustom(NULL, 0, IndicatorName); if (indicator_handle == INVALID_HANDLE) { Print("Failed to load indicator. Error: ", GetLastError()); return(INIT_FAILED); } // Initialize buffers ArraySetAsSeries(BullBuffer, true); ArraySetAsSeries(BearBuffer, true); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { IndicatorRelease(indicator_handle); } void OnTick() { if (!isNewBar()) return; // Get the latest buffer values if (CopyBuffer(indicator_handle, 0, 0, 1, BullBuffer) <= 0 || CopyBuffer(indicator_handle, 1, 0, 1, BearBuffer) <= 0) { Print("Failed to copy buffer. Error: ", GetLastError()); return; } // Buy conditions bool buy_condition = true; buy_condition &= (BuyCount() == 0); buy_condition &= IsUTBuy(1); if (buy_condition) { CloseSell(); Buy(); } // Sell conditions bool sell_condition = true; sell_condition &= (SellCount() == 0); sell_condition &= IsUTSell(1); if (sell_condition) { CloseBuy(); Sell(); } } bool IsUTBuy(int i) { double array[]; ArraySetAsSeries(array, true); CopyBuffer(indicator_handle, 0, i, 1, array); double val1 = array[0]; CopyBuffer(indicator_handle, 1, i, 1, array); double val2 = array[0]; return val1 > val2; } bool IsUTSell(int i) { double array[]; ArraySetAsSeries(array, true); CopyBuffer(indicator_handle, 0, i, 1, array); double val1 = array[0]; CopyBuffer(indicator_handle, 1, i, 1, array); double val2 = array[0]; return val1 < val2; } int BuyCount() { int buy=0; for(int i=0;i<PositionsTotal();i++) { ulong ticket=PositionGetTicket(i); if(ticket==0) continue; if(PositionGetInteger(POSITION_TYPE) != POSITION_TYPE_BUY) continue; if(PositionGetInteger(POSITION_MAGIC) != magic_number) continue; buy++; } return buy; } int SellCount() { int sell=0; for(int i=0;i<PositionsTotal();i++) { ulong ticket=PositionGetTicket(i); if(ticket==0) continue; if(PositionGetInteger(POSITION_TYPE) != POSITION_TYPE_SELL) continue; if(PositionGetInteger(POSITION_MAGIC) != magic_number) continue; sell++; } return sell; } void Buy() { double Ask=SymbolInfoDouble(_Symbol, SYMBOL_ASK); if(!trade.Buy(fixed_lot_size, _Symbol, Ask, 0, 0, "")) { Print("Error executing order: ", GetLastError()); //ExpertRemove(); } } void Sell() { double Bid=SymbolInfoDouble(_Symbol, SYMBOL_BID); if(!trade.Sell(fixed_lot_size, _Symbol, Bid, 0, 0, "")) { Print("Error executing order: ", GetLastError()); //ExpertRemove(); } } void CloseBuy() { for(int i=PositionsTotal()-1;i>=0;i--) { ulong ticket=PositionGetTicket(i); if(ticket==0) continue; if(PositionGetInteger(POSITION_TYPE) != POSITION_TYPE_BUY) continue; if(PositionGetInteger(POSITION_MAGIC) != magic_number) continue; if(trade.PositionClose(ticket)==false) { Print("Error closing position: ", GetLastError()); //ExpertRemove(); } } } void CloseSell() { for(int i=PositionsTotal()-1;i>=0;i--) { ulong ticket=PositionGetTicket(i); if(ticket==0) continue; if(PositionGetInteger(POSITION_TYPE) != POSITION_TYPE_SELL) continue; if(PositionGetInteger(POSITION_MAGIC) != magic_number) continue; if(trade.PositionClose(ticket)==false) { Print("Error closing position: ", GetLastError()); } } } bool isNewBar() { datetime candle_start_time= (int)(TimeCurrent()/(PeriodSeconds()))*PeriodSeconds(); if(timer==NULL) {} else if(timer==candle_start_time) return false; timer=candle_start_time; return true; }

great product