Asesores Expertos: Ejemplos del libro "Redes neuronales en el trading algorítmico en MQL5" - página 4

 
no " nuestro_modelo.net ", ¿a dónde vamos?
 
اللعبه :

MQL5 :

المؤلف : MetaQuotes

اخرزميات انا عالم التكنولوجيا الجديدة ومطور برامج ومنشء تطبيقات
 
¡Muchas gracias al autor por el libro! La única minus)))) - mi Alice Pro perdió la magia de la "conciencia" para mí) Con respeto, Igor.
 
//+------------------------------------------------------------------+
//|EA FVG avanzado.mq5
//+------------------------------------------------------------------+
#property strict

input double Lots = 0.1;
input int TakeProfit = 200;
input int StopLoss = 200;
input int MaxLookback = 50;
input int Slippage = 5;
input int MagicNumber = 123456;
input double MaxSpreadPoints = 20.0; // Maksimum izin verilen spread
input int MA_Period = 50; // Trend filtresi
input int StartHour = 8;  // İşlem saat aralığı başlangıç
input int EndHour = 20;   // İşlem saat aralığı bitiş

//+------------------------------------------------------------------+
int OnInit()
  {
   Print("Advanced FVG EA başlatıldı".);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnTick()
  {
   // Yeni bar kontrolü
   static datetime lastBarTime = 0;
   MqlRates candles[3];
   if(CopyRates(_Symbol, PERIOD_M5, 0, 3, candles) < 3) return;
   if(candles[0].time == lastBarTime) return;
   lastBarTime = candles[0].time;

   // Zaman filtresi
   int currentHour = TimeHour(TimeCurrent());
   if(currentHour < StartHour || currentHour >= EndHour) return;

   // Spread kontrolü
   double spread = (SymbolInfoDouble(_Symbol, SYMBOL_ASK) - SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point;
   if(spread > MaxSpreadPoints) return;

   // Pozisyon kontrolü
   if(PositionSelect(_Symbol)) return;

   // Trend filtresi (MA)
   double ma = iMA(_Symbol, PERIOD_M5, MA_Period, 0, MODE_SMA, PRICE_CLOSE, 0);
   double price = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   // FVG tespiti
   double fvgHigh = 0;
   double fvgLow = 0;
   bool isBullishFVG = false;
   bool isBearishFVG = false;

   MqlRates rates[];
   if(CopyRates(_Symbol, PERIOD_M5, 2, MaxLookback, rates) < 3) return;

   for(int i = 0; i < ArraySize(rates)-2; i++)
     {
      double high0 = rates[i].high;
      double low2 = rates[i+2].low;
      double low0 = rates[i].low;
      double high2 = rates[i+2].high;

      // FVG alcista (sadece yükselen trendde aç)
      if(high0 < low2 && price > ma)
        {
         isBullishFVG = true;
         fvgHigh = low2;
         fvgLow = high0;
         break;
        }
      // FVG bajista (sadece düşen trendde aç)
      else if(low0 > high2 && price < ma)
        {
         isBearishFVG = true;
         fvgHigh = low0;
         fvgLow = high2;
         break;
        }
     }

   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

   // İşlem açma
   if(isBullishFVG && bid <= fvgHigh && bid >= fvgLow)
     {
      trade_buy(ask);
     }
   else if(isBearishFVG && ask >= fvgLow && ask <= fvgHigh)
     {
      trade_sell(bid);
     }
  }
//+------------------------------------------------------------------+
void trade_buy(double price)
  {
   double sl = price - StopLoss * _Point;
   double tp = price + TakeProfit * _Point;

   MqlTradeRequest req = {};
   MqlTradeResult res  = {};

   req.action = TRADE_ACTION_DEAL;
   req.symbol = _Symbol;
   req.volume = Lots;
   req.type = ORDER_TYPE_BUY;
   req.price = price;
   req.sl = NormalizeDouble(sl, _Digits);
   req.tp = NormalizeDouble(tp, _Digits);
   req.deviation = Slippage;
   req.magic = MagicNumber;
   req.comment = "FVG Buy";

   if(OrderSend(req, res))
      Print("Orden de compra:", res.retcode);
   else
      Print("Orden de compra hatası: ", res.retcode);
  }
//+------------------------------------------------------------------+
void trade_sell(double price)
  {
   double sl = price + StopLoss * _Point;
   double tp = price - TakeProfit * _Point;

   MqlTradeRequest req = {};
   MqlTradeResult res  = {};

   req.action = TRADE_ACTION_DEAL;
   req.symbol = _Symbol;
   req.volume = Lots;
   req.type = ORDER_TYPE_SELL;
   req.price = price;
   req.sl = NormalizeDouble(sl, _Digits);
   req.tp = NormalizeDouble(tp, _Digits);
   req.deviation = Slippage;
   req.magic = MagicNumber;
   req.comment = "FVG Sell";

   if(OrderSend(req, res))
      Print("Sell order gönderildi:", res.retcode);
   else
      Print("Orden de venta hatası: ", res.retcode);
  }
//+------------------------------------------------------------------+
 
Cuando utilizo el gpt_not_norm.net después de ejecutar el script "gpt_test_not_norm" obtengo el siguiente error

" Error de Feed Forward: 0" en el probador de estrategias

Me aseguré de establecer la variable de entrada "BarsToLine" en 40, la cual utilicé para recopilar y para entrenar el modelo.

si utilizo el script "atención" funciona bien


 
Es un gran trabajo y muy útil, pero hay un problema.(Error de modo de carga gpt_not_norm.net: 5008)¿Hay alguna solución para ello?
 

Hola a todos. Creo que muchos de nosotros nos hemos topado con errores y es muy frustrante. Para ser honesto con usted, yo también estaba muy emocionado en el principio para obtener el asesor de expertos para trabajar y como era de esperar me encontré en un montón de errores.

Si tienes paciencia y vas a través del libro mientras miras el código paso a paso te garantizo que te encontrarás haciendo lo correcto y obteniendo los resultados que quieres. Lo que más necesitas es entender el lenguaje mql5 lo mejor que puedas.


Yo por suerte soy capaz de hacer funcionar todo el código y el expert advisor también funciona pero necesito una estrategia.


Una cosa más. Cada vez que el código se está ejecutando y lo detengo, estoy recibiendo dos objetos de búfer con fugas en la memoria. Necesito ayuda para encontrar este error.

 
607967 #:

Una cosa más. Cada vez que el código se está ejecutando y lo detengo, estoy recibiendo dos objetos de búfer con fugas en la memoria. Necesito ayuda para encontrar este error.

Eso suele ocurrir cuando los manejadores de los indicadores no se liberan de la memoria del terminal al quitar EA.

Prueba a cambiar

//+------------------------------------------------------------------+
//| Función de desinicialización experta|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(!!net)
      delete net;
   if(!!trade)
      delete trade;
   IndicatorRelease(h_RSI);
   IndicatorRelease(h_MACD);
  }

a:

//+------------------------------------------------------------------+
//| Función de desinicialización experta|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(!!net)
      delete net;
   if(!!trade)
     delete trade;
   if(h_RSI != INVALID_HANDLE || h_MACD != INVALID_HANDLE)
    {
     IndicatorRelease(h_RSI);
     IndicatorRelease(h_MACD);
    }
  } // Este código no está probado.